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