Completely reengineered version of CMake build system (Johny)
[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 "${ALICE_ROOT}/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 THydjet PYTHIA8)
108
109 # Additional Modules
110 # ------------------------------
111 list(APPEND ALIROOTMODULES TUHKMgen EPOS)
112
113 # EVE
114 # ------------------------------
115 ALICE_RootConfig(EVE --has-opengl)
116 if(NOT EVE STREQUAL "no")
117   list(APPEND ALIROOTMODULES EVE)
118 endif(NOT EVE STREQUAL "no")
119
120 # CERN Modules
121 # ------------------------------
122 set(CERNMODULES LHAPDF HIJING MICROCERN HERWIG)
123
124 # Check for Pythia 6
125 if(EXISTS ${ROOTINCDIR}/TPythia6.h)
126   set(PYTHIA6 TRUE)
127   list(APPEND CERNMODULES PYTHIA6 RALICE EVGEN)
128 else()
129   message(FATAL_ERROR "Pythia6 is required !")
130 endif(EXISTS ${ROOTINCDIR}/TPythia6.h)
131
132 # Set Final list of modules 
133 set(MODULES ${ALIROOTMODULES} ${CERNMODULES} ALIROOT)
134
135 # Set Module directories
136 set(MODDIRS ${MODULES})
137
138 # Libraries for Linking
139 # ------------------------------
140 set(ALILIBS MUON TPC PMD TRD FMD TOF ITS PHOS ACORDE HMPID VZERO ZDC STRUCT T0 EVGEN STEER TRIGGER)
141 set(LIBS ${ROOTCLIBS} ${ROOTPLIBS} ${SYSLIBS})
142
143 # Configure ARVerion.h
144 # ------------------------------
145 if(Subversion_FOUND)
146   Subversion_WC_INFO(${PROJECT_SOURCE_DIR} PROJECT)
147   set(ALIROOT_SVN_REVISION ${PROJECT_WC_REVISION})
148   set(ALIROOT_SVN_BRANCH ${PROJECT_WC_URL})
149   string(REGEX MATCH "[^/]+$" ALIROOT_SVN_BRANCH ${ALIROOT_SVN_BRANCH})
150   message(STATUS "Aliroot Revision - ${ALIROOT_SVN_REVISION} Branch - ${ALIROOT_SVN_BRANCH}")
151   if(EXISTS ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
152     file(REMOVE ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
153   endif(EXISTS ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
154   configure_file(${PROJECT_SOURCE_DIR}/cmake/ARVersion.h.tmp ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h @ONLY)
155 endif(Subversion_FOUND)
156
157 #--------------------------------------------------------------------------------#
158 # Build Modules                                                                  #
159 #--------------------------------------------------------------------------------#
160
161 # Module Variables
162 # ------------------------------
163 set(ALLLIBS)
164 set(ALLEXECS)
165 set(INCLUDEFILES)
166 set(BINLIBS)
167 set(EXPORTFILES)
168
169 # Top Level Build Targets
170 # ------------------------------
171
172 add_custom_target(alilibs-static)
173 add_custom_target(include-headers)
174
175 # Add Modules
176 # ------------------------------
177 foreach(MODULE ${MODDIRS})
178   configure_file(${PROJECT_SOURCE_DIR}/cmake/Module.tmp ${PROJECT_SOURCE_DIR}/${MODULE}/CMakeLists.txt @ONLY)
179   add_custom_target(${MODULE}-all ALL)
180   add_custom_target(${MODULE}-static)
181   add_dependencies(alilibs-static "${MODULE}-static")
182   add_subdirectory(${MODULE})
183
184 endforeach(MODULE)
185
186 if(DATE_FOUND AND AMORE_FOUND)
187   include (CMakeDA)
188 endif(DATE_FOUND AND AMORE_FOUND)
189
190 #--------------------------------------------------------------------------------#
191 # Additional Targets                                                             #
192 #--------------------------------------------------------------------------------#
193
194 include (InstallRequiredSystemLibraries)
195 include (CPack)
196