ALIROOT-5528 ATO-65 - replace FitSlicesY with robust fit function (commit after one...
[u/mrichter/AliRoot.git] / CMakeLists.txt
CommitLineData
62e74968 1# -*- mode: cmake -*-
2
6db31708 3# Top level CMakeList.txt file for the AliRoot Build System
4#
5# Author: Johny Jose (johny.jose@cern.ch)
6# Port of previous Makefile build to cmake
e969a926 7
e969a926 8
6b06712c 9cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR)
e969a926 10
6db31708 11#--------------------------------------------------------------------------------#
12# Set Basic CMake Configuration #
13#--------------------------------------------------------------------------------#
b07a2059 14
6db31708 15project(AliRoot CXX C Fortran)
bf4c2121 16
17# Environment variables
64cf46ff 18set(ALICE $ENV{ALICE})
6db31708 19if(NOT ALICE)
20 message(WARNING "Environment variable ALICE is not set")
21endif(NOT ALICE)
3ea0d710 22
64cf46ff 23set(ALICE_ROOT $ENV{ALICE_ROOT})
3ea0d710 24if(NOT ALICE_ROOT)
6db31708 25 message(FATAL_ERROR "Please set ALICE_ROOT to the AliRoot source directory")
3ea0d710 26endif(NOT ALICE_ROOT)
27
07044cfb 28set(ALICE_INSTALL $ENV{ALICE_INSTALL})
6db31708 29# Set AliRoot Installation directory
6a8ffaaa 30# If CMAKE_INSTALL_PREFIX was not set than we set it to ALICE_INSTALL.
31# If ALICE_INSTALL was not defined than it will default to source directory
420407e9 32if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
98b6977d 33 if(ALICE_INSTALL)
34 message(STATUS "AliRoot files will be installed in ${ALICE_INSTALL}")
35 else()
36 message(STATUS "AliRoot files will be installed in ${ALICE_ROOT}. You
37 can specify a different location by passing -DCMAKE_INSTALL_PREFIX or
38 by setting ALICE_INSTALL environment variable")
39 set(ALICE_INSTALL ${ALICE_ROOT})
40 if(${ALICE_INSTALL} STREQUAL ${CMAKE_BINARY_DIR})
41 message(FATAL_ERROR "The install directory must differ from the
42 build directory")
43 endif()
44 endif()
45 set(CMAKE_INSTALL_PREFIX ${ALICE_INSTALL} CACHE STRING "Install dir" FORCE)
6a8ffaaa 46endif()
6db31708 47
98b6977d 48
07044cfb 49# Environment for SHUTTLE
50set(DIMDIR $ENV{DIMDIR})
51set(ODIR $ENV{ODIR})
52
dad683d0 53get_filename_component(PROJECT_SOURCE_DIR "${PROJECT_SOURCE_DIR}" REALPATH)
f72dcc4f 54set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
0742852a 55set(CPACK_COMPONENTS_ALL MDC)
e969a926 56
6db31708 57include(ALICE_CMake)
f2cec6fb 58
6db31708 59#--------------------------------------------------------------------------------#
60# Find Packages #
61#--------------------------------------------------------------------------------#
e969a926 62
6db31708 63# Subversion
64# ------------------------------
e969a926 65
6db31708 66find_package(Subversion REQUIRED)
f7d3fd75 67
6db31708 68# ROOT
69# ------------------------------
f7d3fd75 70
6db31708 71find_package(ROOT REQUIRED)
3ea0d710 72
6db31708 73# IRST Rule Checker
74# ------------------------------
e969a926 75
6db31708 76find_package(RuleChecker)
e969a926 77
6db31708 78# DATE
79# ------------------------------
e969a926 80
6db31708 81find_package(DATE)
e969a926 82
6db31708 83# GEANT3
84# ------------------------------
e969a926 85
6db31708 86find_package(GEANT3)
e969a926 87
6db31708 88# AMORE
89# ------------------------------
90
91find_package(AMORE)
92
0742852a 93# AliRoot CPack configuration
94#-------------------------------
95
96find_package(CPack)
97
7e0cf530 98# ZeroMQ
99# ------------------------------
100find_package(ZeroMQ)
0742852a 101
ebc98c6f 102# fastjet
103# ------------------------------
104find_package(FASTJET)
105
6db31708 106#--------------------------------------------------------------------------------#
107# Environment/Compiler Configuration #
108#--------------------------------------------------------------------------------#
109
110ALICE_CheckOutOfSourceBuild()
111ALICE_RootConfig(CMAKE_CXX_COMPILER --cxx)
112ALICE_RootConfig(CMAKE_C_COMPILER --cc)
113ALICE_RootConfig(CMAKE_Fortran_COMPILER --f77)
114ALICE_ConfigurePlatform()
115ALICE_ConfigureCompiler()
116
117
118#--------------------------------------------------------------------------------#
119# AliRoot Path Settings #
120#--------------------------------------------------------------------------------#
121
122ALICE_DevFlagsOutput()
123set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/tgt_${ALICE_TARGET}")
124set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/tgt_${ALICE_TARGET}")
125set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/tgt_${ALICE_TARGET}")
126set(CMAKE_INCLUDE_EXPORT_DIRECTORY "${PROJECT_BINARY_DIR}/include")
127file(MAKE_DIRECTORY ${CMAKE_INCLUDE_EXPORT_DIRECTORY})
128set(EXPORTDIRS "${ALICE_INSTALL}/include")
129set(BINLIBDIRS "-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
130
0742852a 131
6db31708 132#--------------------------------------------------------------------------------#
133# AliRoot Modules #
134#--------------------------------------------------------------------------------#
135
136# Exclude Module from all target
137# ------------------------------
138
45526b5e 139#set(EXCLUDEMODULES THydjet SHUTTLE)
6db31708 140
0742852a 141
6db31708 142# Standard Modules
143# ------------------------------
5eb34a26 144set(ALIROOTMODULES STEER PHOS TRD TPC ZDC MUON PMD FMD TOF ITS AD ACORDE HMPID T0 BCM STRUCT VZERO THijing THbtp EMCAL THerwig TEPEMGEN FASTSIM TPHIC RAW MONITOR STORAGE ANALYSIS JETAN HLT STAT TTherminator CORRFW DPMJET TDPMjet STARLIGHT PWGPP PWG PWGCF PWGGA PWGHF PWGDQ PWGJE PWGLF PWGUD TRIGGER PYTHIA8 TAmpt OADB MFT TEvtGen FIT)
45526b5e 145
146if(THydjet)
147 list(APPEND ALIROOTMODULES THydjet)
148endif(THydjet)
149
150if(SHUTTLE)
151 list(APPEND ALIROOTMODULES SHUTTLE)
152endif(SHUTTLE)
6db31708 153
154# Additional Modules
155# ------------------------------
156list(APPEND ALIROOTMODULES TUHKMgen EPOS)
157
158# EVE
159# ------------------------------
160ALICE_RootConfig(EVE --has-opengl)
161if(NOT EVE STREQUAL "no")
162 list(APPEND ALIROOTMODULES EVE)
163endif(NOT EVE STREQUAL "no")
164
165# CERN Modules
166# ------------------------------
167set(CERNMODULES LHAPDF HIJING MICROCERN HERWIG)
168
169# Check for Pythia 6
170if(EXISTS ${ROOTINCDIR}/TPythia6.h)
171 set(PYTHIA6 TRUE)
872bf9ef 172 list(APPEND CERNMODULES PYTHIA6 EVGEN)
811ffdcc 173elseif(NOT NOPYTHIA)
45526b5e 174 message(FATAL_ERROR "ROOT must have Pythia6 enabled !")
6db31708 175endif(EXISTS ${ROOTINCDIR}/TPythia6.h)
176
177# Set Final list of modules
178set(MODULES ${ALIROOTMODULES} ${CERNMODULES} ALIROOT)
179
180# Set Module directories
181set(MODDIRS ${MODULES})
182
183# Libraries for Linking
184# ------------------------------
5e319bd5 185set(ALILIBS MUON TPC PMD TRD FMD TOF ITS PHOS AD ACORDE HMPID VZERO ZDC STRUCT T0 EVGEN STEER TRIGGER MFT)
6db31708 186set(LIBS ${ROOTCLIBS} ${ROOTPLIBS} ${SYSLIBS})
187
188# Configure ARVerion.h
189# ------------------------------
0492edf5
A
190#If the sources were taken from Git
191if(EXISTS ${PROJECT_SOURCE_DIR}/.git/)
192 include(GetGitRevisionDescription)
aca5075b 193
0492edf5 194 find_package(Git)
aca5075b 195
0492edf5
A
196 if(GIT_FOUND)
197 get_git_head_revision(GIT_REFSPEC GIT_SHA1)
fb7e4ca3 198
199 # GIT_REFSPEC is empty for detached mode = tags in detached mode or checkout to specific hash
200
201
202 # returns the closest reference to the current hash
203 # name of the current tag or heads/branch in the case of branches
204 git_describe(ALIROOT_GIT_TAG "--all" "--abbrev=0")
aca5075b 205
206 STRING(REGEX REPLACE "^(.+/)(.+)/(.*)$" "\\2" BRANCH_TYPE "${GIT_REFSPEC}" )
fb7e4ca3 207
208 # the revision is not set in the case of a branch, it means we are doing development
209 # and the revision will trigger a reconfiguration
aca5075b 210 if(BRANCH_TYPE STREQUAL "heads")
211 set(ALIROOT_REVISION "ThisIsaBranchNoRevisionProvided")
fb7e4ca3 212 STRING(REGEX REPLACE "^(.+/)(.+/)(.*)$" "\\3" SHORT_BRANCH "${GIT_REFSPEC}" )
aca5075b 213 else()
fb7e4ca3 214 set(SHORT_BRANCH ${ALIROOT_GIT_TAG})
aca5075b 215 set(ALIROOT_REVISION ${GIT_SHA1})
216 endif()
0492edf5 217
0492edf5 218 set(ALIROOT_BRANCH ${SHORT_BRANCH})
fb7e4ca3 219 message(STATUS "Aliroot branch/tag: \"${ALIROOT_BRANCH}\" - Revision: \"${GIT_SHA1}\" ")
0492edf5
A
220
221 else()
222 message("Git not installed. I can't tell you which revision you are using!")
223 endif(GIT_FOUND)
224else()
225 message("AliRoot sources not downloaded from a Version Control System. I can't tell which revision you are using!")
226endif(EXISTS ${PROJECT_SOURCE_DIR}/.git/)
227
7377baa3 228configure_file(${PROJECT_SOURCE_DIR}/cmake/ARVersion.h.tmp ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/FromTemplate/ARVersion.h @ONLY)
0492edf5
A
229
230string (REPLACE "-" "." ALIROOT_BRANCH_SPEC "${ALIROOT_BRANCH}")
6db31708 231
232#--------------------------------------------------------------------------------#
233# Build Modules #
234#--------------------------------------------------------------------------------#
235
236# Module Variables
237# ------------------------------
238set(ALLLIBS)
239set(ALLEXECS)
240set(INCLUDEFILES)
241set(BINLIBS)
242set(EXPORTFILES)
243
244# Top Level Build Targets
245# ------------------------------
246
247add_custom_target(alilibs-static)
e93f6949 248add_custom_target(include-headers ALL)
45526b5e 249add_custom_target(DA-all)
e93f6949 250add_custom_target(check-all)
251add_custom_target(check-hxml)
ae388d3b 252add_custom_target(smell-all)
6a1caa6b 253add_custom_target(htmldoc)
6a9e2760 254add_custom_target(par-all)
3a8dbb31 255add_custom_target(test-par-all)
7531a2ac 256
6a1caa6b 257#NY file(GLOB CFILES_LIST ${CMAKE_SOURCE_DIR}/macros/*.C)
258
259add_custom_command(TARGET htmldoc
260 PRE_BUILD
261 COMMAND mkdir -p html
262 COMMAND rm -rf html/roothtml
263 COMMAND rm -f html/picts
5a46c82e 264 COMMAND cd html && aliroot -q -b mkhtml.C\\\(0,1\\\)
6a1caa6b 265 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
266
144f39dd 267# Include Vc, which provides the static libVc and the relevant CMake macros
268include(Vc/Vc.cmake)
269add_subdirectory(Vc)
6a1caa6b 270
271# Add Modules
6db31708 272# ------------------------------
273foreach(MODULE ${MODDIRS})
45526b5e 274 set(${MODULE}ALIBS)
e017f840 275#RS configure_file(${PROJECT_SOURCE_DIR}/cmake/Module.tmp ${PROJECT_SOURCE_DIR}/${MODULE}/CMakeLists.txt @ONLY)
6db31708 276 add_custom_target(${MODULE}-all ALL)
3a8dbb31 277 add_custom_target(${MODULE}-par-all)
278 add_custom_target(test-${MODULE}-par-all)
529f129e 279 add_custom_target(${MODULE}-all-static)
6db31708 280 add_dependencies(alilibs-static "${MODULE}-static")
281 add_subdirectory(${MODULE})
6a1caa6b 282
283#NY set(dir "${CMAKE_SOURCE_DIR}/${MODULE}")
284#NY if (EXISTS "${dir}")
285#NY file(GLOB CFILES_MOD ${dir}/*.C)
286#NY list(LENGTH CFILES_MOD len)
287#NY if (${len} GREATER 0)
288#NY list(APPEND CFILES_LIST "${CFILES_MOD}")
289#NY endif (${len} GREATER 0)
290#NY endif(EXISTS "${dir}")
6db31708 291endforeach(MODULE)
292
6a1caa6b 293#NY foreach(cfile ${CFILES_LIST})
294#NY add_custom_command(TARGET htmldoc
295#NY PRE_BUILD
296#NY COMMAND cd html &&
297#NY aliroot -b -q \"mkhtml.C(\"${cfile}\")\" > /dev/null
298#NY WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
299#NY endforeach(cfile)
300
5713c03f 301if(DATE_FOUND)
c3b22277 302 include (CMakeDA)
5713c03f 303endif(DATE_FOUND)
c3b22277 304
f09b91ba 305if(RULECHECKER_FOUND)
e93f6949 306 add_custom_target(factfile DEPENDS ${FACTFILE})
62e74968 307 add_custom_command( OUTPUT ${FACTFILE}
e93f6949 308 COMMAND ${CMAKE_COMMAND} -E echo "Re-generating factfile"
309 COMMAND ${JAVA_RUNTIME} -Xmx1024M -jar ${FACTEXTRACTOR_JAR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}
310 DEPENDS check-hxml ${CMAKE_BINARY_DIR}/check-hxml-touchfile ${_factfile_deps}
62e74968 311 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
f09b91ba 312endif(RULECHECKER_FOUND)
62e74968 313
6db31708 314#--------------------------------------------------------------------------------#
315# Additional Targets #
316#--------------------------------------------------------------------------------#
317
7531a2ac 318# AliMdc RPM
319# ------------------------------
320
f17f29d0 321execute_process(
322COMMAND root-config --libdir
323OUTPUT_VARIABLE ROOTALIBDIR)
324string(REPLACE "\n" "" ROOTALIBDIR ${ROOTALIBDIR})
325
326execute_process(
327COMMAND root-config --arch
328OUTPUT_VARIABLE ARCHITECTURE)
329
330
331set(AEXT a)
332set(LIBPATH ${CMAKE_BINARY_DIR}/lib/tgt_${ALICE_TARGET})
333set(BINPATH ${CMAKE_BINARY_DIR}/bin/tgt_${ALICE_TARGET})
334set(EXPORTDIR ${ALICE_ROOT}/include)
5eb34a26 335set(BINLIBDIRS -L${ALICE_ROOT}/${LIBPATH})
f17f29d0 336set(RAWDIRO ${CMAKE_BINARY_DIR}/RAW)
337set(ALIMDCSPECFILE ${RAWDIRO}/alimdc.spec)
338set(RAWDatabaseALIB ${LIBPATH}/libRAWDatabase.${AEXT})
339set(ESDALIB ${LIBPATH}/libESD.${AEXT})
340set(STEERBaseALIB ${LIBPATH}/libSTEERBase.${AEXT})
341set(MDCALIB ${LIBPATH}/libMDC.${AEXT})
342set(MODDIRO RAW/tgt_${ALICE_TARGET})
343
344
345if( ${ARCHITECTURE} MATCHES "linuxx8664gcc" )
346set(ALIMDCARCHDIR x86_64)
347elseif( ${ARCHITECTURE} MATCHES "linux" )
348set(ALIMDCARCHDIR i386)
349elseif( ${ARCHITECTURE} MATCHES "linuxia64gcc" )
350set(ALIMDCARCHDIR ia64)
351elseif(NOT DEFINED ${ARCHITECTURE})
d9fbc3ca 352message("alimdc-rpm: Unknown architecture" )
f17f29d0 353else( ${ARCHITECTURE} MATCHES "linuxx8664gcc" )
d9fbc3ca 354message("alimdc-rpm: Unknown architecture" )
f17f29d0 355endif( ${ARCHITECTURE} MATCHES "linuxx8664gcc" )
356
357
018253d2 358# Module version will be written in the generated header
359configure_file ("RAW/alimdc.spec.in" "${CMAKE_CURRENT_BINARY_DIR}/RAW/alimdc.spec" @ONLY)
360
f17f29d0 361add_custom_target( alimdc-rpm
018253d2 362DEPENDS alimdc-static
f17f29d0 363)
364
365add_custom_command(
366TARGET alimdc-rpm
367POST_BUILD
018253d2 368COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root
369COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
370COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/include
371COMMAND cp ${ALICE_ROOT}/RAW/mdc.h ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/include
372COMMAND cp ${LIBPATH}/libAliMDC.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
373COMMAND cp ${ROOTALIBDIR}/libRoot.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
374COMMAND cp ${ROOTALIBDIR}/liblzma.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
375COMMAND cp ${ROOTALIBDIR}/libpcre.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
376COMMAND cp ${ROOTALIBDIR}/libfreetype.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
377COMMAND cp ${ROOTALIBDIR}/libpcre.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
378COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/RPMS
379COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/RPMS/${ALIMDCARCHDIR}/
380COMMAND rpmbuild --verbose --define "_topdir ${CMAKE_CURRENT_BINARY_DIR}" --define "%buildroot ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root" -bb ${ALIMDCSPECFILE}
381COMMAND cp -p ${CMAKE_CURRENT_BINARY_DIR}/RPMS/${ALIMDCARCHDIR}/alimdc-*.rpm .
382COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root
383COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/RPMS
f17f29d0 384COMMAND echo "***** alimdc RPM created and put in ${CMAKE_BINARY_DIR} folder *****"
385)
386
387add_custom_command(
388TARGET ${RAWDIRO}
389COMMAND mkdir-p ${RAWDIRO}
390)
391
392
f17f29d0 393add_custom_target( alimdc-static
394DEPENDS ${LIBPATH} ${BINPATH} RAW-all-static STEER-all-static )
395
396add_custom_command(
397TARGET alimdc-static
398POST_BUILD
399COMMAND ar r ${LIBPATH}/alimdccxxo.a ${CMAKE_BINARY_DIR}/RAW/CMakeFiles/alimdc.dir/alimdc_main.cxx.o
400COMMAND rm -rf ${LIBPATH}/libAliMDC.a
401COMMAND ar x ${RAWDatabaseALIB}
402COMMAND ar x ${MDCALIB}
403COMMAND ar x ${ESDALIB}
404COMMAND ar x ${STEERBaseALIB}
405COMMAND ar r ${LIBPATH}/libAliMDC.a *.o
406COMMAND ar t ${RAWDatabaseALIB} | xargs rm
407COMMAND ar t ${MDCALIB} | xargs rm
408COMMAND ar t ${ESDALIB} | xargs rm
409COMMAND ar t ${STEERBaseALIB} | xargs rm
b2685a60 410COMMAND ${CMAKE_CXX_COMPILER} ${LDFLAGS} -o ${BINPATH}/alimdca ${LIBPATH}/alimdccxxo.a ${LIBPATH}/libAliMDC.a ${ROOTALIBDIR}/libRoot.a ${ROOTALIBDIR}/libfreetype.a ${ROOTALIBDIR}/libpcre.a ${ROOTALIBDIR}/liblzma.a -pthread -lssl -ldl -lz
f17f29d0 411COMMAND @echo "Target alimdc-static made"
412)
413
414add_custom_command(
415TARGET ${LIBPATH}
416COMMAND mkdir -p ${LIBPATH}
417)
418
419
420#include (MakefileDA)
6db31708 421include (InstallRequiredSystemLibraries)
422include (CPack)
e969a926 423
d2884be9 424# Install data
425# ------------------------------
426install ( DIRECTORY data
427 DESTINATION . )
71d5ee50 428install ( DIRECTORY OCDB
429 DESTINATION .
430 PATTERN ".svn" EXCLUDE)
431install ( DIRECTORY QAref
432 DESTINATION .
433 PATTERN ".svn" EXCLUDE)
c2aad3ae 434install ( DIRECTORY GRP
435 DESTINATION .
436 PATTERN ".svn" EXCLUDE)
d2884be9 437
438#
439# EOF
440#
441