forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
317 lines (269 loc) · 11.7 KB
/
CMakeLists.txt
File metadata and controls
317 lines (269 loc) · 11.7 KB
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
# The name of our project is "ALICEO2". CMakeLists files in this project can
# refer to the root source directory of the project as ${ALICEO2_SOURCE_DIR}
# or as ${CMAKE_SOURCE_DIR} and to the root binary directory of the project as
# ${ALICEO2_BINARY_DIR} or ${CMAKE_BINARY_DIR}.
# This difference is important for the base classes which are in FAIRROOT
# and the experiment part.
# Check IF cmake has the required version
CMAKE_MINIMUM_REQUIRED(VERSION 3.11.0 FATAL_ERROR)
### CMP0025 Compiler id for Apple Clang is now AppleClang.
### CMP0042 MACOSX_RPATH is enabled by default.
FOREACH (p
CMP0025 # CMake 3.0
CMP0042 # CMake 3.0
CMP0028
CMP0068
CMP0057
)
IF (POLICY ${p})
cmake_policy(SET ${p} NEW)
ENDIF ()
endforeach ()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) # project specific cmake dir
# Set name of our project to "ALICEO2". Has to be done
# after check of cmake version since this is a new feature
project(ALICEO2)
# Toplevel targets
ADD_CUSTOM_TARGET(man ALL)
#In case you need Fortran
#ENABLE_LANGUAGE(Fortran)
find_package(Boost REQUIRED)
# Load some basic macros which are needed later on
include(O2Utils)
include(O2Dependencies)
include(FairMacros)
include(WriteConfigFile)
include(CTest)
#include(CheckFortran)
# check if we have a simulation environment
if (Geant3_FOUND AND Geant4_FOUND AND Geant4VMC_FOUND AND Pythia6_FOUND AND PYTHIA8_FOUND)
SET (HAVESIMULATION 1)
message(STATUS "Simulation environment found")
else()
message(STATUS "Simulation environment not found : at least one of the variables Geant3_FOUND , Geant4_FOUND , Geant4VMC_FOUND , Pythia6_FOUND or PYTHIA8_FOUND is not set")
message(STATUS "All of them are needed for a simulation environment.")
message(STATUS "That might not be a problem if you don't care about simulation though.")
message(STATUS "Geant3_FOUND = ${Geant3_FOUND}")
message(STATUS "Geant4_FOUND = ${Geant4_FOUND}")
message(STATUS "Geant4VMC_FOUND = ${Geant4VMC_FOUND}")
message(STATUS "Pythia6_FOUND=${Pythia6_FOUND}")
message(STATUS "PYTHIA8_FOUND=${PYTHIA8_FOUND}")
message(FATAL "stop")
endif()
# Build type for coverage builds
set(CMAKE_CXX_FLAGS_COVERAGE "-g -O2 -fprofile-arcs -ftest-coverage")
set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE}")
set(CMAKE_Fortran_FLAGS_COVERAGE "-g -O2 -fprofile-arcs -ftest-coverage")
set(CMAKE_LINK_FLAGS_COVERAGE "--coverage -fprofile-arcs -fPIC")
MARK_AS_ADVANCED(
CMAKE_CXX_FLAGS_COVERAGE
CMAKE_C_FLAGS_COVERAGE
CMAKE_Fortran_FLAGS_COVERAGE
CMAKE_LINK_FLAGS_COVERAGE)
#Check the compiler and set the compile and link flags
IF (NOT CMAKE_BUILD_TYPE)
Message(STATUS "Set BuildType DEBUG")
set(CMAKE_BUILD_TYPE Debug)
ENDIF (NOT CMAKE_BUILD_TYPE)
IF(ENABLE_CASSERT) #For the CI, we want to have <cassert> assertions enabled
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
ELSE()
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG")
ENDIF()
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(CMAKE_Fortran_FLAGS_RELEASE "-O2")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-O2 -g")
# make sure Debug build not optimized (does not seem to work without CACHE + FORCE)
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0" CACHE STRING "Debug mode build flags" FORCE)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "Debug mode build flags" FORCE)
set(CMAKE_Fortran_FLAGS_DEBUG "-g -O0" CACHE STRING "Debug mode build flags" FORCE)
message(STATUS "Using build type: ${CMAKE_BUILD_TYPE} - CXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}")
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
set(INCLUDE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/include")
Set(VMCWORKDIR ${CMAKE_SOURCE_DIR})
Option(USE_PATH_INFO "Information from PATH and LD_LIBRARY_PATH are used." OFF)
IF (USE_PATH_INFO)
Set(PATH "$PATH")
IF (APPLE)
Set(LD_LIBRARY_PATH $ENV{DYLD_LIBRARY_PATH})
ELSE (APPLE)
Set(LD_LIBRARY_PATH $ENV{LD_LIBRARY_PATH})
ENDIF (APPLE)
ELSE (USE_PATH_INFO)
STRING(REGEX MATCHALL "[^:]+" PATH "$ENV{PATH}")
ENDIF (USE_PATH_INFO)
# Check IF the user wants to build the project in the source
# directory
CHECK_OUT_OF_SOURCE_BUILD()
# Check IF we are on an UNIX system. IF not stop with an error
# message
IF (NOT UNIX)
MESSAGE(FATAL_ERROR "You're not on an UNIX system. The project was up to now only tested on UNIX systems, so we break here. IF you want to go on please edit the CMakeLists.txt in the source directory.")
ENDIF (NOT UNIX)
# Check IF the external packages are installed into a separate install
# directory
CHECK_EXTERNAL_PACKAGE_INSTALL_DIR()
# Set the library version in the main CMakeLists.txt
SET(ALICEO2_MAJOR_VERSION 0)
SET(ALICEO2_MINOR_VERSION 0)
SET(ALICEO2_PATCH_VERSION 0)
SET(ALICEO2_VERSION "${ALICEO2_MAJOR_VERSION}.${ALICEO2_MINOR_VERSION}.${ALICEO2_PATCH_VERSION}")
IF (NOT ROOT_FOUND_VERSION OR ROOT_FOUND_VERSION LESS 59999)
SET(FAIRROOT_LIBRARY_PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES}
VERSION "${ALICEO2_VERSION}"
SOVERSION "${ALICEO2_MAJOR_VERSION}"
SUFFIX ".so"
)
ELSE ()
SET(FAIRROOT_LIBRARY_PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES}
VERSION "${ALICEO2_VERSION}"
SOVERSION "${ALICEO2_MAJOR_VERSION}"
)
ENDIF ()
Generate_Version_Info()
# Our libraries will be under "lib"
SET(_LIBDIR ${CMAKE_BINARY_DIR}/lib)
SET(LD_LIBRARY_PATH ${_LIBDIR} ${LD_LIBRARY_PATH})
# Build targets with install rpath on Mac to dramatically speed up installation
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_INSTALL_RPATH "@loader_path/../lib")
endif()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
endif()
unset(isSystemDir)
# Check for the required C++ standard features (break if not available)
set(CheckCXX14SrcDir "${CMAKE_SOURCE_DIR}/cmake/checks")
include(CheckCXX14Features)
# Recurse into the given subdirectories. This does not actually
# cause another cmake executable to run. The same process will walk through
# the project's entire directory structure.
add_subdirectory(Generators)
set(GENERATORS_LIBRARY Generators)
add_subdirectory(CCDB)
add_subdirectory(Common)
add_subdirectory(DataFormats)
add_subdirectory(Detectors)
add_subdirectory(EventVisualisation)
SET(BUILD_EXAMPLES FALSE CACHE BOOL "Build examples")
if (BUILD_EXAMPLES)
add_subdirectory(Examples)
endif()
add_subdirectory(Framework)
add_subdirectory(Algorithm)
add_subdirectory(macro)
add_subdirectory(Utilities)
add_subdirectory(Steer)
add_subdirectory(doc)
if (HAVESIMULATION)
add_subdirectory(run)
endif()
add_subdirectory(config)
IF (IWYU_FOUND)
ADD_CUSTOM_TARGET(checkHEADERS
DEPENDS $ENV{ALL_HEADER_RULES}
)
ENDIF ()
SET(VMCWORKDIR ${CMAKE_SOURCE_DIR})
SET(VMCWORKDIR ${CMAKE_INSTALL_PREFIX}/share)
SET(ROOT_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/include)
# Place the CTestCustom.cmake in the build dir
configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake
${CMAKE_BINARY_DIR}/CTestCustom.cmake
)
O2_GENERATE_MAN(NAME o2)
O2_GENERATE_MAN(NAME FairMQDevice)
# Macros from this list will be excluded from tests. To be used only in exceptional cases, such as
# when the macro uses symbols from outside the standard O2 build/runtime environment
set(EXCLUDE_MACROS_FROM_TEST
${CMAKE_SOURCE_DIR}/Generators/share/external/hijing.C
${CMAKE_SOURCE_DIR}/Detectors/ITSMFT/ITS/macros/EVE/rootlogon.C
# Temporarily disable the following macros: ROOT v6-14-04 fails to parse
# correctly some Boost headers
${CMAKE_SOURCE_DIR}/CCDB/example/fill_local_ocdb.C
${CMAKE_SOURCE_DIR}/macro/loadExtDepLib.C
${CMAKE_SOURCE_DIR}/macro/putCondition.C
# Disabled until AliTPCCommon is merged
${CMAKE_SOURCE_DIR}/macro/run_test_vert_ca_its.C
${CMAKE_SOURCE_DIR}/macro/run_trac_ca_its.C
${CMAKE_SOURCE_DIR}/macro/run_rec_ca.C
# Disabled from @mconcas: will be removed soon in any case
${CMAKE_SOURCE_DIR}/macro/run_vert_ca_its.C
# This macro is used by the o2sim tests, no need to re-check. Parallel tests
# of the same macro are also breaking it
${CMAKE_SOURCE_DIR}/DataFormats/simulation/test/checkStack.C
)
# Macros from this list will have the test in compiled mode ran in a non-fatal way
set(EXCLUDE_MACROS_FROM_COMPILED_TEST
${CMAKE_SOURCE_DIR}/Detectors/TPC/calibration/macro/comparePedestalsAndNoise.C
${CMAKE_SOURCE_DIR}/Detectors/TPC/calibration/macro/drawNoiseAndPedestal.C
${CMAKE_SOURCE_DIR}/Detectors/TPC/monitor/macro/RunCompareMode3.C
${CMAKE_SOURCE_DIR}/Detectors/TPC/monitor/macro/RunFindAdcError.C
${CMAKE_SOURCE_DIR}/Detectors/TPC/reconstruction/macro/dEdxRes.C
${CMAKE_SOURCE_DIR}/Detectors/TPC/reconstruction/macro/readClusters.C
${CMAKE_SOURCE_DIR}/Detectors/TPC/reconstruction/macro/testTracks.C
${CMAKE_SOURCE_DIR}/Detectors/TPC/simulation/macro/readMCtruth.C
${CMAKE_SOURCE_DIR}/macro/convertClusterToClusterHardware.C
${CMAKE_SOURCE_DIR}/macro/run_clus_tpc.C
)
# UNIT TESTS VERIFYING CONSISTENT STATE OF OUR ROOT MACROS AND THE EXECUTION ENVIRONMENT
if(HAVESIMULATION)
# On Mac OS GLOB_RECURSE returns both .C and .c files, i.e. case insensitive
file(GLOB_RECURSE MACRO_FILES "*.C")
# Case sensitive filtering of .C files
list(FILTER MACRO_FILES INCLUDE REGEX "^.*\\.C$")
foreach(MACRO_FILE ${MACRO_FILES})
if(NOT ${MACRO_FILE} IN_LIST EXCLUDE_MACROS_FROM_TEST)
string(REPLACE ${CMAKE_SOURCE_DIR} "" MACRO_FILE_LABEL ${MACRO_FILE})
# Test for "interpreted" macros
add_test_wrap(NAME ${MACRO_FILE_LABEL}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND root -n -b -l -q -e ".L ${MACRO_FILE}")
# Test for compiled macros
if(${MACRO_FILE} IN_LIST EXCLUDE_MACROS_FROM_COMPILED_TEST)
set(_MACRO_NON_FATAL "NON_FATAL")
message(WARNING "Compiled macro test for ${MACRO_FILE} will be non-fatal")
else()
set(_MACRO_NON_FATAL "")
endif()
add_test_wrap(NAME ${MACRO_FILE_LABEL}_compiled
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
${_MACRO_NON_FATAL}
COMMAND root -n -b -l -q -e ".L ${MACRO_FILE}++")
# Set environment variables
foreach(_TEST_NAME "${MACRO_FILE_LABEL}" "${MACRO_FILE_LABEL}_compiled")
set_property(TEST ${_TEST_NAME} PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${CMAKE_BINARY_DIR}/lib")
if(APPLE)
set_property(TEST ${_TEST_NAME} APPEND PROPERTY ENVIRONMENT "DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}:${CMAKE_BINARY_DIR}/lib")
endif()
set_property(TEST ${_TEST_NAME} APPEND PROPERTY ENVIRONMENT "ROOT_HIST=0")
endforeach()
# Cleanup
unset(_TEST_NAME)
unset(_MACRO_NON_FATAL)
else()
message(WARNING "ROOT macro ${MACRO_FILE} excluded from tests")
endif()
endforeach()
endif()
# Create special .rootrc for testing compiled macros
configure_file("${CMAKE_SOURCE_DIR}/cmake/tests.rootrc.in"
"${CMAKE_BINARY_DIR}/.rootrc"
@ONLY
NEWLINE_STYLE UNIX)
# Create tests wrapper (and make it executable)
configure_file("${CMAKE_SOURCE_DIR}/cmake/tests-wrapper.sh.in"
"${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/tests-wrapper.sh"
@ONLY
NEWLINE_STYLE UNIX)
file(COPY "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/tests-wrapper.sh"
DESTINATION "${CMAKE_BINARY_DIR}"
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)