Fixes for sub-project submissions. Subprojects can now be submitted by running the...
[u/mrichter/AliRoot.git] / CMakeLists.txt
1 # -*- mode: cmake -*-
2
3 # Check if cmake has the required version
4 cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
5
6 # Set name of our project to AliRoot. To be done after check of cmake version
7 project(AliRoot NONE)
8
9 # Set AliRoot variables
10 set(CMAKE_VERBOSE_MAKEFILES OFF)
11 #fix for MACOSX
12 SET(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem")
13 SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem") 
14
15 set(ALICE_INSTALL $ENV{ALICE_INSTALL})
16 set(ALICE_ROOT $ENV{ALICE_ROOT})
17 set(ALICE_STATIC_BUILD OFF CACHE BOOL "Build also statics libs")
18 execute_process(COMMAND root-config --arch OUTPUT_VARIABLE ALICE_TARGET)
19 string (REGEX REPLACE "\n" "" ALICE_TARGET ${ALICE_TARGET})
20
21 if(NOT ALICE_INSTALL)
22 message(FATAL_ERROR "Please set environment variable ALICE_INSTALL to the AliRoot installation directory")
23 endif(NOT ALICE_INSTALL)
24 if(NOT ALICE_ROOT)
25 message(FATAL_ERROR "Please set environment variable ALICE_ROOT to the AliRoot source directory")
26 endif(NOT ALICE_ROOT)
27
28
29 message("ALICE_ROOT: ${ALICE_ROOT}")
30
31
32 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ 
33 set(PROJECT_BINARY_DIR ${ALICE_INSTALL})
34 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin/tgt_${ALICE_TARGET})
35 set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib/tgt_${ALICE_TARGET})
36 set(CMAKE_MODULE_PATH "${ALICE_ROOT}/cmake/modules")
37
38 # To fix a hack that has been introduced for the Mac
39 if(APPLE)
40   set(CMAKE_INSTALL_NAME_TOOL CMAKE_INSTALL_NAME_TOOL-NOTFOUND)
41 endif(APPLE)
42
43 # Setup ROOT and C, C++ , Fortran Compilers
44 find_package(ROOT 5.0.0 REQUIRED)
45 set(CMAKE_C_COMPILER $ENV{CC})
46 enable_language(C)
47 set(CMAKE_CXX_COMPILER $ENV{CXX})
48 enable_language(CXX)
49 set(CMAKE_Fortran_COMPILER $ENV{F77})
50 enable_language(Fortran)
51
52 # Load some basic macros which are needed later on
53 #Include(WriteConfigFile)
54
55 include (CTest)
56 include(ALICEMacros)
57
58 # Check if the user wants to build the project in the source directory
59 Check_out_of_Source_Build()
60
61 # searches for needed packages
62
63 Set(ALIROOT_INSTALL_DIR ${ALICE_INSTALL}/${ALICE_TARGET})
64
65 # Setup GEANT3
66 find_package(GEANT3)
67
68 # Setup RuleChecker
69 find_package(RuleChecker)
70
71 # Check if DATE is installed
72 find_package(DATE)
73
74 # Setup system dependent flags 
75 SetupSystem()
76
77 Include(CreateSubCMakeFiles)
78 CreateSubCMakeFiles()
79
80
81 # Set the library version in the main CMakeLists.txt
82
83 set(ALIROOT_MAJOR_VERSION 0)
84 set(ALIROOT_MINOR_VERSION 0)
85 set(ALIROOT_PATCH_VERSION 0)
86 set(ALIROOT_VERSION "${ALIROOT_MAJOR_VERSION}.${ALIROOT_MINOR_VERSION}.${ALIROOT_PATCH_VERSION}")
87
88 set(ALIROOT_LIBRARY_PROPERTIES ${ALIROOT_LIBRARY_PROPERTIES}
89     VERSION "${ALIROOT_VERSION}"
90     SOVERSION "${ALIROOT_MAJOR_VERSION}"
91     SUFFIX ".so"
92 )
93
94 # Set version variables
95 find_program( READLINK_PROGRAM readlink)
96
97 if(READLINK_PROGRAM) 
98   execute_process(COMMAND readlink -f ${ALICE_ROOT} 
99     COMMAND xargs svn info
100     OUTPUT_VARIABLE _svn_out)
101 else(READLINK_PROGRAM)
102   execute_process(COMMAND svn info ${ALICE_ROOT} 
103     OUTPUT_VARIABLE _svn_out)
104 endif(READLINK_PROGRAM)
105
106 string(REGEX REPLACE "^.*Revision: ([^\n]*).*$" "\\1" 
107   ALIROOT_SVN_REVISION ${_svn_out})
108 string(REGEX REPLACE "^.*URL: ([^\n]*).*$" "\\1"
109   ALIROOT_SVN_BRANCH ${_svn_out})
110 string(REGEX REPLACE "^.*AliRoot/([^\n]*)" "\\1" ALIROOT_SVN_BRANCH ${ALIROOT_SVN_BRANCH})
111
112
113 # Additional targets
114 add_custom_target(check-all COMMENT "Checking coding conventions")
115 message(STATUS "REVISION: ${ALIROOT_SVN_REVISION}")
116 message(STATUS "BRANCH: ${ALIROOT_SVN_BRANCH}")
117
118 # Delete and recreate header ARVersion Header file 
119 execute_process(COMMAND cmake -E remove "${CMAKE_CURRENT_BINARY_DIR}/STEER/ARVersion.h")
120 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/STEER/ARVersion.h.in ${CMAKE_CURRENT_BINARY_DIR}/STEER/ARVersion.h @ONLY)
121
122 # Get list of enabled root features
123 execute_process(COMMAND root-config --features OUTPUT_VARIABLE FEATURES)
124 string(REGEX MATCH "pythia6" PYTHIA6 ${FEATURES})
125 string(REGEX MATCH "pythia8" PYTHIA8 ${FEATURES})
126 string(REGEX MATCH "opengl" OPENGL ${FEATURES})
127 if(PYTHIA6)
128   message(STATUS "Pythia6 enabled")
129 endif(PYTHIA6)
130 if(PYTHIA8)
131   message(STATUS "Pythia8 enabled")
132 endif(PYTHIA8)
133 if(OPENGL)
134   message(STATUS "OpenGL enabled")      
135 endif(OPENGL)   
136 option (TFLUKA "Build TFluka" OFF)
137 option (THYDJET "Build THydjet" OFF)
138 option (SHUTTLE "Build SHUTTLE" OFF)
139
140
141 add_custom_target(STEER-all)
142 add_custom_target(PHOS-all)     
143 add_custom_target(TRD-all) 
144 add_custom_target(TPC-all)
145 add_custom_target(ZDC-all) 
146 add_custom_target(MUON-all) 
147 add_custom_target(PMD-all) 
148 add_custom_target(FMD-all)
149 add_custom_target(TOF-all) 
150 add_custom_target(ITS-all) 
151 add_custom_target(ACORDE-all) 
152 add_custom_target(HMPID-all) 
153 add_custom_target(T0-all) 
154 add_custom_target(BCM-all) 
155 add_custom_target(STRUCT-all) 
156 add_custom_target(EVGEN-all) 
157 add_custom_target(RALICE-all) 
158 add_custom_target(VZERO-all) 
159 add_custom_target(THijing-all)
160 add_custom_target(THbtp-all) 
161 add_custom_target(EMCAL-all) 
162 add_custom_target(THerwig-all) 
163 add_custom_target(TEPEMGEN-all) 
164 add_custom_target(FASTSIM-all) 
165 add_custom_target(TPHIC-all) 
166 add_custom_target(RAW-all) 
167 add_custom_target(MONITOR-all) 
168 add_custom_target(ANALYSIS-all) 
169 add_custom_target(JETAN-all)
170 add_custom_target(HLT-all) 
171 add_custom_target(LHC-all) 
172 add_custom_target(ESDCheck-all) 
173 add_custom_target(STAT-all) 
174 add_custom_target(TTherminator-all) 
175 add_custom_target(CORRFW-all) 
176 add_custom_target(DPMJET-all) 
177 add_custom_target(TDPMjet-all) 
178 add_custom_target(PWG0-all) 
179 add_custom_target(PWG1-all) 
180 add_custom_target(PWG2-all) 
181 add_custom_target(PWG3-all) 
182 add_custom_target(PWG4-all)
183 add_custom_target(TRIGGER-all) 
184 add_custom_target(TUHKMgen-all) 
185 add_custom_target(EPOS-all) 
186 add_custom_target(PYTHIA8-all) 
187 add_custom_target(EVE-all) 
188 add_custom_target(TFluka-all)
189 add_custom_target(THydjet-all)
190 add_custom_target(SHUTTLE-all)
191 add_custom_target(LHAPDF-all) 
192 add_custom_target(HIJING-all) 
193 add_custom_target(MICROCERN-all) 
194 add_custom_target(HERWIG-all) 
195 add_custom_target(PYTHIA6-all)
196 add_custom_target(ALIROOT-all)
197
198
199
200 # Recurse into the given subdirectories.  This does not actually
201 # cause another cmake executable to run.  The same process will walk through
202 # the project's entire directory structure.
203 Add_subdirectory(STEER)
204 Add_subdirectory(PHOS) 
205 Add_subdirectory(TRD) 
206 Add_subdirectory(TPC)
207 Add_subdirectory(ZDC) 
208 Add_subdirectory(MUON) 
209 Add_subdirectory(PMD) 
210 Add_subdirectory(FMD)
211 Add_subdirectory(TOF) 
212 Add_subdirectory(ITS) 
213 Add_subdirectory(ACORDE) 
214 Add_subdirectory(HMPID) 
215 Add_subdirectory(T0) 
216 Add_subdirectory(BCM) 
217 Add_subdirectory(STRUCT) 
218 Add_subdirectory(EVGEN) 
219 Add_subdirectory(RALICE) 
220 Add_subdirectory(VZERO) 
221 Add_subdirectory(THijing)
222 Add_subdirectory(THbtp) 
223 Add_subdirectory(EMCAL) 
224 Add_subdirectory(THerwig) 
225 Add_subdirectory(TEPEMGEN) 
226 Add_subdirectory(FASTSIM) 
227 Add_subdirectory(TPHIC) 
228 Add_subdirectory(RAW) 
229 Add_subdirectory(MONITOR) 
230 Add_subdirectory(ANALYSIS) 
231 Add_subdirectory(JETAN)
232 Add_subdirectory(HLT) 
233 Add_subdirectory(LHC) 
234 Add_subdirectory(ESDCheck) 
235 Add_subdirectory(STAT) 
236 Add_subdirectory(TTherminator) 
237 Add_subdirectory(CORRFW) 
238 Add_subdirectory(DPMJET) 
239 Add_subdirectory(TDPMjet) 
240 Add_subdirectory(PWG0) 
241 Add_subdirectory(PWG1) 
242 Add_subdirectory(PWG2) 
243 Add_subdirectory(PWG3) 
244 Add_subdirectory(PWG4)
245 Add_subdirectory(TRIGGER) 
246 Add_subdirectory(TUHKMgen) 
247 Add_subdirectory(EPOS) 
248 if(PYTHIA8)
249 Add_subdirectory(PYTHIA8) 
250 endif(PYTHIA8)
251 if(OPENGL)
252 Add_subdirectory(EVE) 
253 endif(OPENGL)
254 if(TFLUKA)
255 Add_subdirectory(TFluka)
256 endif(TFLUKA)
257 if(THYDJET)     
258 Add_subdirectory(THydjet)
259 endif(THYDJET)
260 if(SHUTTLE)
261 Add_subdirectory(SHUTTLE)
262 endif(SHUTTLE)  
263 Add_subdirectory(LHAPDF) 
264 Add_subdirectory(HIJING) 
265 Add_subdirectory(MICROCERN) 
266 Add_subdirectory(HERWIG) 
267 if(PYTHIA6)
268 Add_subdirectory(PYTHIA6)
269 endif(PYTHIA6)
270 Add_subdirectory(ALIROOT)
271 add_subdirectory(test)
272 add_test ("Aliroot_executable" aliroot -q) 
273 #copy testing files
274 configure_file("CTestCustom.ctest" "${PROJECT_BINARY_DIRECTORY}" COPYONLY)