forked from jrl-umi3218/jrl-cmakemodules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dist.cmake
114 lines (105 loc) · 4.48 KB
/
dist.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# Copyright (C) 2008-2014 LAAS-CNRS, JRL AIST-CNRS.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# _SETUP_PROJECT_DIST
# -------------------
#
# Add a dist target to generate a tarball using git-archive.
#
# Linux specific: use git-archive-all.sh to obtain a recursive
# git-archive on the project's submodule.
# Please note that git-archive-all.sh is not carefully written
# and create a temporary file in the source directory
# (which is then moved to the build directory).
MACRO(_SETUP_PROJECT_DIST)
IF(UNIX)
FIND_PROGRAM(TAR tar)
FIND_PROGRAM(GPG gpg)
# Use git-archive-all.sh to generate distributable source code
ADD_CUSTOM_TARGET(distdir
COMMAND
rm -f /tmp/${PROJECT_NAME}.tar
&& ${PROJECT_SOURCE_DIR}/cmake/git-archive-all.sh
--prefix ${PROJECT_NAME}-${PROJECT_VERSION}/ ${PROJECT_NAME}.tar
&& cd ${CMAKE_BINARY_DIR}/
&& (test -d ${PROJECT_NAME}-${PROJECT_VERSION}
&& find ${PROJECT_NAME}-${PROJECT_VERSION}/ -type d -print0
| xargs -0 chmod a+w || true)
&& rm -rf ${PROJECT_NAME}-${PROJECT_VERSION}/
&& ${TAR} xf ${PROJECT_SOURCE_DIR}/${PROJECT_NAME}.tar
&& echo "${PROJECT_VERSION}" >
${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}/.version
&& ${PROJECT_SOURCE_DIR}/cmake/gitlog-to-changelog >
${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}/ChangeLog
&& rm -f ${PROJECT_SOURCE_DIR}/${PROJECT_NAME}.tar
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Generating dist directory..."
)
# Create a tar.gz tarball for the project, and generate the signature
ADD_CUSTOM_TARGET(dist_targz
COMMAND
${TAR} -czf ${PROJECT_NAME}-${PROJECT_VERSION}.tar.gz
${PROJECT_NAME}-${PROJECT_VERSION}/
&& ${GPG} --detach-sign --armor -o
${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}.tar.gz.sig
${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}.tar.gz
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating tar.gz tarball and its signature..."
)
# Create a tar.bz2 tarball for the project, and generate the signature
ADD_CUSTOM_TARGET(dist_tarbz2
COMMAND
${TAR} -cjf ${PROJECT_NAME}-${PROJECT_VERSION}.tar.bz2
${PROJECT_NAME}-${PROJECT_VERSION}/
&& ${GPG} --detach-sign --armor -o
${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}.tar.bz2.sig
${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}.tar.bz2
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating tar.bz2 tarball and its signature..."
)
# Create a tar.xz tarball for the project, and generate the signature
ADD_CUSTOM_TARGET(dist_tarxz
COMMAND
${TAR} -cJf ${PROJECT_NAME}-${PROJECT_VERSION}.tar.xz
${PROJECT_NAME}-${PROJECT_VERSION}/
&& ${GPG} --detach-sign --armor -o
${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}.tar.xz.sig
${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}.tar.xz
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating tar.xz tarball and its signature..."
)
# Alias: dist = dist_targz (backward compatibility)
ADD_CUSTOM_TARGET(dist DEPENDS dist_targz)
# TODO: call this during `make clean`
ADD_CUSTOM_TARGET(distclean
COMMAND
rm -rf ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${PROJECT_VERSION}/
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Cleaning dist sources..."
)
ADD_CUSTOM_TARGET(distorig
COMMAND
cmake -E copy ${PROJECT_NAME}-${PROJECT_VERSION}.tar.gz
${PROJECT_NAME}-${PROJECT_VERSION}.orig.tar.gz
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Generating orig tarball..."
)
ADD_DEPENDENCIES(dist_targz distdir)
ADD_DEPENDENCIES(dist_tarbz2 distdir)
ADD_DEPENDENCIES(dist_tarxz distdir)
ADD_DEPENDENCIES(distorig dist)
ELSE()
#FIXME: what to do here?
ENDIF()
ENDMACRO(_SETUP_PROJECT_DIST)