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