69450fb4c98ad9e7fbbcbe77a2dfc6864b3ac81f
[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 set(ALICE_ROOT $ENV{ALICE_ROOT})
15 set(ALICE $ENV{ALICE})
16
17 if(NOT ALICE)
18   message(WARNING "Environment variable ALICE is not set")
19 endif(NOT ALICE)
20
21 if(NOT ALICE_ROOT)
22   message(FATAL_ERROR "Please set ALICE_ROOT to the AliRoot source directory")
23 endif(NOT ALICE_ROOT)
24
25 # Set AliRoot Installation directory 
26 if(NOT ALICE_INSTALL)
27   message(STATUS "AliRoot files will be installed in ${ALICE_ROOT}. You can specify a different location by setting ALICE_INSTALL environment variable")
28   set(ALICE_INSTALL ${ALICE_ROOT})
29 else()
30   message(STATUS "AliRoot files will be installed in ${ALICE_INSTALL}")
31 endif(NOT ALICE_INSTALL)
32
33 set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
34
35 include(ALICE_CMake)
36
37 #--------------------------------------------------------------------------------#
38 # Find Packages                                                                  #
39 #--------------------------------------------------------------------------------#
40
41 # Subversion
42 # ------------------------------
43
44 find_package(Subversion REQUIRED)
45
46 # ROOT
47 # ------------------------------
48
49 find_package(ROOT REQUIRED)
50
51 # IRST Rule Checker 
52 # ------------------------------
53
54 find_package(RuleChecker)
55
56 # DATE
57 # ------------------------------ 
58
59 find_package(DATE)
60
61 # GEANT3
62 # ------------------------------
63
64 find_package(GEANT3)
65
66 # AMORE
67 # ------------------------------
68
69 find_package(AMORE)
70
71 #--------------------------------------------------------------------------------#
72 # Environment/Compiler Configuration                                             #
73 #--------------------------------------------------------------------------------#
74
75 ALICE_CheckOutOfSourceBuild()
76 ALICE_RootConfig(CMAKE_CXX_COMPILER --cxx)
77 ALICE_RootConfig(CMAKE_C_COMPILER --cc)
78 ALICE_RootConfig(CMAKE_Fortran_COMPILER --f77)
79 ALICE_ConfigurePlatform()
80 ALICE_ConfigureCompiler()
81
82
83 #--------------------------------------------------------------------------------#
84 # AliRoot Path Settings                                                          #
85 #--------------------------------------------------------------------------------#
86
87 ALICE_DevFlagsOutput()
88 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/tgt_${ALICE_TARGET}")
89 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/tgt_${ALICE_TARGET}")
90 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/tgt_${ALICE_TARGET}")
91 set(CMAKE_INCLUDE_EXPORT_DIRECTORY "${PROJECT_BINARY_DIR}/include")
92 file(MAKE_DIRECTORY ${CMAKE_INCLUDE_EXPORT_DIRECTORY})
93 set(EXPORTDIRS "${ALICE_INSTALL}/include")
94 set(BINLIBDIRS "-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
95
96 #--------------------------------------------------------------------------------#
97 # AliRoot Modules                                                                #
98 #--------------------------------------------------------------------------------#
99
100 # Exclude Module from all target
101 # ------------------------------
102
103 #set(EXCLUDEMODULES THydjet SHUTTLE)
104
105 # Standard Modules
106 # ------------------------------
107 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 )
108
109 if(THydjet)
110   list(APPEND ALIROOTMODULES THydjet)
111 endif(THydjet)
112
113 if(SHUTTLE)
114   list(APPEND ALIROOTMODULES SHUTTLE)
115 endif(SHUTTLE)
116
117 # Additional Modules
118 # ------------------------------
119 list(APPEND ALIROOTMODULES TUHKMgen EPOS)
120
121 # EVE
122 # ------------------------------
123 ALICE_RootConfig(EVE --has-opengl)
124 if(NOT EVE STREQUAL "no")
125   list(APPEND ALIROOTMODULES EVE)
126 endif(NOT EVE STREQUAL "no")
127
128 # CERN Modules
129 # ------------------------------
130 set(CERNMODULES LHAPDF HIJING MICROCERN HERWIG)
131
132 # Check for Pythia 6
133 if(EXISTS ${ROOTINCDIR}/TPythia6.h)
134   set(PYTHIA6 TRUE)
135   list(APPEND CERNMODULES PYTHIA6 RALICE EVGEN)
136 else()
137   message(FATAL_ERROR "ROOT must have Pythia6 enabled !")
138 endif(EXISTS ${ROOTINCDIR}/TPythia6.h)
139
140 # Set Final list of modules 
141 set(MODULES ${ALIROOTMODULES} ${CERNMODULES} ALIROOT)
142
143 # Set Module directories
144 set(MODDIRS ${MODULES})
145
146 # Libraries for Linking
147 # ------------------------------
148 set(ALILIBS MUON TPC PMD TRD FMD TOF ITS PHOS ACORDE HMPID VZERO ZDC STRUCT T0 EVGEN STEER TRIGGER)
149 set(LIBS ${ROOTCLIBS} ${ROOTPLIBS} ${SYSLIBS})
150
151 # Configure ARVerion.h
152 # ------------------------------
153 if(Subversion_FOUND)
154   Subversion_WC_INFO(${PROJECT_SOURCE_DIR} PROJECT)
155   set(ALIROOT_SVN_REVISION ${PROJECT_WC_REVISION})
156   set(ALIROOT_SVN_BRANCH ${PROJECT_WC_URL})
157   string(REGEX MATCH "[^/]+$" ALIROOT_SVN_BRANCH ${ALIROOT_SVN_BRANCH})
158   message(STATUS "Aliroot Revision - ${ALIROOT_SVN_REVISION} Branch - ${ALIROOT_SVN_BRANCH}")
159   if(EXISTS ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
160     file(REMOVE ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
161   endif(EXISTS ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
162   configure_file(${PROJECT_SOURCE_DIR}/cmake/ARVersion.h.tmp ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h @ONLY)
163 endif(Subversion_FOUND)
164
165 #--------------------------------------------------------------------------------#
166 # Build Modules                                                                  #
167 #--------------------------------------------------------------------------------#
168
169 # Module Variables
170 # ------------------------------
171 set(ALLLIBS)
172 set(ALLEXECS)
173 set(INCLUDEFILES)
174 set(BINLIBS)
175 set(EXPORTFILES)
176
177 # Top Level Build Targets
178 # ------------------------------
179
180 add_custom_target(alilibs-static)
181 add_custom_target(include-headers)
182 add_custom_target(DA-all)
183
184
185 # Add Modules
186 # ------------------------------
187 foreach(MODULE ${MODDIRS})
188   set(${MODULE}ALIBS)
189   configure_file(${PROJECT_SOURCE_DIR}/cmake/Module.tmp ${PROJECT_SOURCE_DIR}/${MODULE}/CMakeLists.txt @ONLY)
190   add_custom_target(${MODULE}-all ALL)
191   add_custom_target(${MODULE}-all-static)
192   add_dependencies(alilibs-static "${MODULE}-static")
193   add_subdirectory(${MODULE})
194 endforeach(MODULE)
195
196 if(DATE_FOUND AND AMORE_FOUND)
197   include (CMakeDA)
198 endif(DATE_FOUND AND AMORE_FOUND)
199
200 #--------------------------------------------------------------------------------#
201 # Additional Targets                                                             #
202 #--------------------------------------------------------------------------------#
203
204 # AliMdc RPM
205 # ------------------------------
206
207
208 include (InstallRequiredSystemLibraries)
209 include (CPack)
210