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