forked from FairRootGroup/FairRoot
-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
341 lines (280 loc) · 10.7 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
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
################################################################################
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
# #
# This software is distributed under the terms of the #
# GNU Lesser General Public Licence version 3 (LGPL) version 3, #
# copied verbatim in the file "LICENSE" #
################################################################################
# The name of our project is "FairBase". CMakeLists files in this project can
# refer to the root source directory of the project as ${FAIRROOT_SOURCE_DIR} or
# as ${CMAKE_SOURCE_DIR} and to the root binary directory of the project as
# ${FAIRROOT_BINARY_DIR} or ${CMAKE_BINARY_DIR}.
# This difference is is important for the base classes which are in FAIRROOT
# and PANDAROOT.
# Check if cmake has the required version
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.2 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
)
if(POLICY ${p})
cmake_policy(SET ${p} NEW)
endif()
endforeach()
# Set name of our project to "FAIRROOT". Has to be done
# after check of cmake version
project(FAIRROOT)
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/
# is checked
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/cuda" ${CMAKE_MODULE_PATH})
SET(VMCWORKDIR ${CMAKE_SOURCE_DIR}/examples)
# Check if the compiler support specific C++11 features
# Up to now this is only a check since the code does not use
# any of the features of the new standard
Set(CheckSrcDir "${CMAKE_SOURCE_DIR}/cmake/checks")
include(CheckCXX11Features)
# Load some basic macros which are needed later on
include(FairMacros)
include(WriteConfigFile)
include(Dart)
include(CheckCompiler)
#Check the compiler and set the compile and link flags
Check_Compiler()
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
Option(WITH_DBASE "Switch off the building of FairDB." OFF)
If(WITH_DBASE)
Add_Definitions(-DWITH_DBASE)
EndIf()
Option(USE_PATH_INFO "Information from PATH and LD_LIBRARY_PATH are used." OFF)
If(USE_PATH_INFO)
Set(PATH $ENV{PATH})
If (APPLE)
Set(LD_LIBRARY_PATH $ENV{DYLD_LIBRARY_PATH})
Else (APPLE)
Set(LD_LIBRARY_PATH $ENV{LD_LIBRARY_PATH})
EndIf (APPLE)
EndIf(USE_PATH_INFO)
# Check if the user wants to build the project in the source
# directory and if the install directory is different from the build
# directory
CHECK_OUT_OF_SOURCE_BUILD()
CHECK_INSTALL_DIRECTORY()
# 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 necessary environment variables are set
#If not stop execution unless modular build is activated
Option(FAIRROOT_MODULAR_BUILD "Modular build without environment variables" OFF)
IF(NOT FAIRROOT_MODULAR_BUILD)
IF(NOT DEFINED ENV{SIMPATH})
MESSAGE(FATAL_ERROR "You did not define the environment variable SIMPATH which is nedded to find the external packages. Please set this variable and execute cmake again.")
ENDIF(NOT DEFINED ENV{SIMPATH})
STRING(REGEX MATCHALL "[^:]+" PATH $ENV{PATH})
SET(SIMPATH $ENV{SIMPATH})
endif(NOT FAIRROOT_MODULAR_BUILD)
# Check if the external packages are installed into a separate install
# directory
CHECK_EXTERNAL_PACKAGE_INSTALL_DIR()
# searches for needed packages
# REQUIRED means that cmake will stop if this packages are not found
# For example the framework can run without GEANT4, but ROOT is
# mandatory
find_package(ROOT 5.32.00 REQUIRED)
find_package(Pythia6)
if(FAIRROOT_MODULAR_BUILD)
# Geant3, Geant4 installed via cmake
find_package(Geant3)
find_package(Geant4)
else(FAIRROOT_MODULAR_BUILD)
# For old versions of VMC packages (to be removed)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules_old" ${CMAKE_MODULE_PATH})
find_package(GEANT3)
find_package(GEANT4)
find_package(GEANT4DATA)
find_package(GEANT4VMC)
find_package(CLHEP)
find_package(GEANT4DATA)
find_package(GEANT4VMC)
find_package(CLHEP)
endif(FAIRROOT_MODULAR_BUILD)
find_package(CUDA)
find_package(IWYU)
find_package(ZeroMQ)
find_package(Protobuf)
find_package(DDS)
If(WITH_DBASE)
find_package(MYSQL)
find_package(PGSQL)
find_package(SQLITE)
EndIf(WITH_DBASE)
if(USE_NANOMSG)
find_package(nanomsg)
else(USE_NANOMSG)
set(NANOMSG_FOUND false) # lower case false value is needed for bash scripts
endif(USE_NANOMSG)
If(FAIRSOFT_EXTERN)
set(BOOST_ROOT ${SIMPATH})
set(GSL_DIR ${SIMPATH})
Else(FAIRSOFT_EXTERN)
set(BOOST_ROOT ${SIMPATH}/basics/boost)
set(GSL_DIR ${SIMPATH}/basics/gsl)
EndIf(FAIRSOFT_EXTERN)
Set(Boost_NO_SYSTEM_PATHS TRUE)
Set(Boost_NO_BOOST_CMAKE TRUE)
Message("-- Looking for Boost ...")
# If an older version of boost is found both of the variables below are
# cached and in a second cmake run, a good boost version is found even
# if the version is to old.
# To overcome this problem both variables are cleared before checking
# for boost.
Unset(Boost_INCLUDE_DIR CACHE)
Unset(Boost_LIBRARY_DIRS CACHE)
find_package(Boost 1.41 COMPONENTS thread system timer program_options random filesystem chrono exception regex)
If (Boost_FOUND)
Set(Boost_Avail 1)
Set(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${Boost_LIBRARY_DIR})
Else (Boost_FOUND)
Set(Boost_Avail 0)
EndIf (Boost_FOUND)
# Set the library version in the main CMakeLists.txt
SET(FAIRROOT_MAJOR_VERSION 15)
SET(FAIRROOT_MINOR_VERSION 11)
SET(FAIRROOT_PATCH_VERSION 0)
SET(FAIRROOT_VERSION "${FAIRROOT_MAJOR_VERSION}.${FAIRROOT_MINOR_VERSION}.${FAIRROOT_PATCH_VERSION}")
If(ROOT_FOUND_VERSION LESS 59999)
SET(FAIRROOT_LIBRARY_PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES}
VERSION "${FAIRROOT_VERSION}"
SOVERSION "${FAIRROOT_MAJOR_VERSION}"
SUFFIX ".so"
)
Else()
SET(FAIRROOT_LIBRARY_PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES}
VERSION "${FAIRROOT_VERSION}"
SOVERSION "${FAIRROOT_MAJOR_VERSION}"
)
SET(CMAKE_SHARED_LIBRARY_SUFFIX .so)
EndIf()
# Load the macro to generate the needed version info at compile time
Generate_Version_Info()
# Set some useful variables
SetBasicVariables()
# Check C++11 availability
If(NOT CMAKE_CXX_FLAGS)
Message(STATUS "No C++11 support found.")
Else()
String(FIND " ${CMAKE_CXX_FLAGS} " "-std=c++11" POS_C++11)
If(POS_C++11)
Message(STATUS "C++11 support found.")
Else()
Message(STATUS "No C++11 support found.")
EndIf()
EndIf()
# 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 (fairtools)
add_subdirectory (base)
If(WITH_DBASE)
add_subdirectory (dbase)
EndIf()
add_subdirectory (geobase)
add_subdirectory (parbase)
add_subdirectory (parmq)
add_subdirectory (generators)
If(GEANT3_FOUND)
add_subdirectory (geane)
add_subdirectory (trackbase)
add_subdirectory (eventdisplay)
EndIf ()
add_subdirectory (MbsAPI)
add_subdirectory (datamatch)
If (Boost_FOUND AND POS_C++11)
Message(STATUS "C++11 support & boost libraries found. FairMQ will be built.")
add_subdirectory (fairmq)
add_subdirectory (base/MQ)
Else ()
Message(STATUS "Building of the FairMQ library is switched off since C++11 or the necessary boost libraries couldn't be found on the system")
EndIf ()
Option(BUILD_DOXYGEN "Build Doxygen" OFF)
if(BUILD_DOXYGEN)
MESSAGE(STATUS "*** Building the Doxygen documentaion ***")
ADD_SUBDIRECTORY(doxygen)
endif(BUILD_DOXYGEN)
add_subdirectory (examples)
if(IWYU_FOUND)
ADD_CUSTOM_TARGET(checkHEADERS
DEPENDS $ENV{ALL_HEADER_RULES}
)
endif(IWYU_FOUND)
Option(BUILD_UNITTESTS "Build all unittests and add them as new tests" OFF)
If(BUILD_UNITTESTS)
Message("Build the unit tests.")
Set(GTEST_ROOT ${SIMPATH})
Find_Package(GTest)
If(GTEST_FOUND)
Message("Add tests library and tests.")
add_subdirectory(test)
EndIf(GTEST_FOUND)
EndIf(BUILD_UNITTESTS)
Install(DIRECTORY examples/common/gconfig examples/common/geometry
DESTINATION share/fairbase/examples/common
PATTERN ".svn" EXCLUDE)
Install(FILES ${CMAKE_BINARY_DIR}/config.sh_install
DESTINATION bin
RENAME FairRootConfig.sh
)
Install(FILES ${CMAKE_BINARY_DIR}/check_system.sh
DESTINATION bin
)
Install(FILES ${CMAKE_BINARY_DIR}/FairVersion.h
DESTINATION include
)
Install(FILES ${CMAKE_BINARY_DIR}/config.csh_install
DESTINATION bin
RENAME FairRootConfig.csh
)
Install(FILES ${CMAKE_BINARY_DIR}/check_system.csh
DESTINATION bin
)
Install(DIRECTORY cmake
DESTINATION share/fairbase
PATTERN ".svn" EXCLUDE)
Find_Package(Git)
If(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
Execute_Process(COMMAND ${GIT_EXECUTABLE} describe --tags
OUTPUT_VARIABLE FAIRROOT_GIT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
Else()
Set(FAIRROOT_GIT_VERSION v-15.03)
EndIf()
Configure_File(${CMAKE_SOURCE_DIR}/cmake/scripts/fairroot-config.in ${CMAKE_BINARY_DIR}/fairroot-config @ONLY)
Install(PROGRAMS ${CMAKE_BINARY_DIR}/fairroot-config
DESTINATION bin
)
if(NOT FAIRROOT_MINIMAL)
WRITE_CONFIG_FILE(config.sh)
WRITE_CONFIG_FILE(config.csh)
SET(VMCWORKDIR ${CMAKE_INSTALL_PREFIX}/share/fairbase/examples)
SET(ROOT_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/include)
WRITE_CONFIG_FILE(config.sh_install)
WRITE_CONFIG_FILE(config.csh_install)
# for lxplus, need to change LD_LIBRARY_PATH
execute_process(COMMAND lsb_release -is OUTPUT_VARIABLE distribution)
If(${distribution} MATCHES "ScientificCERNSLC")
MESSAGE("change to lcg environment")
file(APPEND ${CMAKE_BINARY_DIR}/config.csh "eval \"$(/cvmfs/sft.cern.ch/lcg/releases/lcgenv/latest/lcgenv -p /cvmfs/sft.cern.ch/lcg/releases/LCG_87 x86_64-slc6-gcc62-opt Python)\"\n")
file(APPEND ${CMAKE_BINARY_DIR}/config.sh "eval \"$(/cvmfs/sft.cern.ch/lcg/releases/lcgenv/latest/lcgenv -p /cvmfs/sft.cern.ch/lcg/releases/LCG_87 x86_64-slc6-gcc62-opt Python)\"\n")
EndIf()
file(APPEND ${CMAKE_BINARY_DIR}/config.csh "source ${SIMPATH}/bin/geant4.csh ${SIMPATH}/bin\n")
file(APPEND ${CMAKE_BINARY_DIR}/config.sh "source ${SIMPATH}/bin/geant4.sh \n")
else(NOT FAIRROOT_MINIMAL)
WRITE_MINIMAL_CONFIG_FILE(config.sh)
endif(NOT FAIRROOT_MINIMAL)