Fixed striong (Svein)
[u/mrichter/AliRoot.git] / CMakeLists.txt
1 # Top level CMakeList.txt file for the AliRoot Build System
2 #
3 # Author: Johny Jose (johny.jose@cern.ch)
4 #         Port of previous Makefile build to cmake
5
6
7 cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
8
9 #--------------------------------------------------------------------------------#
10 # Set Basic CMake Configuration                                                  #
11 #--------------------------------------------------------------------------------#
12
13 project(AliRoot CXX C Fortran)
14
15 # Environment variables
16 set(ALICE_ROOT $ENV{ALICE_ROOT})
17 set(ALICE $ENV{ALICE})
18 set(ALICE_INSTALL $ENV{ALICE_INSTALL})
19
20 if(NOT ALICE)
21   message(WARNING "Environment variable ALICE is not set")
22 endif(NOT ALICE)
23
24 if(NOT ALICE_ROOT)
25   message(FATAL_ERROR "Please set ALICE_ROOT to the AliRoot source directory")
26 endif(NOT ALICE_ROOT)
27
28 # Set AliRoot Installation directory 
29 if(NOT ALICE_INSTALL)
30   message(STATUS "AliRoot files will be installed in ${ALICE_ROOT}. You can specify a different location by setting ALICE_INSTALL environment variable")
31   set(ALICE_INSTALL ${ALICE_ROOT})
32 else()
33   message(STATUS "AliRoot files will be installed in ${ALICE_INSTALL}")
34 endif(NOT ALICE_INSTALL)
35 set(CMAKE_INSTALL_PREFIX ${ALICE_INSTALL})
36
37 get_filename_component(PROJECT_SOURCE_DIR "${PROJECT_SOURCE_DIR}" REALPATH)
38 set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
39 set(CPACK_COMPONENTS_ALL MDC)
40
41 include(ALICE_CMake)
42
43 #--------------------------------------------------------------------------------#
44 # Find Packages                                                                  #
45 #--------------------------------------------------------------------------------#
46
47 # Subversion
48 # ------------------------------
49
50 find_package(Subversion REQUIRED)
51
52 # ROOT
53 # ------------------------------
54
55 find_package(ROOT REQUIRED)
56
57 # IRST Rule Checker 
58 # ------------------------------
59
60 find_package(RuleChecker)
61
62 # DATE
63 # ------------------------------ 
64
65 find_package(DATE)
66
67 # GEANT3
68 # ------------------------------
69
70 find_package(GEANT3)
71
72 # AMORE
73 # ------------------------------
74
75 find_package(AMORE)
76
77 # AliRoot CPack configuration                                                    
78 #-------------------------------
79
80 find_package(CPack)
81
82
83 #--------------------------------------------------------------------------------#
84 # Environment/Compiler Configuration                                             #
85 #--------------------------------------------------------------------------------#
86
87 ALICE_CheckOutOfSourceBuild()
88 ALICE_RootConfig(CMAKE_CXX_COMPILER --cxx)
89 ALICE_RootConfig(CMAKE_C_COMPILER --cc)
90 ALICE_RootConfig(CMAKE_Fortran_COMPILER --f77)
91 ALICE_ConfigurePlatform()
92 ALICE_ConfigureCompiler()
93
94
95 #--------------------------------------------------------------------------------#
96 # AliRoot Path Settings                                                          #
97 #--------------------------------------------------------------------------------#
98
99 ALICE_DevFlagsOutput()
100 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/tgt_${ALICE_TARGET}")
101 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/tgt_${ALICE_TARGET}")
102 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/tgt_${ALICE_TARGET}")
103 set(CMAKE_INCLUDE_EXPORT_DIRECTORY "${PROJECT_BINARY_DIR}/include")
104 file(MAKE_DIRECTORY ${CMAKE_INCLUDE_EXPORT_DIRECTORY})
105 set(EXPORTDIRS "${ALICE_INSTALL}/include")
106 set(BINLIBDIRS "-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
107
108
109 #--------------------------------------------------------------------------------#
110 # AliRoot Modules                                                                #
111 #--------------------------------------------------------------------------------#
112
113 # Exclude Module from all target
114 # ------------------------------
115
116 #set(EXCLUDEMODULES THydjet SHUTTLE)
117
118
119 # Standard Modules
120 # ------------------------------
121 set(ALIROOTMODULES STEER PHOS TRD TPC ZDC MUON PMD FMD TOF ITS ACORDE HMPID T0 BCM STRUCT VZERO THijing THbtp EMCAL THerwig TEPEMGEN FASTSIM TPHIC RAW MONITOR ANALYSIS JETAN HLT LHC ESDCheck STAT TTherminator CORRFW DPMJET TDPMjet PWG0 PWG1 PWG2 PWG3 PWG4 TRIGGER PYTHIA8 TAmpt OADB )
122
123 if(THydjet)
124   list(APPEND ALIROOTMODULES THydjet)
125 endif(THydjet)
126
127 if(SHUTTLE)
128   list(APPEND ALIROOTMODULES SHUTTLE)
129 endif(SHUTTLE)
130
131 # Additional Modules
132 # ------------------------------
133 list(APPEND ALIROOTMODULES TUHKMgen EPOS)
134
135 # EVE
136 # ------------------------------
137 ALICE_RootConfig(EVE --has-opengl)
138 if(NOT EVE STREQUAL "no")
139   list(APPEND ALIROOTMODULES EVE)
140 endif(NOT EVE STREQUAL "no")
141
142 # CERN Modules
143 # ------------------------------
144 set(CERNMODULES LHAPDF HIJING MICROCERN HERWIG)
145
146 # Check for Pythia 6
147 if(EXISTS ${ROOTINCDIR}/TPythia6.h)
148   set(PYTHIA6 TRUE)
149   list(APPEND CERNMODULES PYTHIA6 RALICE EVGEN)
150 elseif(NOT NOPYTHIA)
151   message(FATAL_ERROR "ROOT must have Pythia6 enabled !")
152 endif(EXISTS ${ROOTINCDIR}/TPythia6.h)
153
154 # Set Final list of modules 
155 set(MODULES ${ALIROOTMODULES} ${CERNMODULES} ALIROOT)
156
157 # Set Module directories
158 set(MODDIRS ${MODULES})
159
160 # Libraries for Linking
161 # ------------------------------
162 set(ALILIBS MUON TPC PMD TRD FMD TOF ITS PHOS ACORDE HMPID VZERO ZDC STRUCT T0 EVGEN STEER TRIGGER)
163 set(LIBS ${ROOTCLIBS} ${ROOTPLIBS} ${SYSLIBS})
164
165 # Configure ARVerion.h
166 # ------------------------------
167 if(Subversion_FOUND)
168   if(EXISTS ${PROJECT_SOURCE_DIR}/.svn/ )
169   Subversion_WC_INFO(${PROJECT_SOURCE_DIR} PROJECT)
170   set(ALIROOT_SVN_REVISION ${PROJECT_WC_REVISION})
171   set(ALIROOT_SVN_BRANCH ${PROJECT_WC_URL})
172   string(REGEX MATCH "[^/]+$" ALIROOT_SVN_BRANCH ${ALIROOT_SVN_BRANCH})
173
174   elseif(EXISTS ${PROJECT_SOURCE_DIR}/.git/ )
175     execute_process(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} COMMAND git svn info OUTPUT_VARIABLE OUTPUTVAR)
176     string(REPLACE "\n" ";" OUTPUTVAR ${OUTPUTVAR})
177     foreach(f ${OUTPUTVAR})
178       if(${f} MATCHES URL)
179         string(REGEX MATCH "[^/]+$" ALIROOT_SVN_BRANCH ${f})
180       elseif(${f} MATCHES Revision)
181         string(REGEX MATCH "[^: ]+$" ALIROOT_SVN_REVISION ${f})
182       endif(${f} MATCHES URL)   
183     endforeach()
184   endif(EXISTS ${PROJECT_SOURCE_DIR}/.svn/ )
185
186   message(STATUS "Aliroot Revision - ${ALIROOT_SVN_REVISION} Branch - ${ALIROOT_SVN_BRANCH}")
187   if(EXISTS ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
188     file(REMOVE ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
189   endif(EXISTS ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
190   configure_file(${PROJECT_SOURCE_DIR}/cmake/ARVersion.h.tmp ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h @ONLY)
191 endif(Subversion_FOUND)
192
193 #--------------------------------------------------------------------------------#
194 # Build Modules                                                                  #
195 #--------------------------------------------------------------------------------#
196
197 # Module Variables
198 # ------------------------------
199 set(ALLLIBS)
200 set(ALLEXECS)
201 set(INCLUDEFILES)
202 set(BINLIBS)
203 set(EXPORTFILES)
204
205 # Top Level Build Targets
206 # ------------------------------
207
208 add_custom_target(alilibs-static)
209 add_custom_target(include-headers)
210 add_custom_target(DA-all)
211 add_custom_target(check-all)
212 add_custom_target(par-all)
213 add_custom_target(test-par-all)
214
215 # Add Modules
216 # ------------------------------
217 foreach(MODULE ${MODDIRS})
218   set(${MODULE}ALIBS)
219   configure_file(${PROJECT_SOURCE_DIR}/cmake/Module.tmp ${PROJECT_SOURCE_DIR}/${MODULE}/CMakeLists.txt @ONLY)
220   add_custom_target(${MODULE}-all ALL)
221   add_custom_target(${MODULE}-check-all)
222   add_custom_target(${MODULE}-par-all)
223   add_custom_target(test-${MODULE}-par-all)
224   add_dependencies(check-all "${MODULE}-check-all")
225   add_custom_target(${MODULE}-all-static)
226   add_dependencies(alilibs-static "${MODULE}-static")
227   add_subdirectory(${MODULE})
228 endforeach(MODULE)
229
230 if(DATE_FOUND AND AMORE_FOUND)
231   include (CMakeDA)
232 endif(DATE_FOUND AND AMORE_FOUND)
233
234 #--------------------------------------------------------------------------------#
235 # Additional Targets                                                             #
236 #--------------------------------------------------------------------------------#
237
238 # AliMdc RPM
239 # ------------------------------
240
241 include (InstallRequiredSystemLibraries)
242 include (CPack)
243