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