forked from IBM/CAST
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
213 lines (174 loc) · 6.87 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
206
207
208
209
210
211
212
213
cmake_minimum_required (VERSION 3.2.0)
project (ibm)
set(BUILDID_RELEASE 1)
set(BUILDID_CUMULFIXID 8)
set(BUILDID_EFIXID 2)
execute_process(
COMMAND git rev-list --count HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GITCOUNT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(BUILDID_SUFFIX "${GITCOUNT}")
set(VERSION "${BUILDID_RELEASE}.${BUILDID_CUMULFIXID}.${BUILDID_EFIXID}")
enable_testing()
include (scripts/setupMacros.cmake)
include (scripts/setupBoost.cmake)
include (CTest)
execute_process(
COMMAND git log -1 --format=%H
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE tmp_GITCOMMITID
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND date
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE tmp_BUILDTIME
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GITCOMMITIDSHORT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git log -1 --format=%cd
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE tmp_COMMITDATE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND rpm -qa
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE RPMLIST
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message("GIT commit: ${tmp_GITCOMMITID}")
message("Build time: ${tmp_BUILDTIME}")
if(tmp_GITCOMMITID STREQUAL "")
message("GIT commit could not be determined. Using current build time as commit ID")
set(GITCOMMITID ${tmp_BUILDTIME})
set(GITCOMMITDATE ${tmp_BUILDTIME})
else()
set(GITCOMMITID ${tmp_GITCOMMITID})
set(GITCOMMITDATE ${tmp_COMMITDATE})
endif()
set(BASEDIR ${CMAKE_SOURCE_DIR} CACHE FILEPATH "Base directory of source repository")
set(SETUPFILE "." CACHE FILEPATH "Path to the SETUP.sh environment setup script")
set(GENXCODE OFF CACHE BOOL "Generate an Xcode project")
set(GENECLIPSEPROJECT OFF CACHE BOOL "Generate an Eclipse project")
set(ALTINCLUDE "" CACHE FILEPATH "Path to alternate include directory")
set(VERBOSE_COMPILE OFF CACHE BOOL "Compile using compiler's verbose setting")
set(REMOTEIP "" CACHE STRING "IP address for remote ssh builds")
set(BUILD_PARALLEL OFF CACHE BOOL "Perform parallel build")
set(MINCMAKE "" CACHE STRING "Minimum cmake version permitted")
set(OPTLEVEL "-O0" CACHE STRING "Optimization level")
set(DCGM OFF CACHE BOOL "Build CSM with support for Nvidia Data Center GPU Manager (DCGM)")
set(SKIPCSM OFF CACHE BOOL "Skip CSM build")
################################
# Available toplevel directories
# The DISABLE_TOPLEVELS variable will trim from this list.
#
if(${SKIPCSM})
set(ALL_TOPLEVELS flightlog utilities transport bb fshipmond fshipd fshipcld export_layout bscfs)
else()
set(ALL_TOPLEVELS extras flightlog utilities transport bb fshipmond fshipd fshipcld csmutil csmnet csmconf scripts csmi csmdb csmd csmrestd csm_big_data export_layout hcdiag bscfs)
endif()
set(DISABLE_TOPLEVELS "none" CACHE STRING "Disabled toplevels")
message("Disabled toplevels: ${DISABLE_TOPLEVELS}")
message("Base source directory: ${CMAKE_SOURCE_DIR}")
set(CMAKE_BASE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
message("Base build directory: ${CMAKE_BASE_BINARY_DIR}")
string(REGEX REPLACE "[ ,]" ";" DOUT ${DISABLE_TOPLEVELS})
set(TOPLEVELS ${ALL_TOPLEVELS})
list(REMOVE_ITEM TOPLEVELS ${DOUT})
###################################
# Setup default compile options
#
set(CMAKE_C_FLAGS "-g -Wall -Werror -m64 -fPIC")
set(CMAKE_CXX_FLAGS "-g -Wall -Werror -m64 -fPIC -std=c++11")
if(RPMLIST MATCHES "boost-python3")
set(EXPLICIT_PYTHON_VERSION 1)
else()
set(EXPLICIT_PYTHON_VERSION 0)
endif()
message("System: ${CMAKE_SYSTEM}")
message("Explicit python version: ${EXPLICIT_PYTHON_VERSION}")
if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU" AND ${CMAKE_C_COMPILER_VERSION} VERSION_GREATER "7.0.0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=format-truncation= -Wno-error=format-overflow= -Wno-error=stringop-truncation")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=format-truncation= -Wno-error=format-overflow= -Wno-error=stringop-truncation")
endif()
set(CMAKE_C_FLAGS_DEBUG "")
set(CMAKE_CXX_FLAGS_DEBUG "")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${OPTLEVEL}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${OPTLEVEL}")
set(CMAKE_C_FLAGS_RELEASE "${OPTLEVEL}")
set(CMAKE_CXX_FLAGS_RELEASE "${OPTLEVEL}")
# keep symbols in rpmbuild step
if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
set(CPACK_RPM_SPEC_INSTALL_POST "/bin/true")
endif()
if(${CMAKE_BUILD_TYPE} MATCHES "RelWithDebInfo")
set(CPACK_RPM_SPEC_INSTALL_POST "/bin/true")
endif()
# Define __SOURCEROOT__
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__SOURCEROOT__='\"${CMAKE_SOURCE_DIR}\"'")
# Define __FILENAME__ which gets evaluated to the short file name ("main.cc") for each source file
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DOMPI_SKIP_MPICXX=1 -D__FILENAME__='\"$(<F)\"'")
if(${VERBOSE_COMPILE})
add_definitions(-v)
endif()
set(STRICT_WARN OFF CACHE BOOL "Enable strict warnings")
message("Option STRICT_WARN is ${STRICT_WARN}")
if(${STRICT_WARN})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra -W -Wunused -Wcomment -Wparentheses -Wconversion -Wsign-compare -Wsign-conversion -Wundef")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -W -Wunused -Wcomment -Wparentheses -Wconversion -Wsign-compare -Wsign-conversion -Wundef")
endif(${STRICT_WARN})
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "internal")
set(RPMBUILD OFF CACHE BOOL "Perform an RPM build")
message("Option RPMBUILD is ${RPMBUILD}")
if(${RPMBUILD})
set(CMAKE_INSTALL_PREFIX "/opt/ibm")
else(!${RPMBUILD})
set(CMAKE_INSTALL_PREFIX ${WORKDIR})
endif(${RPMBUILD})
set(CMAKE_INSTALL_MESSAGE LAZY)
include (scripts/setupRPATH.cmake)
include (scripts/setupClang.cmake)
##########################################################
# Add include paths relative to repository root/ directory
#
include_directories(${CMAKE_SOURCE_DIR})
#############################################################################
# Add include paths relative to repositoryroot/toplevel/include/ directories
#
foreach (LVL ${ALL_TOPLEVELS})
include_directories("${CMAKE_SOURCE_DIR}/${LVL}/include")
endforeach(LVL)
include_directories(${ALTINCLUDE})
##################################################################
# Add include paths relative to floor/subdir/include/ directories
#
if(${FLOOR})
getdirs(FLOORDIRS ${FLOOR})
foreach (LVL ${FLOORDIRS})
message("including files from floor directory: ${LVL}/include")
include_directories(${LVL}/include)
endforeach(LVL)
endif()
###################################
# Build all configured source code
foreach (LVL ${TOPLEVELS})
set(ADDTOPLEVEL ${LVL})
add_subdirectory(${LVL})
endforeach(LVL)
# csmd RPM packaging customization
include (csmd/setupRPM.cmake)
include (csm_big_data/setupRPM.cmake)
include (scripts/setupDoxygen.cmake)
include (scripts/setupTargets.cmake)
include (scripts/setupRPM.cmake)
file(GLOB config *.cfg csmconf/*.cfg)
install(FILES ${config} COMPONENT coral DESTINATION bin)