-
Notifications
You must be signed in to change notification settings - Fork 32
/
CMakeLists.txt
146 lines (124 loc) · 6.05 KB
/
CMakeLists.txt
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# ****************
# * BLAHP daemon *
# ****************
#
# $Id: $
#
# File: CMakeLists.txt
#
# Author(s): Francesco Prelz ($Author: $)
# e-mail: "[email protected]"
#
# Revision history:
#
# 5-Nov-2012 Created
cmake_minimum_required(VERSION 2.8.11)
project(BLAH)
# CPack info
set(RPM_PACKAGE_RELEASE_MAJ "1")
set(RPM_PACKAGE_RELEASE_MIN "0" CACHE STRING "Release minor")
set(CPACK_RPM_PACKAGE_RELEASE "${RPM_PACKAGE_RELEASE_MAJ}.${RPM_PACKAGE_RELEASE_MIN}")
if (UNIX AND NOT APPLE)
set(CPACK_GENERATOR "STGZ;DEB;RPM")
execute_process(COMMAND uname -i
OUTPUT_VARIABLE local_arch OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CPACK_SYSTEM_NAME "${CPACK_RPM_PACKAGE_RELEASE}.${local_arch}")
endif (UNIX AND NOT APPLE)
set(CMAKE_INSTALL_PREFIX "/usr")
set(CPACK_PACKAGE_VENDOR "EMI")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Batch Local ASCII Helper Protocol suite")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/blah_description.txt")
file(READ ${CPACK_PACKAGE_DESCRIPTION_FILE} CPACK_PACKAGE_DESCRIPTION)
execute_process(COMMAND git describe
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_TAG
ERROR_QUIET)
STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+"
CPACK_PACKAGE_VERSION "${GIT_TAG}")
if (CPACK_PACKAGE_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+")
message(STATUS "CPACK_PACKAGE_VERSION = ${CPACK_PACKAGE_VERSION} (from latest git tag on this branch)")
else()
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "23")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_PACKAGE_VERSION
"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
message(STATUS "CPACK_PACKAGE_VERSION = ${CPACK_PACKAGE_VERSION} (no git tag, using hardcoded values)")
endif (CPACK_PACKAGE_VERSION MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+")
add_definitions(-DBLAH_VERSION="${CPACK_PACKAGE_VERSION}")
execute_process(COMMAND git "show" "-s" "--format=%cd"
COMMAND cut "-d " "-f2,3,5"
OUTPUT_VARIABLE BLAH_BUILD_TIMESTAMP
RESULT_VARIABLE GIT_DATE_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
if (NOT GIT_DATE_ERROR)
message(STATUS "BLAH_BUILD_TIMESTAMP = ${BLAH_BUILD_TIMESTAMP} (from latest commit on this branch)")
else()
set(MONTH_LIST "Jan" "Feb" "Mar" "Apr" "May" "Jun"
"Jul" "Aug" "Sep" "Oct" "Nov" "Dec")
file(TIMESTAMP "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt"
BLAH_BUILD_MONTH "%m")
math(EXPR BLAH_BUILD_MONTH "${BLAH_BUILD_MONTH}-1")
list(GET MONTH_LIST ${BLAH_BUILD_MONTH} BLAH_BUILD_MONTH_TXT)
file(TIMESTAMP "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt"
BLAH_BUILD_TIMESTAMP "${BLAH_BUILD_MONTH_TXT} %d %Y")
message(STATUS "BLAH_BUILD_TIMESTAMP = ${BLAH_BUILD_TIMESTAMP} (no git date, using last CMakeLists.txt update)")
endif (NOT GIT_DATE_ERROR)
add_definitions(-DBLAH_BUILD_TIMESTAMP="${BLAH_BUILD_TIMESTAMP}")
# For the following setting, see CMAKE manual, page 155
# or http://public.kitware.com/Bug/view.php?id=7000
set(CPACK_SET_DESTDIR ON)
set(CPACK_PACKAGE_RELOCATABLE "false")
# Pre-definition of variables for the UseRPMTools spec template
set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
set(CPACK_RPM_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
set(CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
set(CPACK_RPM_PACKAGE_VENDOR ${CPACK_PACKAGE_VENDOR})
# Contruct two spec file templates: one for UseRPMTools and one for
# the CPack RPM module (that we hope we'll be able to actually use some day)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cpack_spec_template
COMMAND ${CMAKE_COMMAND}
-D OUTPUT=${CMAKE_CURRENT_BINARY_DIR}/cpack_spec_template
-D CUSTOM=${CMAKE_SOURCE_DIR}/project/cmake_spec_cpack_build
-D SCRIPLET_DIR=${CMAKE_SOURCE_DIR}/project
-P ${CMAKE_SOURCE_DIR}/create_spec_templates.cmake
DEPENDS
${CMAKE_SOURCE_DIR}/project/cmake_spec_prologue
${CMAKE_SOURCE_DIR}/project/cmake_spec_epilogue
${CMAKE_SOURCE_DIR}/project/cmake_spec_cpack_build)
execute_process(COMMAND ${CMAKE_COMMAND}
-D OUTPUT=${CMAKE_CURRENT_BINARY_DIR}/${CPACK_RPM_PACKAGE_NAME}.spec.in
-D CUSTOM=${CMAKE_SOURCE_DIR}/project/cmake_spec_userpmtools_build
-D SCRIPLET_DIR=${CMAKE_SOURCE_DIR}/project
-P ${CMAKE_SOURCE_DIR}/create_spec_templates.cmake)
add_custom_target(all_spec_files ALL DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/cpack_spec_template
${CMAKE_CURRENT_BINARY_DIR}/${CPACK_RPM_PACKAGE_NAME}.spec.in
)
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_RPM_PACKAGE_LICENSE "Apache Software License")
set(CPACK_RPM_PACKAGE_GROUP "Applications/Internet")
set(CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_SOURCE_DIR}/cpack_spec_template")
set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE
${CMAKE_SOURCE_DIR}/project/glite-ce-blahp.post)
set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE
${CMAKE_SOURCE_DIR}/project/glite-ce-blahp.preun)
set(CPACK_SOURCE_IGNORE_FILES
"Makefile;CMakeCache.txt;/RPM/;/autom4te.cache/;/CMakeFiles/;/build/;/\\\\.git/;/\\\\.deps/;\\\\.tar\\\\.gz$;\\\\.o$;\\\\.rpm$;\\\\.deb$;${CPACK_SOURCE_IGNORE_FILES}")
add_subdirectory(src)
add_subdirectory(config)
add_subdirectory(doc)
include(CPack)
include(UseRPMTools.cmake)
if(RPMTools_FOUND)
file(READ ${CPACK_RPM_POST_INSTALL_SCRIPT_FILE} CPACK_RPM_SPEC_POSTINSTALL)
file(READ ${CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE} CPACK_RPM_SPEC_PREUNINSTALL)
message(STATUS "DEBUG: spec file == ${CMAKE_CURRENT_BINARY_DIR}/${CPACK_RPM_PACKAGE_NAME}.spec.in")
RPMTools_ADD_RPM_TARGETS(${CPACK_RPM_PACKAGE_NAME}
"${CMAKE_CURRENT_BINARY_DIR}/${CPACK_RPM_PACKAGE_NAME}.spec.in")
unset(CPACK_RPM_SPEC_POSTINSTALL)
unset(CPACK_RPM_SPEC_PREUNINSTALL)
endif(RPMTools_FOUND)
install(FILES LICENSE
DESTINATION share/doc/${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION})