updated macros for Kaon Femto analysis
[u/mrichter/AliRoot.git] / CMakeLists.txt
CommitLineData
d37e8011 1# -*- mode: cmake -*-/usr/share/applications/thunderbird.desktop
62e74968 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
d9cb61c9 30# If CMAKE_INSTALL_PREFIX was not set, then we set it to ALICE_INSTALL.
31# If ALICE_INSTALL was not defined, then it will default to the 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# ------------------------------
164d3d29 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 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# ------------------------------
d37e8011 190# If the sources were taken from Git
191# Sets 3 git variables
192# - GIT_REFSPEC - complete name of the current reference
193# - ALIROOT_BRANCH - name of the branch or tag extracted from the current reference
194# - GIT_SHA1 - current hash in the long format
195# - GIT_SHORT_SHA1 - current hash in the short format
0492edf5
A
196if(EXISTS ${PROJECT_SOURCE_DIR}/.git/)
197 include(GetGitRevisionDescription)
aca5075b 198
0492edf5 199 find_package(Git)
aca5075b 200
0492edf5
A
201 if(GIT_FOUND)
202 get_git_head_revision(GIT_REFSPEC GIT_SHA1)
fb7e4ca3 203
204 # GIT_REFSPEC is empty for detached mode = tags in detached mode or checkout to specific hash
205
206
207 # returns the closest reference to the current hash
208 # name of the current tag or heads/branch in the case of branches
209 git_describe(ALIROOT_GIT_TAG "--all" "--abbrev=0")
aca5075b 210
211 STRING(REGEX REPLACE "^(.+/)(.+)/(.*)$" "\\2" BRANCH_TYPE "${GIT_REFSPEC}" )
fb7e4ca3 212
213 # the revision is not set in the case of a branch, it means we are doing development
214 # and the revision will trigger a reconfiguration
aca5075b 215 if(BRANCH_TYPE STREQUAL "heads")
216 set(ALIROOT_REVISION "ThisIsaBranchNoRevisionProvided")
fb7e4ca3 217 STRING(REGEX REPLACE "^(.+/)(.+/)(.*)$" "\\3" SHORT_BRANCH "${GIT_REFSPEC}" )
aca5075b 218 else()
fb7e4ca3 219 set(SHORT_BRANCH ${ALIROOT_GIT_TAG})
aca5075b 220 set(ALIROOT_REVISION ${GIT_SHA1})
221 endif()
0492edf5 222
0492edf5 223 set(ALIROOT_BRANCH ${SHORT_BRANCH})
d37e8011 224
225 # generate the short version of the revision hash
226 execute_process(COMMAND git rev-parse --short ${GIT_SHA1}
227 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
228 OUTPUT_STRIP_TRAILING_WHITESPACE
229 RESULT_VARIABLE res
230 OUTPUT_VARIABLE GIT_SHORT_SHA1)
231
232 # if the rev-parse fails we set the short sha to the long initial one
233 if(NOT res EQUAL 0)
234 set(GIT_SHORT_SHA1 ${GIT_SHA1})
235 endif()
236
237 message(STATUS "Aliroot branch/tag: \"${ALIROOT_BRANCH}\" - Revision: \"${GIT_SHORT_SHA1}\" ")
0492edf5
A
238
239 else()
240 message("Git not installed. I can't tell you which revision you are using!")
241 endif(GIT_FOUND)
242else()
243 message("AliRoot sources not downloaded from a Version Control System. I can't tell which revision you are using!")
244endif(EXISTS ${PROJECT_SOURCE_DIR}/.git/)
245
7377baa3 246configure_file(${PROJECT_SOURCE_DIR}/cmake/ARVersion.h.tmp ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/FromTemplate/ARVersion.h @ONLY)
0492edf5
A
247
248string (REPLACE "-" "." ALIROOT_BRANCH_SPEC "${ALIROOT_BRANCH}")
6db31708 249
250#--------------------------------------------------------------------------------#
251# Build Modules #
252#--------------------------------------------------------------------------------#
253
254# Module Variables
255# ------------------------------
256set(ALLLIBS)
257set(ALLEXECS)
258set(INCLUDEFILES)
259set(BINLIBS)
260set(EXPORTFILES)
261
262# Top Level Build Targets
263# ------------------------------
264
265add_custom_target(alilibs-static)
e93f6949 266add_custom_target(include-headers ALL)
45526b5e 267add_custom_target(DA-all)
e93f6949 268add_custom_target(check-all)
269add_custom_target(check-hxml)
ae388d3b 270add_custom_target(smell-all)
6a1caa6b 271add_custom_target(htmldoc)
6a9e2760 272add_custom_target(par-all)
3a8dbb31 273add_custom_target(test-par-all)
7531a2ac 274
6a1caa6b 275#NY file(GLOB CFILES_LIST ${CMAKE_SOURCE_DIR}/macros/*.C)
276
277add_custom_command(TARGET htmldoc
278 PRE_BUILD
279 COMMAND mkdir -p html
280 COMMAND rm -rf html/roothtml
281 COMMAND rm -f html/picts
5a46c82e 282 COMMAND cd html && aliroot -q -b mkhtml.C\\\(0,1\\\)
6a1caa6b 283 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
284
144f39dd 285# Include Vc, which provides the static libVc and the relevant CMake macros
286include(Vc/Vc.cmake)
287add_subdirectory(Vc)
6a1caa6b 288
289# Add Modules
6db31708 290# ------------------------------
291foreach(MODULE ${MODDIRS})
45526b5e 292 set(${MODULE}ALIBS)
e017f840 293#RS configure_file(${PROJECT_SOURCE_DIR}/cmake/Module.tmp ${PROJECT_SOURCE_DIR}/${MODULE}/CMakeLists.txt @ONLY)
6db31708 294 add_custom_target(${MODULE}-all ALL)
3a8dbb31 295 add_custom_target(${MODULE}-par-all)
296 add_custom_target(test-${MODULE}-par-all)
529f129e 297 add_custom_target(${MODULE}-all-static)
6db31708 298 add_dependencies(alilibs-static "${MODULE}-static")
299 add_subdirectory(${MODULE})
6a1caa6b 300
301#NY set(dir "${CMAKE_SOURCE_DIR}/${MODULE}")
302#NY if (EXISTS "${dir}")
303#NY file(GLOB CFILES_MOD ${dir}/*.C)
304#NY list(LENGTH CFILES_MOD len)
305#NY if (${len} GREATER 0)
306#NY list(APPEND CFILES_LIST "${CFILES_MOD}")
307#NY endif (${len} GREATER 0)
308#NY endif(EXISTS "${dir}")
6db31708 309endforeach(MODULE)
310
6a1caa6b 311#NY foreach(cfile ${CFILES_LIST})
312#NY add_custom_command(TARGET htmldoc
313#NY PRE_BUILD
314#NY COMMAND cd html &&
315#NY aliroot -b -q \"mkhtml.C(\"${cfile}\")\" > /dev/null
316#NY WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
317#NY endforeach(cfile)
318
5713c03f 319if(DATE_FOUND)
c3b22277 320 include (CMakeDA)
5713c03f 321endif(DATE_FOUND)
c3b22277 322
f09b91ba 323if(RULECHECKER_FOUND)
e93f6949 324 add_custom_target(factfile DEPENDS ${FACTFILE})
62e74968 325 add_custom_command( OUTPUT ${FACTFILE}
e93f6949 326 COMMAND ${CMAKE_COMMAND} -E echo "Re-generating factfile"
327 COMMAND ${JAVA_RUNTIME} -Xmx1024M -jar ${FACTEXTRACTOR_JAR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}
328 DEPENDS check-hxml ${CMAKE_BINARY_DIR}/check-hxml-touchfile ${_factfile_deps}
62e74968 329 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
f09b91ba 330endif(RULECHECKER_FOUND)
62e74968 331
6db31708 332#--------------------------------------------------------------------------------#
333# Additional Targets #
334#--------------------------------------------------------------------------------#
335
7531a2ac 336# AliMdc RPM
337# ------------------------------
338
f17f29d0 339execute_process(
340COMMAND root-config --libdir
341OUTPUT_VARIABLE ROOTALIBDIR)
342string(REPLACE "\n" "" ROOTALIBDIR ${ROOTALIBDIR})
343
344execute_process(
345COMMAND root-config --arch
346OUTPUT_VARIABLE ARCHITECTURE)
347
348
349set(AEXT a)
350set(LIBPATH ${CMAKE_BINARY_DIR}/lib/tgt_${ALICE_TARGET})
351set(BINPATH ${CMAKE_BINARY_DIR}/bin/tgt_${ALICE_TARGET})
352set(EXPORTDIR ${ALICE_ROOT}/include)
5eb34a26 353set(BINLIBDIRS -L${ALICE_ROOT}/${LIBPATH})
f17f29d0 354set(RAWDIRO ${CMAKE_BINARY_DIR}/RAW)
355set(ALIMDCSPECFILE ${RAWDIRO}/alimdc.spec)
356set(RAWDatabaseALIB ${LIBPATH}/libRAWDatabase.${AEXT})
357set(ESDALIB ${LIBPATH}/libESD.${AEXT})
358set(STEERBaseALIB ${LIBPATH}/libSTEERBase.${AEXT})
359set(MDCALIB ${LIBPATH}/libMDC.${AEXT})
360set(MODDIRO RAW/tgt_${ALICE_TARGET})
361
362
363if( ${ARCHITECTURE} MATCHES "linuxx8664gcc" )
364set(ALIMDCARCHDIR x86_64)
365elseif( ${ARCHITECTURE} MATCHES "linux" )
366set(ALIMDCARCHDIR i386)
367elseif( ${ARCHITECTURE} MATCHES "linuxia64gcc" )
368set(ALIMDCARCHDIR ia64)
369elseif(NOT DEFINED ${ARCHITECTURE})
d9fbc3ca 370message("alimdc-rpm: Unknown architecture" )
f17f29d0 371else( ${ARCHITECTURE} MATCHES "linuxx8664gcc" )
d9fbc3ca 372message("alimdc-rpm: Unknown architecture" )
f17f29d0 373endif( ${ARCHITECTURE} MATCHES "linuxx8664gcc" )
374
375
018253d2 376# Module version will be written in the generated header
377configure_file ("RAW/alimdc.spec.in" "${CMAKE_CURRENT_BINARY_DIR}/RAW/alimdc.spec" @ONLY)
378
f17f29d0 379add_custom_target( alimdc-rpm
018253d2 380DEPENDS alimdc-static
f17f29d0 381)
382
383add_custom_command(
384TARGET alimdc-rpm
385POST_BUILD
018253d2 386COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root
387COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
388COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/include
389COMMAND cp ${ALICE_ROOT}/RAW/mdc.h ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/include
390COMMAND cp ${LIBPATH}/libAliMDC.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
391COMMAND cp ${ROOTALIBDIR}/libRoot.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
392COMMAND cp ${ROOTALIBDIR}/liblzma.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
393COMMAND cp ${ROOTALIBDIR}/libpcre.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
394COMMAND cp ${ROOTALIBDIR}/libfreetype.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
395COMMAND cp ${ROOTALIBDIR}/libpcre.a ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root/opt/alimdc/lib
396COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/RPMS
397COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/RPMS/${ALIMDCARCHDIR}/
398COMMAND rpmbuild --verbose --define "_topdir ${CMAKE_CURRENT_BINARY_DIR}" --define "%buildroot ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root" -bb ${ALIMDCSPECFILE}
399COMMAND cp -p ${CMAKE_CURRENT_BINARY_DIR}/RPMS/${ALIMDCARCHDIR}/alimdc-*.rpm .
400COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/alimdc-root
401COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/RPMS
f17f29d0 402COMMAND echo "***** alimdc RPM created and put in ${CMAKE_BINARY_DIR} folder *****"
403)
404
405add_custom_command(
406TARGET ${RAWDIRO}
407COMMAND mkdir-p ${RAWDIRO}
408)
409
410
f17f29d0 411add_custom_target( alimdc-static
412DEPENDS ${LIBPATH} ${BINPATH} RAW-all-static STEER-all-static )
413
414add_custom_command(
415TARGET alimdc-static
416POST_BUILD
417COMMAND ar r ${LIBPATH}/alimdccxxo.a ${CMAKE_BINARY_DIR}/RAW/CMakeFiles/alimdc.dir/alimdc_main.cxx.o
418COMMAND rm -rf ${LIBPATH}/libAliMDC.a
419COMMAND ar x ${RAWDatabaseALIB}
420COMMAND ar x ${MDCALIB}
421COMMAND ar x ${ESDALIB}
422COMMAND ar x ${STEERBaseALIB}
423COMMAND ar r ${LIBPATH}/libAliMDC.a *.o
424COMMAND ar t ${RAWDatabaseALIB} | xargs rm
425COMMAND ar t ${MDCALIB} | xargs rm
426COMMAND ar t ${ESDALIB} | xargs rm
427COMMAND ar t ${STEERBaseALIB} | xargs rm
b2685a60 428COMMAND ${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 429COMMAND @echo "Target alimdc-static made"
430)
431
432add_custom_command(
433TARGET ${LIBPATH}
434COMMAND mkdir -p ${LIBPATH}
435)
436
437
438#include (MakefileDA)
6db31708 439include (InstallRequiredSystemLibraries)
440include (CPack)
e969a926 441
d2884be9 442# Install data
443# ------------------------------
444install ( DIRECTORY data
445 DESTINATION . )
71d5ee50 446install ( DIRECTORY OCDB
447 DESTINATION .
448 PATTERN ".svn" EXCLUDE)
449install ( DIRECTORY QAref
450 DESTINATION .
451 PATTERN ".svn" EXCLUDE)
c2aad3ae 452install ( DIRECTORY GRP
453 DESTINATION .
454 PATTERN ".svn" EXCLUDE)
d2884be9 455
456#
457# EOF
458#
459