forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
243 lines (209 loc) · 8.25 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
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
# 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(CheckCompiler)
#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)
Check_Compiler()
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)
# Run macros unit tests automatically if ALIBUILD_O2_TESTS is defined
IF($ENV{ALIBUILD_O2_TESTS})
SET(CHECK_ROOTMACRO_COMPILE 1)
ENDIF()
# A LIST OF MACROS TO EXCLUDE FROM THE TEST
# To be used only in exceptional cases, such as when the macro
# uses symbols from outside the standard O2 build/runtime
# environment.
SET(IGNORE_MACROS
${CMAKE_SOURCE_DIR}/Generators/share/external/hijing.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
# End of temporarily disabled macros
)
# UNIT TESTS VERIFYING CONSISTENT STATE OF OUR ROOT MACROS AND THE EXECUTION ENVIRONMENT
if(CHECK_ROOTMACRO_COMPILE AND 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$")
SET(TEST_NO 0)
FOREACH(MACRO_FILE ${MACRO_FILES})
IF(NOT ${MACRO_FILE} IN_LIST IGNORE_MACROS)
string(REPLACE ${CMAKE_SOURCE_DIR} "" MACRO_FILE_LABEL ${MACRO_FILE})
MATH(EXPR TEST_NO "${TEST_NO} + 1")
ADD_TEST(NAME ${MACRO_FILE_LABEL}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND root -n -b -l -q -e ".L ${MACRO_FILE}"
)
SET_PROPERTY(TEST ${MACRO_FILE_LABEL} PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${CMAKE_BINARY_DIR}/lib")
SET_PROPERTY(TEST ${MACRO_FILE_LABEL} APPEND PROPERTY ENVIRONMENT "DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}:${CMAKE_BINARY_DIR}/lib")
SET_PROPERTY(TEST ${MACRO_FILE_LABEL} APPEND PROPERTY ENVIRONMENT "ROOT_HIST=0")
ELSE()
MESSAGE(STATUS "EXCLUDING ROOT MACRO ${MACRO_FILE} FROM CHECK")
ENDIF()
ENDFOREACH()
endif()