]> git.uio.no Git - u/mrichter/AliRoot.git/blame - CMakeLists.txt
Update master to aliroot
[u/mrichter/AliRoot.git] / CMakeLists.txt
CommitLineData
d50827fc 1# **************************************************************************
2# * Copyright(c) 1998-2014, ALICE Experiment at CERN, All rights reserved. *
3# * *
4# * Author: The ALICE Off-line Project. *
5# * Contributors are mentioned in the code where appropriate. *
6# * *
7# * Permission to use, copy, modify and distribute this software and its *
8# * documentation strictly for non-commercial purposes is hereby granted *
9# * without fee, provided that the above copyright notice appears in all *
10# * copies and that both the copyright notice and this permission notice *
11# * appear in the supporting documentation. The authors make no claims *
12# * about the suitability of this software for any purpose. It is *
13# * provided "as is" without express or implied warranty. *
14# **************************************************************************
15
16#--------------------------------------------------------------------------#
17# Set Basic CMake Configuration #
18#--------------------------------------------------------------------------#
e969a926 19
139cbc46 20cmake_minimum_required(VERSION 2.8.11 FATAL_ERROR)
e969a926 21
ce89cc9e 22### CMP0025 Compiler id for Apple Clang is now AppleClang.
23### CMP0042 MACOSX_RPATH is enabled by default.
24
25foreach(p
26 CMP0025 # CMake 3.0
27 CMP0042 # CMake 3.0
28 )
29 if(POLICY ${p})
30 cmake_policy(SET ${p} NEW)
31 endif()
32endforeach()
33
d50827fc 34project(AliRoot CXX C)
bf4c2121 35
04484146 36message(STATUS "CMake platform: ${CMAKE_SYSTEM}")
37message(STATUS "Build folder: ${AliRoot_BINARY_DIR}")
38message(STATUS "Source folder: ${AliRoot_SOURCE_DIR}")
39message(STATUS "Installation folder: ${CMAKE_INSTALL_PREFIX}")
34ab4e08 40
ac6fcf94 41# CMake supports different build types by default. We want the DEBUG build type
42# to have "-g -O0" flags: by default it only has "-g"
43set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
44set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
45
46# You can change the build type using
34ab4e08 47# cmake -DCMAKE_BUILD_TYPE=DEBUG | RELEASE | RELWITHDEBINFO | MINSIZEREL ...
48if (NOT CMAKE_BUILD_TYPE)
49 set(CMAKE_BUILD_TYPE RELWITHDEBINFO)
50endif(NOT CMAKE_BUILD_TYPE)
ac6fcf94 51message(STATUS "Build type: ${CMAKE_BUILD_TYPE} (${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}})")
04484146 52
53if(CMAKE_INSTALL_PREFIX STREQUAL "${AliRoot_SOURCE_DIR}")
16ae4e81 54 message(FATAL_ERROR "Please choose a different installation point than the source tree!")
04484146 55endif()
56
d50827fc 57# Path to additonal modules
c2f9135f 58set(CMAKE_MODULE_PATH "${AliRoot_SOURCE_DIR}/cmake")
59
60# AliRoot version extracted from Git repository
61# Sets 4 git variables
62# - GIT_REFSPEC - complete name of the current reference
63# - ALIROOT_BRANCH - name of the branch or tag extracted from the current reference
64# - GIT_SHA1 - current hash in the long format
65# - GIT_SHORT_SHA1 - current hash in the short format
66# - ALIROOT_VERSION = ALIROOT_BRANCH
67# - ALIROOT_REVISION = GIT_SHORT_SHA1
68include(CheckGitVersion)
b22a7396 69
16ae4e81 70# - CLANG_MAJOR.CLANG_MINOR or
71# - GCC_MAJOR.GCC_MINOR.GCC_PATCH
b22a7396 72include(CheckCompiler)
73
b24da1d3 74# Utility to generate PARfiles
75include(cmake/GenParFile.cmake)
76
34ab4e08 77# Shared library suffix
0e5d2ccd 78if (NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
34ab4e08 79 set(CMAKE_SHARED_LIBRARY_SUFFIX .so)
0e5d2ccd 80endif (NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
c4faffc2 81
16ae4e81 82# Optional: Doxygen for reference doc generation
83find_package(Doxygen)
84if(DOXYGEN_FOUND AND DOXYGEN_DOT_FOUND)
85 message(STATUS "Doxygen ${DOXYGEN_VERSION} and Graphviz found: ${DOXYGEN_EXECUTABLE}, ${DOXYGEN_DOT_EXECUTABLE}")
86 set(CAN_GENERATE_DOC TRUE)
87elseif(DOXYGEN_ONLY)
88 message(FATAL_ERROR "Doxygen and Graphviz not found. Cannot generate documentation")
89else()
90 message(STATUS "Doxygen and Graphviz not found. Disabling support for documentation generation")
91endif()
92
93# Doxygen documentation is always included
94add_subdirectory(doxygen)
f82bfa66 95
16ae4e81 96if(DEFINED DOXYGEN_ONLY AND DOXYGEN_ONLY)
97 # In this case we do not prepare targets for the rest, but for Doxygen only.
98 # This is useful because no checks are performed, and it means that Doxygen
99 # documentation can be generated on a relatively "dumb" server that has as
100 # requirements only cmake, doxygen and graphviz.
101 message(WARNING "Preparing build for Doxygen documentation only as requested. AliRoot will not be built!")
102else()
103
104 # Standard CMake inclusions and checks if we are actually building AliRoot,
105 # i.e. not only the documentation
106
107 # Checking first for DIM, DATE, AMORE and daqDA
108 # in case ROOT Extra static library needs to be enabled
109
110 # DATE
111 # date-config needs DIMDIR and ODIR set
112 # Setting variables in cache to be accesible by ccmake
113 set(DATE_CONFIG CACHE STRING "date-config script location")
2dc0b2a8 114 set(DIMDIR CACHE STRING "dim installation folder")
16ae4e81 115 set(ODIR CACHE STRING "dim plaform, usually \"linux\"")
47b6091d 116
117 if(DIMDIR AND ODIR)
118 find_package(DIM)
119 endif()
120
1c5dc89d 121 if(DATE_CONFIG)
122 if(DIM_FOUND)
123 find_package(DATE)
124 else()
125 message(FATAL_ERROR "DATE enabled but no DIMDIR and ODIR set. Please set DIMDIR and ODIR")
126 endif()
16ae4e81 127 endif()
f82bfa66 128
16ae4e81 129 # daqDA
130 # Setting variables in cache to be accesible by ccmake
131 set(daqDA CACHE STRING "daqDA library folder installation")
132 if(daqDA)
f82bfa66 133 find_package(daqDA)
16ae4e81 134 endif(daqDA)
f82bfa66 135
1c5dc89d 136 # AMORE -> requires ROOT to be installed
16ae4e81 137 # Setting variables in cache to be accesible by ccmake
138 set(AMORE_CONFIG CACHE STRING "amore-config script location")
139 if(AMORE_CONFIG)
ec8c8ea6 140 if(ROOTSYS)
16ae4e81 141 find_package(AMORE)
ec8c8ea6 142 else()
16ae4e81 143 message(FATAL_ERROR "AMORE enabled but no ROOTSYS defined")
ec8c8ea6 144 endif()
16ae4e81 145 endif(AMORE_CONFIG)
f82bfa66 146
16ae4e81 147 # id DARPM we enable DA if it is not set
148 # Setting variables in cache to be accesible by ccmake
149 set(DARPM CACHE STRING "Enable DARPM: ON")
150 set(DA CACHE STRING "Enable DA: ON")
151 if(DARPM)
168930f9 152 if(NOT DA)
16ae4e81 153 set(DA ON)
168930f9 154 endif(NOT DA)
16ae4e81 155 endif(DARPM)
168930f9 156
1c5dc89d 157 # DA is enabled
158 # Setting variables in cache to be accesible by ccmake
159 set(ALIROOT_STATIC CACHE STRING "ENABLE static building of AliRoot: ON")
160 if(DA)
161 if(NOT DIM_FOUND)
162 set(DA FALSE)
163 message(FATAL_ERROR "DAs enabled but no DIMDIR and ODIR set. Please set DIMDIR to DIM installation and ODIR to platform (default linux)")
164 endif()
165
166 if(NOT DATE_FOUND)
167 set(DA FALSE)
168 message(FATAL_ERROR "DAs enabled but no DATE support found. Please point to your date installation using \"DATE_CONFIG\" variable")
169 endif()
170
171 if(NOT daqDA_FOUND)
172 set(DA FALSE)
173 message(FATAL_ERROR "DAs enabled but no daqDA support found. Please point to your daqDA installation using \"daqDA\" variable")
174 endif()
175
176 if(NOT AMORE_FOUND)
177 set(DA FALSE)
178 message(FATAL_ERROR "DAs enabled but no AMORE support found. Please point to your AMORE installation using \"AMORE_CONFIG\" variable")
179 endif()
16ae4e81 180
1c5dc89d 181 # Enable static libraries
182 set(ALIROOT_STATIC TRUE)
183 message(STATUS "DAs enabled")
16ae4e81 184 endif(DA)
f82bfa66 185
16ae4e81 186 # MDC rpm creation enables the static build
187 # Setting variables in cache to be accesible by ccmake
188 set(MDCRPM CACHE STRING "Enable mdc rpm build")
189 if(MDCRPM)
fae85bcc 190 set(ALIROOT_STATIC TRUE)
191 message(STATUS "AliMDC RPM enabled. AliRoot static build enabled")
16ae4e81 192 endif(MDCRPM)
193
194 # ROOT configuration mandatory
195 # FindRoot has to be after the enabling of DA due to libRootExtra
196 # Do not put it above DA
197 # Setting variables in cache to be accesible by ccmake
198 set(ROOTSYS CACHE STRING "ROOT installation folder")
199 if(ROOTSYS)
7c325e0b 200 find_package(ROOT REQUIRED)
201
202 # ROOT must be build with XML2 support
203 if(NOT ROOT_HASXML)
16ae4e81 204 message(FATAL_ERROR "ROOT was not build with xml2 support. Please reinstall or rebuild ROOT with xml2 support")
7c325e0b 205 endif(NOT ROOT_HASXML)
16ae4e81 206 else()
7c325e0b 207 message(FATAL_ERROR "ROOT installation not found!\nPlease point to the ROOT installation using -DROOTSYS=ROOT_INSTALL_DIR")
16ae4e81 208 endif(ROOTSYS)
7c325e0b 209
16ae4e81 210 # ROOT dictionaries and maps
211 include(CMakeALICE)
7c325e0b 212
16ae4e81 213 # If no Fortran, i.e on Windows
214 # We need to specify ROOT fortran
215 # (f95 comes before gfortran in default module)
216 include(CheckLanguage)
1dbe1076 217
16ae4e81 218 if(ROOT_FORTRAN)
1dbe1076 219 message(STATUS "Using the Fortran compiler defined by ROOT configuration: ${ROOT_FORTRAN}")
220 set(CMAKE_Fortran_COMPILER ${ROOT_FORTRAN})
16ae4e81 221 else()
1dbe1076 222 message(STATUS "Using default system Fortran compiler")
16ae4e81 223 endif(ROOT_FORTRAN)
1dbe1076 224
16ae4e81 225 check_language(Fortran)
226 if(CMAKE_Fortran_COMPILER)
1dbe1076 227 enable_language(Fortran OPTIONAL)
16ae4e81 228 else()
f82bfa66 229 message(STATUS "No Fortran support. Disabling LHAPDF, PHYTIA6, MICROCERN, etc.")
16ae4e81 230 endif()
231
232 # FastJet
233 find_package(FASTJET)
234
235 # ZEROMQ
236 find_package(ZeroMQ)
237
238 # Generating the AliRoot-config.cmake file
239 configure_file(${PROJECT_SOURCE_DIR}/cmake/AliRoot-config.cmake.in ${CMAKE_BINARY_DIR}/version/AliRoot-config.cmake @ONLY)
240 install(FILES ${PROJECT_BINARY_DIR}/version/AliRoot-config.cmake DESTINATION etc)
241
242 # General flags -> Should be moved into a configuration file
243 set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
244 set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE)
245
246 # List of modules for which PARfiles are enabled -- use the cache as global scope and clean it
247 set(ALIPARFILES "" CACHE INTERNAL "ALIPARFILES" FORCE)
248
249 # AliRoot base modules
250 add_subdirectory(STEER)
251 add_subdirectory(RAW)
252 add_subdirectory(ANALYSIS)
253
254 # Include Vc own cmake
255 include(Vc/Vc.cmake)
256 add_subdirectory(Vc)
257
258 # AliRoot common macros
259 add_subdirectory(macros)
260
261 # AliRoot modules
262 add_subdirectory(ACORDE)
263 add_subdirectory(AD)
264 add_subdirectory(BCM)
265 add_subdirectory(EMCAL)
266 add_subdirectory(EPOS)
267 add_subdirectory(EVE)
268 add_subdirectory(EVGEN)
269 add_subdirectory(FASTSIM)
270 add_subdirectory(FIT)
271 add_subdirectory(FMD)
272 add_subdirectory(HLT)
273 add_subdirectory(HMPID)
274 add_subdirectory(ITS)
275 add_subdirectory(MFT)
276 add_subdirectory(MONITOR)
277 add_subdirectory(MUON)
278 add_subdirectory(PHOS)
279 add_subdirectory(PMD)
280 add_subdirectory(PYTHIA8)
281 add_subdirectory(STARLIGHT)
282 add_subdirectory(STAT)
283 add_subdirectory(STRUCT)
284 add_subdirectory(T0)
285 add_subdirectory(TDPMjet)
286 add_subdirectory(TEvtGen)
287 add_subdirectory(THerwig)
288 add_subdirectory(TOF)
289 add_subdirectory(TPC)
290 add_subdirectory(TRD)
291 add_subdirectory(TRIGGER)
292 add_subdirectory(TTherminator)
293 add_subdirectory(VZERO)
294 add_subdirectory(ZDC)
295
296 # Fortran modules
297 if(CMAKE_Fortran_COMPILER)
298 add_subdirectory(DIME)
299 add_subdirectory(DPMJET)
300 add_subdirectory(HERWIG)
301 add_subdirectory(HIJING)
302 add_subdirectory(LHAPDF)
303 add_subdirectory(MICROCERN)
304 add_subdirectory(PYTHIA6)
305 add_subdirectory(TEPEMGEN)
306 add_subdirectory(THbtp)
307 add_subdirectory(THijing)
308 add_subdirectory(THydjet)
309 add_subdirectory(TPHIC)
310 add_subdirectory(TUHKMgen)
311 add_subdirectory(TAmpt)
312 endif(CMAKE_Fortran_COMPILER)
313
314 add_subdirectory(data)
315 add_subdirectory(GRP)
316 add_subdirectory(OCDB)
317 add_subdirectory(QAref)
318
319 # Enable SHUTTLE compilation
320 # Check if DIMDIR and ODIR are set
321 # # Setting variables in cache to be accesible by ccmake
322 set(SHUTTLE CACHE STRING "Enable SHUTTLE build : ON")
323 if(SHUTTLE)
1c5dc89d 324 if(NOT ROOT_HASMONALISA)
325 message(FATAL_ERROR "ROOT was not build with MonAlisa support")
326 endif()
327
328 find_package(ApMon)
329
101cc341 330 if(ROOT_HASALIEN STREQUAL "no")
16ae4e81 331 message(FATAL_ERROR "Shuttle needs ROOT build with AliEn support. Please build ROOT with AliEn support. Do not forget to set ALIEN to your AliEn installation")
101cc341 332 endif()
47b6091d 333
334 if(DIM_FOUND AND ALIEN)
335 add_subdirectory(SHUTTLE)
67018bf4 336 else()
16ae4e81 337 message(FATAL_ERROR "SHUTTLE enabled! Please specify DIMDIR, ODIR and ALIEN")
67018bf4 338 endif()
16ae4e81 339 endif(SHUTTLE)
340
341 add_subdirectory(ALIROOT)
342
343 # List modules with PARfiles
344 string(REPLACE ";" " " ALIPARFILES_FLAT "${ALIPARFILES}")
345 message(STATUS "PARfile target enabled for the following modules: ${ALIPARFILES_FLAT}")
346
347 # Install Find macros for common packages to be further used by AliPhysics
348 install(FILES
349 cmake/CMakeALICE.cmake
350 cmake/FindROOT.cmake
351 cmake/FindFASTJET.cmake
352 cmake/FindZeroMQ.cmake
353 cmake/GetGitRevisionDescription.cmake
354 cmake/GetGitRevisionDescription.cmake.in
355 DESTINATION cmake)
356
357endif(DEFINED DOXYGEN_ONLY AND DOXYGEN_ONLY)