forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
179 lines (148 loc) · 5.95 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
# 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 2.8.11 FATAL_ERROR)
# Set name of our project to "ALICEO2". Has to be done
# after check of cmake version since this is a new feature
project(ALICEO2)
#In case you need Fortran
#ENABLE_LANGUAGE(Fortran)
# Check for needed environment variables
IF(NOT DEFINED ENV{FAIRROOTPATH})
MESSAGE(FATAL_ERROR "You did not define the environment variable FAIRROOTPATH which is needed to find FairRoot. Please set this variable and execute cmake again.")
ENDIF(NOT DEFINED ENV{FAIRROOTPATH})
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})
SET(SIMPATH $ENV{SIMPATH})
SET(FAIRROOTPATH $ENV{FAIRROOTPATH})
# 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 "${FAIRROOTPATH}/share/fairbase/cmake/modules" ${CMAKE_MODULE_PATH})
Set(CheckSrcDir "${FAIRROOTPATH}/share/fairbase/cmake/checks")
find_package(FairRoot)
# Load some basic macros which are needed later on
include(FairMacros)
include(WriteConfigFile)
include(CTest)
include(CheckCompiler)
#include(CheckFortran)
#Check the compiler and set the compile and link flags
If(NOT CMAKE_BUILD_TYPE)
Message("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()
# 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(Pythia8)
find_package(GENERATORS REQUIRED)
find_package(GEANT3 REQUIRED)
find_package(GEANT4)
find_package(GEANT4DATA)
find_package(GEANT4VMC)
find_package(CLHEP)
find_package(CERNLIB)
find_package(HEPMC)
Set(Boost_NO_SYSTEM_PATHS TRUE)
Set(Boost_NO_BOOST_CMAKE TRUE)
If(${ROOT_LIBRARY_DIR} MATCHES /lib/root)
set(BOOST_ROOT ${SIMPATH})
set(GSL_DIR ${SIMPATH})
Else(${ROOT_LIBRARY_DIR} MATCHES /lib/root)
set(BOOST_ROOT ${SIMPATH}/basics/boost)
set(GSL_DIR ${SIMPATH}/basics/gsl)
EndIf(${ROOT_LIBRARY_DIR} MATCHES /lib/root)
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)
If (Boost_FOUND)
Set(Boost_Avail 1)
Else (Boost_FOUND)
Set(Boost_Avail 0)
EndIf (Boost_FOUND)
# set a variable which should be used in all CMakeLists.txt
# Defines all basic include directories from fairbase
SetBasicVariables()
# Set the library version in the main CMakeLists.txt
SET(FAIRROOT_MAJOR_VERSION 0)
SET(FAIRROOT_MINOR_VERSION 0)
SET(FAIRROOT_PATCH_VERSION 0)
SET(FAIRROOT_VERSION "${FAIRROOT_MAJOR_VERSION}.${FAIRROOT_MINOR_VERSION}.${FAIRROOT_PATCH_VERSION}")
SET(FAIRROOT_LIBRARY_PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES}
VERSION "${FAIRROOT_VERSION}"
SOVERSION "${FAIRROOT_MAJOR_VERSION}"
SUFFIX ".so"
)
Generate_Version_Info()
SET(_LIBDIR ${CMAKE_BINARY_DIR}/lib)
SET(LD_LIBRARY_PATH ${_LIBDIR} ${LD_LIBRARY_PATH})
#install(DIRECTORY geometry DESTINATION pnd_install
# )
# 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
include(CheckCXX11Features)
# Check if the compilation flag -std=c++11 is set
If(NOT CMAKE_CXX_FLAGS)
Message(FATAL_ERROR "No C++11 support found. AliceO2 require C++11 be build.")
EndIF(NOT CMAKE_CXX_FLAGS)
# 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 (Base)
add_subdirectory (Data)
add_subdirectory (Generators)
add_subdirectory (its)
add_subdirectory (passive)
add_subdirectory (field)
add_subdirectory (devices)
Add_Subdirectory(macro)
WRITE_CONFIG_FILE(config.sh)
configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake
${CMAKE_BINARY_DIR}/CTestCustom.cmake
)
# Create an automatically generated config header file to pass file paths to the application
configure_file(${PROJECT_SOURCE_DIR}/header/AliceO2Config.h.in
${CMAKE_CURRENT_SOURCE_DIR}/header/AliceO2Config.h)