]> git.uio.no Git - u/mrichter/AliRoot.git/blob - CMakeLists.txt
0ece85984422a21a82dd4407b7bf29ce6fe105e5
[u/mrichter/AliRoot.git] / CMakeLists.txt
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 #--------------------------------------------------------------------------#
19
20 cmake_minimum_required(VERSION 2.8.11 FATAL_ERROR)
21
22 ### CMP0025   Compiler id for Apple Clang is now AppleClang.
23 ### CMP0042   MACOSX_RPATH is enabled by default.
24
25 foreach(p
26   CMP0025 # CMake 3.0
27   CMP0042 # CMake 3.0
28   )
29   if(POLICY ${p})
30   cmake_policy(SET ${p} NEW)
31   endif()
32 endforeach()
33
34 project(AliRoot CXX C)
35
36 message(STATUS "CMake platform: ${CMAKE_SYSTEM}")
37 message(STATUS "Build folder: ${AliRoot_BINARY_DIR}")
38 message(STATUS "Source folder: ${AliRoot_SOURCE_DIR}")
39 message(STATUS "Installation folder: ${CMAKE_INSTALL_PREFIX}")
40
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"
43 set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
44 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
45
46 # You can change the build type using
47 # cmake -DCMAKE_BUILD_TYPE=DEBUG | RELEASE | RELWITHDEBINFO | MINSIZEREL ...
48 if (NOT CMAKE_BUILD_TYPE)
49   set(CMAKE_BUILD_TYPE RELWITHDEBINFO)
50 endif(NOT CMAKE_BUILD_TYPE)
51 message(STATUS "Build type: ${CMAKE_BUILD_TYPE} (${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}})")
52
53 if(CMAKE_INSTALL_PREFIX STREQUAL "${AliRoot_SOURCE_DIR}")
54   message(FATAL_ERROR "Please choose a different installation point than the source tree!")
55 endif()
56
57 # Path to additonal modules
58 set(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
68 include(CheckGitVersion)
69
70 # - CLANG_MAJOR.CLANG_MINOR or
71 # - GCC_MAJOR.GCC_MINOR.GCC_PATCH
72 include(CheckCompiler)
73
74 # Utility to generate PARfiles
75 include(cmake/GenParFile.cmake)
76
77 # Shared library suffix
78 if (NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
79   set(CMAKE_SHARED_LIBRARY_SUFFIX .so)
80 endif (NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
81
82 # Optional: Doxygen for reference doc generation
83 find_package(Doxygen)
84 if(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)
87 elseif(DOXYGEN_ONLY)
88   message(FATAL_ERROR "Doxygen and Graphviz not found. Cannot generate documentation")
89 else()
90   message(STATUS "Doxygen and Graphviz not found. Disabling support for documentation generation")
91 endif()
92
93 # Doxygen documentation is always included
94 add_subdirectory(doxygen)
95
96 if(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!")
102 else()
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")
114   set(DIMDIT CACHE STRING "dim installation folder")
115   set(ODIR CACHE STRING "dim plaform, usually \"linux\"")
116
117   if(DIMDIR AND ODIR)
118     find_package(DIM)
119   endif()
120
121   if(DIM_FOUND)
122     find_package(DATE)
123   else()
124     message(FATAL_ERROR "DATE enabled but no DIMDIR and ODIR set. Please set DIMDIR and ODIR")
125   endif()
126
127   # daqDA
128   # Setting variables in cache to be accesible by ccmake
129   set(daqDA CACHE STRING "daqDA library folder installation")
130   if(daqDA)
131     find_package(daqDA)
132   endif(daqDA)
133
134   # AMORE
135   # Setting variables in cache to be accesible by ccmake
136   set(AMORE_CONFIG CACHE STRING "amore-config script location")
137   if(AMORE_CONFIG)
138     if(ROOTSYS)
139       find_package(AMORE)
140     else()
141       message(FATAL_ERROR "AMORE enabled but no ROOTSYS defined")
142     endif()
143   endif(AMORE_CONFIG)
144
145   # id DARPM we enable DA if it is not set
146   # Setting variables in cache to be accesible by ccmake
147   set(DARPM CACHE STRING "Enable DARPM: ON")
148   set(DA CACHE STRING "Enable DA: ON")
149   if(DARPM)
150     if(NOT DA)
151       set(DA ON)
152     endif(NOT DA)
153   endif(DARPM)
154
155     # DA is enabled
156     # Setting variables in cache to be accesible by ccmake
157     set(ALIROOT_STATIC CACHE STRING "ENABLE static building of AliRoot: ON")
158     if(DA)
159         if(NOT DIM_FOUND)
160             set(DA FALSE)
161             message(FATAL_ERROR "DAs enabled but no DIMDIR and ODIR set. Please set DIMDIR to DIM installation and ODIR to platform (default linux)")
162         endif()
163
164         if(NOT DATE_FOUND)
165             set(DA FALSE)
166             message(FATAL_ERROR "DAs enabled but no DATE support found. Please point to your date installation using \"DATE_CONFIG\" variable")
167         endif()
168
169         if(NOT daqDA_FOUND)
170             set(DA FALSE)
171             message(FATAL_ERROR "DAs enabled but no daqDA support found. Please point to your daqDA installation using \"daqDA\" variable")
172         endif()
173
174         if(NOT AMORE_FOUND)
175             set(DA FALSE)
176             message(FATAL_ERROR "DAs enabled but no AMORE support found. Please point to your AMORE installation using \"AMORE_CONFIG\" variable")
177         endif()
178       
179         # Enable static libraries
180         set(ALIROOT_STATIC TRUE)
181         message(STATUS "DAs enabled")
182   endif(DA)
183
184   # MDC rpm creation enables the static build
185   # Setting variables in cache to be accesible by ccmake
186   set(MDCRPM CACHE STRING "Enable mdc rpm build")
187   if(MDCRPM)
188     set(ALIROOT_STATIC TRUE)
189     message(STATUS "AliMDC RPM enabled. AliRoot static build enabled")
190   endif(MDCRPM)
191
192   # ROOT configuration mandatory
193   # FindRoot has to be after the enabling of DA due to libRootExtra
194   # Do not put it above DA
195   # Setting variables in cache to be accesible by ccmake
196   set(ROOTSYS CACHE STRING "ROOT installation folder")
197   if(ROOTSYS)
198     find_package(ROOT REQUIRED)
199
200     # ROOT must be build with XML2 support
201     if(NOT ROOT_HASXML)
202       message(FATAL_ERROR "ROOT was not build with xml2 support. Please reinstall or rebuild ROOT with xml2 support")
203     endif(NOT ROOT_HASXML)
204   else()
205     message(FATAL_ERROR "ROOT installation not found!\nPlease point to the ROOT installation using -DROOTSYS=ROOT_INSTALL_DIR")
206   endif(ROOTSYS)
207
208   # ROOT dictionaries and maps
209   include(CMakeALICE)
210
211   # If no Fortran, i.e on Windows
212   # We need to specify ROOT fortran
213   # (f95 comes before gfortran in default module)
214   include(CheckLanguage)
215
216   if(ROOT_FORTRAN)
217     message(STATUS "Using the Fortran compiler defined by ROOT configuration: ${ROOT_FORTRAN}")
218     set(CMAKE_Fortran_COMPILER ${ROOT_FORTRAN})
219   else()
220     message(STATUS "Using default system Fortran compiler")
221   endif(ROOT_FORTRAN)
222
223   check_language(Fortran)
224   if(CMAKE_Fortran_COMPILER)
225     enable_language(Fortran OPTIONAL)
226   else()
227     message(STATUS "No Fortran support. Disabling LHAPDF, PHYTIA6, MICROCERN, etc.")
228   endif()
229
230   # FastJet
231   find_package(FASTJET)
232
233   # ZEROMQ
234   find_package(ZeroMQ)
235
236   # Generating the AliRoot-config.cmake file
237   configure_file(${PROJECT_SOURCE_DIR}/cmake/AliRoot-config.cmake.in ${CMAKE_BINARY_DIR}/version/AliRoot-config.cmake @ONLY)
238   install(FILES ${PROJECT_BINARY_DIR}/version/AliRoot-config.cmake DESTINATION etc)
239
240   # General flags -> Should be moved into a configuration file
241   set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
242   set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE)
243
244   # List of modules for which PARfiles are enabled -- use the cache as global scope and clean it
245   set(ALIPARFILES "" CACHE INTERNAL "ALIPARFILES" FORCE)
246
247   # AliRoot base modules
248   add_subdirectory(STEER)
249   add_subdirectory(RAW)
250   add_subdirectory(ANALYSIS)
251
252   # Include Vc own cmake
253   include(Vc/Vc.cmake)
254   add_subdirectory(Vc)
255
256   # AliRoot common macros
257   add_subdirectory(macros)
258
259   # AliRoot modules
260   add_subdirectory(ACORDE)
261   add_subdirectory(AD)
262   add_subdirectory(BCM)
263   add_subdirectory(EMCAL)
264   add_subdirectory(EPOS)
265   add_subdirectory(EVE)
266   add_subdirectory(EVGEN)
267   add_subdirectory(FASTSIM)
268   add_subdirectory(FIT)
269   add_subdirectory(FMD)
270   add_subdirectory(HLT)
271   add_subdirectory(HMPID)
272   add_subdirectory(ITS)
273   add_subdirectory(MFT)
274   add_subdirectory(MONITOR)
275   add_subdirectory(MUON)
276   add_subdirectory(PHOS)
277   add_subdirectory(PMD)
278   add_subdirectory(PYTHIA8)
279   add_subdirectory(STARLIGHT)
280   add_subdirectory(STAT)
281   add_subdirectory(STRUCT)
282   add_subdirectory(T0)
283   add_subdirectory(TDPMjet)
284   add_subdirectory(TEvtGen)
285   add_subdirectory(THerwig)
286   add_subdirectory(TOF)
287   add_subdirectory(TPC)
288   add_subdirectory(TRD)
289   add_subdirectory(TRIGGER)
290   add_subdirectory(TTherminator)
291   add_subdirectory(VZERO)
292   add_subdirectory(ZDC)
293
294   # Fortran modules
295   if(CMAKE_Fortran_COMPILER)
296     add_subdirectory(DIME)
297     add_subdirectory(DPMJET)
298     add_subdirectory(HERWIG)
299     add_subdirectory(HIJING)
300     add_subdirectory(LHAPDF)
301     add_subdirectory(MICROCERN)
302     add_subdirectory(PYTHIA6)
303     add_subdirectory(TEPEMGEN)
304     add_subdirectory(THbtp)
305     add_subdirectory(THijing)
306     add_subdirectory(THydjet)
307     add_subdirectory(TPHIC)
308     add_subdirectory(TUHKMgen)
309     add_subdirectory(TAmpt)
310   endif(CMAKE_Fortran_COMPILER)
311
312   add_subdirectory(data)
313   add_subdirectory(GRP)
314   add_subdirectory(OCDB)
315   add_subdirectory(QAref)
316
317   # Enable SHUTTLE compilation
318   # Check if DIMDIR and ODIR are set
319   # # Setting variables in cache to be accesible by ccmake
320   set(SHUTTLE CACHE STRING "Enable SHUTTLE build : ON")
321   if(SHUTTLE)
322     if(ROOT_HASALIEN STREQUAL "no")
323       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")
324     endif()
325
326     if(DIM_FOUND AND ALIEN)
327         add_subdirectory(SHUTTLE)
328     else()
329       message(FATAL_ERROR "SHUTTLE enabled! Please specify DIMDIR, ODIR and ALIEN")
330     endif()
331   endif(SHUTTLE)
332
333   add_subdirectory(ALIROOT)
334
335   # List modules with PARfiles
336   string(REPLACE ";" " " ALIPARFILES_FLAT "${ALIPARFILES}")
337   message(STATUS "PARfile target enabled for the following modules: ${ALIPARFILES_FLAT}")
338
339   # Install Find macros for common packages to be further used by AliPhysics
340   install(FILES
341     cmake/CMakeALICE.cmake
342     cmake/FindROOT.cmake
343     cmake/FindFASTJET.cmake
344     cmake/FindZeroMQ.cmake
345     cmake/GetGitRevisionDescription.cmake
346     cmake/GetGitRevisionDescription.cmake.in
347     DESTINATION cmake)
348
349 endif(DEFINED DOXYGEN_ONLY AND DOXYGEN_ONLY)