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