CMake: prepend_prefix() to every elm in a list
[u/mrichter/AliRoot.git] / CMakeLists.txt
... / ...
CommitLineData
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
20cmake_minimum_required(VERSION 2.8.11 FATAL_ERROR)
21
22project(AliRoot CXX C)
23
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}")
28
29# You can change the build type using
30# cmake -DCMAKE_BUILD_TYPE=DEBUG | RELEASE | RELWITHDEBINFO | MINSIZEREL ...
31if (NOT CMAKE_BUILD_TYPE)
32 set(CMAKE_BUILD_TYPE RELWITHDEBINFO)
33endif(NOT CMAKE_BUILD_TYPE)
34message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
35
36
37if(CMAKE_INSTALL_PREFIX STREQUAL "${AliRoot_SOURCE_DIR}")
38 message(FATAL_ERROR "Please choose a different installation point than the source tree!")
39endif()
40
41# Path to additonal modules
42set(CMAKE_MODULE_PATH "${AliRoot_SOURCE_DIR}/cmake")
43
44# AliRoot version extracted from Git repository
45# Sets 4 git variables
46# - GIT_REFSPEC - complete name of the current reference
47# - ALIROOT_BRANCH - name of the branch or tag extracted from the current reference
48# - GIT_SHA1 - current hash in the long format
49# - GIT_SHORT_SHA1 - current hash in the short format
50# - ALIROOT_VERSION = ALIROOT_BRANCH
51# - ALIROOT_REVISION = GIT_SHORT_SHA1
52include(CheckGitVersion)
53
54# - CLANG_MAJOR.CLANG_MINOR or
55# - GCC_MAJOR.GCC_MINOR.GCC_PATCH
56include(CheckCompiler)
57
58# Utility to generate PARfiles
59include(cmake/GenParFile.cmake)
60
61# Shared library suffix
62if (NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
63 set(CMAKE_SHARED_LIBRARY_SUFFIX .so)
64endif (NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
65
66# Checking first for DIM, DATE, AMORE and daqDA
67# in case ROOT Extra static library needs to be enabled
68
69# DATE
70# date-config needs DIMDIR and ODIR set
71if(DATE_CONFIG)
72 if(DIMDIR AND ODIR)
73 find_package(DATE)
74 else()
75 message(FATAL_ERROR "DATE enabled but no DIMDIR and ODIR set. Please set DIMDIR and ODIR")
76 endif()
77endif()
78
79# daqDA
80if(daqDA)
81 find_package(daqDA)
82endif(daqDA)
83
84# AMORE
85if(AMORE_CONFIG)
86 if(ROOTSYS)
87 find_package(AMORE)
88 else()
89 message(FATAL_ERROR "AMORE enabled but no ROOTSYS defined")
90 endif()
91endif(AMORE_CONFIG)
92
93# id DARPM we enable DA if it is not set
94if(DARPM)
95 if(NOT DA)
96 set(DA ON)
97 endif(NOT DA)
98endif(DARPM)
99
100# DA is enabled
101if(DA)
102 if(NOT DIMDIR AND NOT ODIR)
103 set(DA FALSE)
104 message(FATAL_ERROR "Das enabled but no DIMDIR and ODIR set. Please set DIMDIR to DIM installation and ODIR to platform (default linux)")
105 endif()
106
107 if(NOT DATE_FOUND)
108 set(DA FALSE)
109 message(FATAL_ERROR "DAs enabled but no DATE support found. Please point to your date installation using \"DATE_CONFIG\" variable")
110 endif()
111
112 if(NOT daqDA_FOUND)
113 set(DA FALSE)
114 message(FATAL_ERROR "DAs enabled but no daqDA support found. Please point to your daqDA installation using \"daqDA\" variable")
115 endif()
116
117 if(NOT AMORE_FOUND)
118 set(DA FALSE)
119 message(FATAL_ERROR "DAs enabled but no AMORE support found. Please point to your AMORE installation using \"AMORE_CONFIG\" variable")
120 endif()
121
122 # Enable static libraries
123 set(ALIROOT_STATIC TRUE)
124 message(STATUS "DAs enabled")
125endif(DA)
126
127# MDC rpm creation enables the static build
128if(MDCRPM)
129 set(ALIROOT_STATIC TRUE)
130 message(STATUS "AliMDC RPM enabled. AliRoot static build enabled")
131endif(MDCRPM)
132
133# ROOT configuration mandatory
134# FindRoot has to be after the enabling of DA due to libRootExtra
135# Do not put it above DA
136if(ROOTSYS)
137 find_package(ROOT REQUIRED)
138
139 # ROOT must be build with XML2 support
140 if(NOT ROOT_HASXML)
141 message(FATAL_ERROR "ROOT was not build with xml2 support. Please reinstall or rebuild ROOT with xml2 support")
142 endif(NOT ROOT_HASXML)
143else()
144 message(FATAL_ERROR "ROOT installation not found!\nPlease point to the ROOT installation using -DROOTSYS=ROOT_INSTALL_DIR")
145endif(ROOTSYS)
146
147# ROOT dictionaries and maps
148include(CMakeALICE)
149
150
151# If no Fortran, i.e on Windows
152# We need to specify ROOT fortran
153# (f95 comes before gfortran in default module)
154include(CheckLanguage)
155
156if(ROOT_FORTRAN)
157 message(STATUS "Using the Fortran compiler defined by ROOT configuration: ${ROOT_FORTRAN}")
158 set(CMAKE_Fortran_COMPILER ${ROOT_FORTRAN})
159else()
160 message(STATUS "Using default system Fortran compiler")
161endif(ROOT_FORTRAN)
162
163check_language(Fortran)
164if(CMAKE_Fortran_COMPILER)
165 enable_language(Fortran OPTIONAL)
166else()
167 message(STATUS "No Fortran support. Disabling LHAPDF, PHYTIA6, MICROCERN, etc.")
168endif()
169
170# Optional: Doxygen for reference doc generation
171find_package(Doxygen)
172if(DOXYGEN_FOUND AND DOXYGEN_DOT_FOUND)
173 message(STATUS "Doxygen ${DOXYGEN_VERSION} and Graphviz found: ${DOXYGEN_EXECUTABLE}, ${DOXYGEN_DOT_EXECUTABLE}")
174 set(CAN_GENERATE_DOC TRUE)
175else()
176 message(STATUS "Doxygen and Graphviz not found. Disabling support for documentation generation")
177endif(DOXYGEN_FOUND AND DOXYGEN_DOT_FOUND)
178
179# FastJet
180find_package(FASTJET)
181
182# ZEROMQ
183find_package(ZeroMQ)
184
185# Generating the AliRoot-config.cmake file
186configure_file(${PROJECT_SOURCE_DIR}/cmake/AliRoot-config.cmake.in ${CMAKE_BINARY_DIR}/version/AliRoot-config.cmake @ONLY)
187install(FILES ${PROJECT_BINARY_DIR}/version/AliRoot-config.cmake DESTINATION etc)
188
189# General flags -> Should be moved into a configuration file
190set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
191set(CMAKE_NO_SYSTEM_FROM_IMPORTED TRUE)
192
193# AliRoot base modules
194add_subdirectory(STEER)
195add_subdirectory(RAW)
196add_subdirectory(ANALYSIS)
197
198# Include Vc own cmake
199include(Vc/Vc.cmake)
200add_subdirectory(Vc)
201
202# AliRoot common macros
203add_subdirectory(macros)
204
205# AliRoot modules
206add_subdirectory(ACORDE)
207add_subdirectory(AD)
208add_subdirectory(BCM)
209add_subdirectory(EMCAL)
210add_subdirectory(EPOS)
211add_subdirectory(EVE)
212add_subdirectory(EVGEN)
213add_subdirectory(FASTSIM)
214add_subdirectory(FIT)
215add_subdirectory(FMD)
216add_subdirectory(HLT)
217add_subdirectory(HMPID)
218add_subdirectory(ITS)
219add_subdirectory(MFT)
220add_subdirectory(MONITOR)
221add_subdirectory(MUON)
222add_subdirectory(PHOS)
223add_subdirectory(PMD)
224add_subdirectory(PYTHIA8)
225add_subdirectory(STARLIGHT)
226add_subdirectory(STAT)
227add_subdirectory(STRUCT)
228add_subdirectory(T0)
229add_subdirectory(TDPMjet)
230add_subdirectory(TEvtGen)
231add_subdirectory(THerwig)
232add_subdirectory(TOF)
233add_subdirectory(TPC)
234add_subdirectory(TRD)
235add_subdirectory(TRIGGER)
236add_subdirectory(TTherminator)
237add_subdirectory(VZERO)
238add_subdirectory(ZDC)
239add_subdirectory(doxygen)
240
241# Fortran modules
242if(CMAKE_Fortran_COMPILER)
243 add_subdirectory(DIME)
244 add_subdirectory(DPMJET)
245 add_subdirectory(HERWIG)
246 add_subdirectory(HIJING)
247 add_subdirectory(LHAPDF)
248 add_subdirectory(MICROCERN)
249 add_subdirectory(PYTHIA6)
250 add_subdirectory(TEPEMGEN)
251 add_subdirectory(THbtp)
252 add_subdirectory(THijing)
253 add_subdirectory(THydjet)
254 add_subdirectory(TPHIC)
255 add_subdirectory(TUHKMgen)
256 add_subdirectory(TAmpt)
257endif(CMAKE_Fortran_COMPILER)
258
259add_subdirectory(data)
260add_subdirectory(GRP)
261add_subdirectory(OCDB)
262add_subdirectory(QAref)
263
264# Enable SHUTTLE compilation
265# Check if DIMDIR and ODIR are set
266if(SHUTTLE)
267 if(ROOT_HASALIEN STREQUAL "no")
268 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")
269 endif()
270
271 if(DIMDIR AND ODIR AND ALIEN)
272 add_subdirectory(SHUTTLE)
273 else()
274 message(FATAL_ERROR "SHUTTLE enabled! Please specify DIMDIR, ODIR and ALIEN")
275 endif()
276endif(SHUTTLE)
277
278add_subdirectory(ALIROOT)