-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
206 lines (163 loc) · 7.4 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
project (hpccsystems-nagios-monitoring)
cmake_minimum_required (VERSION 2.8.11)
set (HPCC_NM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
MESSAGE ("************ Setting CMAKE_MODULE_PATH to ${HPCC_NM_SOURCE_DIR}/cmake_modules/")
set (CMAKE_MODULE_PATH "${HPCC_NM_SOURCE_DIR}/cmake_modules/")
MESSAGE ("CMAKE_MODULE_PATH is set to ${CMAKE_MODULE_PATH}")
###
## Build Level
###
if( NOT BUILD_LEVEL )
set ( BUILD_LEVEL "COMMUNITY" )
endif()
###
option(EXEC_PREFIX "Set the execution prefix")
if (NOT LICENSE_FILE)
set (LICENSE_FILE "LICENSE.txt")
endif()
MESSAGE ( "CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}" )
set (HPCC_SOURCE_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
IF ("${HPCC_SOURCE_DIR}" STREQUAL "")
SET (HPCC_SOURCE_DIR ${HPCC_SOURCE_ROOT_DIR}/HPCC-Platform)
ENDIF()
#MESSAGE ( "32 - CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}" )
include (${HPCC_NM_SOURCE_DIR}/version.cmake)
include (${HPCC_SOURCE_DIR}/version.cmake)
include (${HPCC_NM_SOURCE_DIR}/cmake_modules/optionDefaults.cmake)
include (${HPCC_NM_SOURCE_DIR}/cmake_modules/nmCommonSetup.cmake)
include (${HPCC_SOURCE_DIR}/version.cmake)
#MESSAGE ( "40 - CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}" )
MESSAGE ( "CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}" )
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti -fPIC -fmessage-length=0 -Wformat -Wformat-security -Wformat-nonliteral -pthread -Wuninitialized")
MESSAGE("*** START BUILDING HPCC PLATFORM ***")
MESSAGE (HPCC_SOURCE_DIR: ${HPCC_SOURCE_DIR})
ADD_SUBDIRECTORY(${HPCC_SOURCE_DIR} oss EXCLUDE_FROM_ALL)
INCLUDE(${HPCC_NM_SOURCE_DIR}/platform-version-prereq.cmake)
###
## Run file configuration to set build tag along with install lines for generated
## config files.
###
set( BUILD_TAG "${projname}_${version}-${stagever}")
if (USE_GIT_DESCRIBE OR CHECK_GIT_TAG)
FETCH_GIT_TAG (${CMAKE_SOURCE_DIR} ${projname}_${version} GIT_BUILD_TAG)
message ("-- Git tag is '${GIT_BUILD_TAG}'")
if (NOT "${GIT_BUILD_TAG}" STREQUAL "${BUILD_TAG}")
if (CHECK_GIT_TAG)
message(FATAL_ERROR "Git tag '${GIT_BUILD_TAG}' does not match source version '${BUILD_TAG}'" )
else()
if(NOT "${GIT_BUILD_TAG}" STREQUAL "") # probably means being built from a tarball...
set( BUILD_TAG "${BUILD_TAG}[${GIT_BUILD_TAG}]")
endif()
endif()
endif()
endif()
message ("-- Build tag is '${BUILD_TAG}'")
if (NOT "${BASE_BUILD_TAG}" STREQUAL "")
set(BASE_BUILD_TAG "${BUILD_TAG}")
endif()
message ("-- Base build tag is '${BASE_BUILD_TAG}'")
CONFIGURE_FILE(${HPCC_SOURCE_DIR}/build-config.h.cmake "build-config.h" )
MESSAGE("*** END BUILDING HPCC PLATFORM ***")
MESSAGE ( "CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}" )
HPCC_ADD_SUBDIRECTORY( hpcc-nagios-tools )
HPCC_ADD_SUBDIRECTORY( utils )
HPCC_ADD_SUBDIRECTORY( config )
HPCC_ADD_SUBDIRECTORY( commands )
MESSAGE (HPCC_SOURCE_DIR: ${HPCC_SOURCE_DIR})
#ADD_SUBDIRECTORY(${HPCC_SOURCE_DIR} oss EXCLUDE_FROM_ALL)
SET (VER_SEPARATOR "-")
IF ("${stagever}" MATCHES "^rc[0-9]-$")
SET (VER_SEPARATOR "~")
ENDIF ()
SET(CPACK_PACKAGE_VERSION_MAJOR ${majorver})
SET(CPACK_PACKAGE_VERSION_MINOR ${minorver})
SET(CPACK_PACKAGE_VERSION_PATCH ${point}${VER_SEPARATOR}${stagever})
set (CPACK_PACKAGE_CONTACT "HPCCSystems <[email protected]>")
set (CPACK_SOURCE_GENERATOR TGZ )
set (CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CPACK_RPM_PACKAGE_ARCHITECTURE}")
set (CPACK_RPM_PACKAGE_VERSION "${version}" )
set (CPACK_RPM_PACKAGE_RELEASE "${stagever}")
# Fix filesystem conflict error, This fix requires cmake 3+
SET(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/etc/nagios;/etc/nagios/conf.d;/etc/nrpe.d;/usr/lib64/nagios" )
MESSAGE ( "CPACK_RPM_PACKAGE_ARCHITECTURE ${CPACK_RPM_PACKAGE_ARCHITECTURE}" )
MESSAGE ( "CPACK_SYSTEM_NAME ${CPACK_SYSTEM_NAME}" )
MESSAGE ( "CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}" )
MESSAGE ( "${CMAKE_MODULE_PATH}/distrocheck.sh" )
MESSAGE ( "HPCC_NM_SOURCE_DIR ${HPCC_NM_SOURCE_DIR}" )
IF ( CMAKE_SYSTEM_NAME MATCHES Linux )
EXECUTE_PROCESS (
COMMAND ${CMAKE_MODULE_PATH}/distrocheck.sh
OUTPUT_VARIABLE packageManagement
ERROR_VARIABLE packageManagement
)
EXECUTE_PROCESS (
COMMAND ${CMAKE_MODULE_PATH}/getpackagerevisionarch.sh
OUTPUT_VARIABLE packageRevisionArch
ERROR_VARIABLE packageRevisionArch
)
EXECUTE_PROCESS (
COMMAND ${CMAKE_MODULE_PATH}/getpackagerevisionarch.sh --noarch
OUTPUT_VARIABLE packageRevision
ERROR_VARIABLE packageRevision
)
MESSAGE ( "-- Auto Detecting Packaging type")
MESSAGE ( "-- distro uses ${packageManagement}, revision is ${packageRevisionArch}" )
IF ( ${packageManagement} STREQUAL "DEB" )
SET(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${version}-${stagever}${packageRevisionArch}")
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /usr/lib)
ELSEIF ( ${packageManagement} STREQUAL "RPM" )
SET(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${version}-${stagever}.${packageRevisionArch}")
SET(CMAKE_LIBRARY_PATH "/usr/lib64")
ELSE()
SET(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${version}-${stagever}${CPACK_SYSTEM_NAME}")
ENDIF ()
ENDIF ( CMAKE_SYSTEM_NAME MATCHES Linux )
get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
if ("${LIB64}" STREQUAL "TRUE")
set(LIBSUFFIX 64)
else()
set(LIBSUFFIX "")
endif()
set(INSTALL_LIB_DIR lib${LIBSUFFIX} CACHE PATH "Installation directory for libraries")
mark_as_advanced(INSTALL_LIB_DIR)
get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
SET ( CPACK_SOURCE_GENERATOR TGZ )
IF (NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.2")
IF ( CMAKE_SYSTEM MATCHES Linux )
IF ( ${packageManagement} STREQUAL "DEB" )
IF ("${CMAKE_VERSION}" VERSION_EQUAL "2.8.2")
MESSAGE("WARNING: CMAKE 2.8.2 would not build DEB package")
ELSE ()
SET ( CPACK_GENERATOR "${packageManagement}" )
MESSAGE("-- Will build DEB package")
###
## CPack instruction required for Debian
###
MESSAGE ("-- Packing BASH installation files")
ENDIF ()
ELSEIF ( ${packageManagement} STREQUAL "RPM" )
SET ( CPACK_GENERATOR "${packageManagement}" )
###
## CPack instruction required for RPM
###
MESSAGE("-- Will build RPM package")
MESSAGE ("-- Packing BASH installation files")
ELSE()
MESSAGE("WARNING: Unsupported package ${packageManagement}.")
ENDIF ()
ENDIF ( CMAKE_SYSTEM MATCHES Linux )
IF ( EXISTS ${CMAKE_MODULE_PATH}/dependencies/${packageRevision}.cmake.in )
CONFIGURE_FILE(${HPCC_NM_SOURCE_DIR}/cmake_modules/dependencies/${packageRevision}.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/dependencies/${packageRevision}.cmake)
INCLUDE( ${CMAKE_CURRENT_BINARY_DIR}/dependencies/${packageRevision}.cmake )
ELSE()
MESSAGE("-- WARNING: DEPENDENCY FILE FOR ${packageRevision} NOT FOUND")
ENDIF()
IF ( UNIX )
SET ( CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" )
ENDIF()
SET ( CPACK_MONOLITHIC_INSTALL TRUE )
SET ( CPACK_PACKAGE_VENDOR "HPCC Systems" )
INCLUDE ( CPack )
ELSE()
MESSAGE("WARNING: CMAKE 2.8.1 or later required to create RPMs from this project")
ENDIF()