Changed fastjet includes to forward declarations for rootcint (Ch. Holm)
[u/mrichter/AliRoot.git] / CMakeLists.txt
... / ...
CommitLineData
1# -*- mode: cmake -*-
2
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
7
8
9cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR)
10
11#--------------------------------------------------------------------------------#
12# Set Basic CMake Configuration #
13#--------------------------------------------------------------------------------#
14
15project(AliRoot CXX C Fortran)
16
17# Environment variables
18set(ALICE $ENV{ALICE})
19if(NOT ALICE)
20 message(WARNING "Environment variable ALICE is not set")
21endif(NOT ALICE)
22
23set(ALICE_ROOT $ENV{ALICE_ROOT})
24if(NOT ALICE_ROOT)
25 message(FATAL_ERROR "Please set ALICE_ROOT to the AliRoot source directory")
26endif(NOT ALICE_ROOT)
27
28set(ALICE_INSTALL $ENV{ALICE_INSTALL})
29# Set AliRoot Installation directory
30if(NOT ALICE_INSTALL)
31 message(STATUS "AliRoot files will be installed in ${ALICE_ROOT}. You can specify a different location by setting ALICE_INSTALL environment variable")
32 set(ALICE_INSTALL ${ALICE_ROOT})
33else()
34 message(STATUS "AliRoot files will be installed in ${ALICE_INSTALL}")
35endif(NOT ALICE_INSTALL)
36if(${ALICE_INSTALL} STREQUAL ${CMAKE_BINARY_DIR})
37 message(FATAL_ERROR "Install dir should be different from build dir")
38endif()
39set(CMAKE_INSTALL_PREFIX ${ALICE_INSTALL})
40
41# Environment for SHUTTLE
42set(DIMDIR $ENV{DIMDIR})
43set(ODIR $ENV{ODIR})
44
45get_filename_component(PROJECT_SOURCE_DIR "${PROJECT_SOURCE_DIR}" REALPATH)
46set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
47set(CPACK_COMPONENTS_ALL MDC)
48
49include(ALICE_CMake)
50
51#--------------------------------------------------------------------------------#
52# Find Packages #
53#--------------------------------------------------------------------------------#
54
55# Subversion
56# ------------------------------
57
58find_package(Subversion REQUIRED)
59
60# ROOT
61# ------------------------------
62
63find_package(ROOT REQUIRED)
64
65# IRST Rule Checker
66# ------------------------------
67
68find_package(RuleChecker)
69
70# DATE
71# ------------------------------
72
73find_package(DATE)
74
75# GEANT3
76# ------------------------------
77
78find_package(GEANT3)
79
80# AMORE
81# ------------------------------
82
83find_package(AMORE)
84
85# AliRoot CPack configuration
86#-------------------------------
87
88find_package(CPack)
89
90# ZeroMQ
91# ------------------------------
92find_package(ZeroMQ)
93
94#--------------------------------------------------------------------------------#
95# Environment/Compiler Configuration #
96#--------------------------------------------------------------------------------#
97
98ALICE_CheckOutOfSourceBuild()
99ALICE_RootConfig(CMAKE_CXX_COMPILER --cxx)
100ALICE_RootConfig(CMAKE_C_COMPILER --cc)
101ALICE_RootConfig(CMAKE_Fortran_COMPILER --f77)
102ALICE_ConfigurePlatform()
103ALICE_ConfigureCompiler()
104
105
106#--------------------------------------------------------------------------------#
107# AliRoot Path Settings #
108#--------------------------------------------------------------------------------#
109
110ALICE_DevFlagsOutput()
111set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/tgt_${ALICE_TARGET}")
112set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/tgt_${ALICE_TARGET}")
113set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/tgt_${ALICE_TARGET}")
114set(CMAKE_INCLUDE_EXPORT_DIRECTORY "${PROJECT_BINARY_DIR}/include")
115file(MAKE_DIRECTORY ${CMAKE_INCLUDE_EXPORT_DIRECTORY})
116set(EXPORTDIRS "${ALICE_INSTALL}/include")
117set(BINLIBDIRS "-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
118
119
120#--------------------------------------------------------------------------------#
121# AliRoot Modules #
122#--------------------------------------------------------------------------------#
123
124# Exclude Module from all target
125# ------------------------------
126
127#set(EXCLUDEMODULES THydjet SHUTTLE)
128
129
130# Standard Modules
131# ------------------------------
132set(ALIROOTMODULES STEER PHOS TRD TPC ZDC MUON PMD FMD TOF ITS 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)
133
134if(THydjet)
135 list(APPEND ALIROOTMODULES THydjet)
136endif(THydjet)
137
138if(SHUTTLE)
139 list(APPEND ALIROOTMODULES SHUTTLE)
140endif(SHUTTLE)
141
142# Additional Modules
143# ------------------------------
144list(APPEND ALIROOTMODULES TUHKMgen EPOS)
145
146# EVE
147# ------------------------------
148ALICE_RootConfig(EVE --has-opengl)
149if(NOT EVE STREQUAL "no")
150 list(APPEND ALIROOTMODULES EVE)
151endif(NOT EVE STREQUAL "no")
152
153# CERN Modules
154# ------------------------------
155set(CERNMODULES LHAPDF HIJING MICROCERN HERWIG)
156
157# Check for Pythia 6
158if(EXISTS ${ROOTINCDIR}/TPythia6.h)
159 set(PYTHIA6 TRUE)
160 list(APPEND CERNMODULES PYTHIA6 EVGEN)
161elseif(NOT NOPYTHIA)
162 message(FATAL_ERROR "ROOT must have Pythia6 enabled !")
163endif(EXISTS ${ROOTINCDIR}/TPythia6.h)
164
165# Set Final list of modules
166set(MODULES ${ALIROOTMODULES} ${CERNMODULES} ALIROOT)
167
168# Set Module directories
169set(MODDIRS ${MODULES})
170
171# Libraries for Linking
172# ------------------------------
173set(ALILIBS MUON TPC PMD TRD FMD TOF ITS PHOS ACORDE HMPID VZERO ZDC STRUCT T0 EVGEN STEER TRIGGER MFT)
174set(LIBS ${ROOTCLIBS} ${ROOTPLIBS} ${SYSLIBS})
175
176# Configure ARVerion.h
177# ------------------------------
178#If the sources were taken from Git
179if(EXISTS ${PROJECT_SOURCE_DIR}/.git/)
180 include(GetGitRevisionDescription)
181 find_package(Git)
182 if(GIT_FOUND)
183 get_git_head_revision(GIT_REFSPEC GIT_SHA1)
184 message(STATUS "Aliroot Revision - ${GIT_SHA1} Branch - ${GIT_REFSPEC}")
185
186 STRING(REGEX REPLACE "^(.+/)(.+/)(.*)$" "\\3" SHORT_BRANCH "${GIT_REFSPEC}" )
187
188 set(ALIROOT_REVISION ${GIT_SHA1})
189 set(ALIROOT_BRANCH ${SHORT_BRANCH})
190
191 else()
192 message("Git not installed. I can't tell you which revision you are using!")
193 endif(GIT_FOUND)
194else()
195 message("AliRoot sources not downloaded from a Version Control System. I can't tell which revision you are using!")
196endif(EXISTS ${PROJECT_SOURCE_DIR}/.git/)
197
198configure_file(${PROJECT_SOURCE_DIR}/cmake/ARVersion.h.tmp ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h @ONLY)
199
200string (REPLACE "-" "." ALIROOT_BRANCH_SPEC "${ALIROOT_BRANCH}")
201
202#--------------------------------------------------------------------------------#
203# Build Modules #
204#--------------------------------------------------------------------------------#
205
206# Module Variables
207# ------------------------------
208set(ALLLIBS)
209set(ALLEXECS)
210set(INCLUDEFILES)
211set(BINLIBS)
212set(EXPORTFILES)
213
214# Top Level Build Targets
215# ------------------------------
216
217add_custom_target(alilibs-static)
218add_custom_target(include-headers ALL)
219add_custom_target(DA-all)
220add_custom_target(check-all)
221add_custom_target(check-hxml)
222add_custom_target(smell-all)
223add_custom_target(htmldoc)
224add_custom_target(par-all)
225add_custom_target(test-par-all)
226
227#NY file(GLOB CFILES_LIST ${CMAKE_SOURCE_DIR}/macros/*.C)
228
229add_custom_command(TARGET htmldoc
230 PRE_BUILD
231 COMMAND mkdir -p html
232 COMMAND rm -rf html/roothtml
233 COMMAND rm -f html/picts
234 COMMAND cd html && aliroot -q -b mkhtml.C\\\(0,1\\\)
235 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
236
237# Include Vc, which provides the static libVc and the relevant CMake macros
238include(Vc/Vc.cmake)
239add_subdirectory(Vc)
240
241# Add Modules
242# ------------------------------
243foreach(MODULE ${MODDIRS})
244 set(${MODULE}ALIBS)
245#RS configure_file(${PROJECT_SOURCE_DIR}/cmake/Module.tmp ${PROJECT_SOURCE_DIR}/${MODULE}/CMakeLists.txt @ONLY)
246 add_custom_target(${MODULE}-all ALL)
247 add_custom_target(${MODULE}-par-all)
248 add_custom_target(test-${MODULE}-par-all)
249 add_custom_target(${MODULE}-all-static)
250 add_dependencies(alilibs-static "${MODULE}-static")
251 add_subdirectory(${MODULE})
252
253#NY set(dir "${CMAKE_SOURCE_DIR}/${MODULE}")
254#NY if (EXISTS "${dir}")
255#NY file(GLOB CFILES_MOD ${dir}/*.C)
256#NY list(LENGTH CFILES_MOD len)
257#NY if (${len} GREATER 0)
258#NY list(APPEND CFILES_LIST "${CFILES_MOD}")
259#NY endif (${len} GREATER 0)
260#NY endif(EXISTS "${dir}")
261endforeach(MODULE)
262
263#NY foreach(cfile ${CFILES_LIST})
264#NY add_custom_command(TARGET htmldoc
265#NY PRE_BUILD
266#NY COMMAND cd html &&
267#NY aliroot -b -q \"mkhtml.C(\"${cfile}\")\" > /dev/null
268#NY WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
269#NY endforeach(cfile)
270
271if(DATE_FOUND)
272 include (CMakeDA)
273endif(DATE_FOUND)
274
275if(RULECHECKER_FOUND)
276 add_custom_target(factfile DEPENDS ${FACTFILE})
277 add_custom_command( OUTPUT ${FACTFILE}
278 COMMAND ${CMAKE_COMMAND} -E echo "Re-generating factfile"
279 COMMAND ${JAVA_RUNTIME} -Xmx1024M -jar ${FACTEXTRACTOR_JAR} ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}
280 DEPENDS check-hxml ${CMAKE_BINARY_DIR}/check-hxml-touchfile ${_factfile_deps}
281 WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
282endif(RULECHECKER_FOUND)
283
284#--------------------------------------------------------------------------------#
285# Additional Targets #
286#--------------------------------------------------------------------------------#
287
288# AliMdc RPM
289# ------------------------------
290
291execute_process(
292COMMAND root-config --libdir
293OUTPUT_VARIABLE ROOTALIBDIR)
294string(REPLACE "\n" "" ROOTALIBDIR ${ROOTALIBDIR})
295
296execute_process(
297COMMAND root-config --arch
298OUTPUT_VARIABLE ARCHITECTURE)
299
300
301set(AEXT a)
302set(LIBPATH ${CMAKE_BINARY_DIR}/lib/tgt_${ALICE_TARGET})
303set(BINPATH ${CMAKE_BINARY_DIR}/bin/tgt_${ALICE_TARGET})
304set(EXPORTDIR ${ALICE_ROOT}/include)
305set(BINLIBDIRS -L${ALICE_ROOT}/${LIBPATH})
306set(RAWDIRO ${CMAKE_BINARY_DIR}/RAW)
307set(ALIMDCSPECFILE ${RAWDIRO}/alimdc.spec)
308set(RAWDatabaseALIB ${LIBPATH}/libRAWDatabase.${AEXT})
309set(ESDALIB ${LIBPATH}/libESD.${AEXT})
310set(STEERBaseALIB ${LIBPATH}/libSTEERBase.${AEXT})
311set(MDCALIB ${LIBPATH}/libMDC.${AEXT})
312set(MODDIRO RAW/tgt_${ALICE_TARGET})
313
314
315if( ${ARCHITECTURE} MATCHES "linuxx8664gcc" )
316set(ALIMDCARCHDIR x86_64)
317elseif( ${ARCHITECTURE} MATCHES "linux" )
318set(ALIMDCARCHDIR i386)
319elseif( ${ARCHITECTURE} MATCHES "linuxia64gcc" )
320set(ALIMDCARCHDIR ia64)
321elseif(NOT DEFINED ${ARCHITECTURE})
322message("alimdc-rpm: Unknown architecture" )
323else( ${ARCHITECTURE} MATCHES "linuxx8664gcc" )
324message("alimdc-rpm: Unknown architecture" )
325endif( ${ARCHITECTURE} MATCHES "linuxx8664gcc" )
326
327
328add_custom_target( alimdc-rpm
329DEPENDS alimdc-static alimdc-specfile
330)
331
332add_custom_command(
333TARGET alimdc-rpm
334POST_BUILD
335COMMAND rm -rf ${ALICE_ROOT}/alimdc-root
336COMMAND mkdir -p ${ALICE_ROOT}/alimdc-root/opt/alimdc/lib
337COMMAND mkdir -p ${ALICE_ROOT}/alimdc-root/opt/alimdc/include
338COMMAND cp ${ALICE_ROOT}/RAW/mdc.h ${ALICE_ROOT}/alimdc-root/opt/alimdc/include
339COMMAND cp ${LIBPATH}/libAliMDC.a ${ALICE_ROOT}/alimdc-root/opt/alimdc/lib
340COMMAND cp ${ROOTALIBDIR}/libRoot.a ${ALICE_ROOT}/alimdc-root/opt/alimdc/lib
341COMMAND cp ${ROOTALIBDIR}/liblzma.a ${ALICE_ROOT}/alimdc-root/opt/alimdc/lib
342COMMAND cp ${ROOTALIBDIR}/libpcre.a ${ALICE_ROOT}/alimdc-root/opt/alimdc/lib
343COMMAND cp ${ROOTALIBDIR}/libfreetype.a ${ALICE_ROOT}/alimdc-root/opt/alimdc/lib
344COMMAND cp ${ROOTALIBDIR}/libpcre.a ${ALICE_ROOT}/alimdc-root/opt/alimdc/lib
345COMMAND rm -rf ${ALICE_ROOT}/RPMS
346COMMAND mkdir -p ${ALICE_ROOT}/RPMS/${ALIMDCARCHDIR}/
347COMMAND rpmbuild --verbose --define "_topdir ${ALICE_ROOT}" --define "_tmppath ${ALICE_ROOT}" -bb ${ALIMDCSPECFILE}
348COMMAND cp -p ${ALICE_ROOT}/RPMS/${ALIMDCARCHDIR}/alimdc-*.rpm .
349COMMAND rm -rf ${ALICE_ROOT}/alimdc-root
350COMMAND rm -rf ${ALICE_ROOT}/RPMS
351COMMAND echo "***** alimdc RPM created and put in ${CMAKE_BINARY_DIR} folder *****"
352)
353
354add_custom_command(
355TARGET ${RAWDIRO}
356COMMAND mkdir-p ${RAWDIRO}
357)
358
359
360add_custom_target( alimdc-specfile
361DEPENDS ${RAWDIRO}
362)
363
364add_custom_command(
365TARGET alimdc-specfile
366POST_BUILD
367COMMAND rm -rf ${ALIMDCSPECFILE}
368COMMAND @echo "***** Making alimdc RPM spec-file ${ALIMDCSPECFILE} *****"
369COMMAND @echo '\# RPM specfile for alimdc static libs' >> ${ALIMDCSPECFILE}
370COMMAND @echo '\# Package contains both ROOT and AliRoot' >> ${ALIMDCSPECFILE}
371COMMAND @echo '\# static libs needed by mStreamRecorder' >> ${ALIMDCSPECFILE}
372COMMAND @echo '\# in order to ROOT-ify the incoming raw' >> ${ALIMDCSPECFILE}
373COMMAND @echo '\# data' >> ${ALIMDCSPECFILE}
374COMMAND @echo '\# Example how-to build alimdc RPM:' >> ${ALIMDCSPECFILE}
375COMMAND @echo '\# cd ${ALICE_ROOT}' >> ${ALIMDCSPECFILE}
376COMMAND @echo '\# make alimdc-rpm' >> ${ALIMDCSPECFILE}
377COMMAND @echo "" >> ${ALIMDCSPECFILE}
378COMMAND @echo "Summary: AliMDC static libraries" >> ${ALIMDCSPECFILE}
379COMMAND @echo "Name: alimdc" >> ${ALIMDCSPECFILE}
380COMMAND @echo "Version: ${ALIROOT_BRANCH_SPEC}" >> ${ALIMDCSPECFILE}
381COMMAND @echo "Release: ${ALIROOT_REVISION}" >> ${ALIMDCSPECFILE}
382COMMAND @echo '\# Copyright: CERN Alice Off-line' >> ${ALIMDCSPECFILE}
383COMMAND @echo "License: CERN Alice Off-line" >> ${ALIMDCSPECFILE}
384COMMAND @echo "Vendor: ALICE Core Off-line Group" >> ${ALIMDCSPECFILE}
385COMMAND @echo "URL: http://aliceinfo.cern.ch" >> ${ALIMDCSPECFILE}
386COMMAND @echo "Group: Applications/Alice" >> ${ALIMDCSPECFILE}
387COMMAND @echo "Prefix: /opt/%{name}" >> ${ALIMDCSPECFILE}
388COMMAND @echo "BuildRoot: %{_tmppath}/%{name}-root" >> ${ALIMDCSPECFILE}
389COMMAND @echo "" >> ${ALIMDCSPECFILE}
390COMMAND @echo '\# automatic dependencies' >> ${ALIMDCSPECFILE}
391COMMAND @echo "AutoReqProv: yes" >> ${ALIMDCSPECFILE}
392COMMAND @echo "" >> ${ALIMDCSPECFILE}
393COMMAND @echo '\# list here required RPM packages for runtime' >> ${ALIMDCSPECFILE}
394COMMAND @echo "Requires: glibc" >> ${ALIMDCSPECFILE}
395COMMAND @echo "" >> ${ALIMDCSPECFILE}
396COMMAND @echo "Provides: alimdc" >> ${ALIMDCSPECFILE}
397COMMAND @echo "" >> ${ALIMDCSPECFILE}
398COMMAND @echo '\# description of the package' >> ${ALIMDCSPECFILE}
399COMMAND @echo "%description" >> ${ALIMDCSPECFILE}
400COMMAND @echo "Package contains both ROOT and AliRoot" >> ${ALIMDCSPECFILE}
401COMMAND @echo "static libs needed by mStreamRecorder" >> ${ALIMDCSPECFILE}
402COMMAND @echo "in order to ROOT-ify the incoming raw" >> ${ALIMDCSPECFILE}
403COMMAND @echo "data. The package version correspond to" >> ${ALIMDCSPECFILE}
404COMMAND @echo "the AliRoot one." >> ${ALIMDCSPECFILE}
405COMMAND @echo "" >> ${ALIMDCSPECFILE}
406COMMAND @echo '\# list of files to be installed' >> ${ALIMDCSPECFILE}
407COMMAND @echo "%files" >> ${ALIMDCSPECFILE}
408COMMAND @echo "%defattr (-,root,root)" >> ${ALIMDCSPECFILE}
409COMMAND @echo "%{prefix}/lib/libAliMDC.a" >> ${ALIMDCSPECFILE}
410COMMAND @echo "%{prefix}/lib/libRoot.a" >> ${ALIMDCSPECFILE}
411COMMAND @echo "%{prefix}/lib/libpcre.a" >> ${ALIMDCSPECFILE}
412COMMAND @echo "%{prefix}/lib/liblzma.a" >> ${ALIMDCSPECFILE}
413COMMAND @echo "%{prefix}/lib/libfreetype.a" >> ${ALIMDCSPECFILE}
414COMMAND @echo "%{prefix}/include/mdc.h" >> ${ALIMDCSPECFILE}
415)
416
417
418add_custom_target( alimdc-static
419DEPENDS ${LIBPATH} ${BINPATH} RAW-all-static STEER-all-static )
420
421add_custom_command(
422TARGET alimdc-static
423POST_BUILD
424COMMAND ar r ${LIBPATH}/alimdccxxo.a ${CMAKE_BINARY_DIR}/RAW/CMakeFiles/alimdc.dir/alimdc_main.cxx.o
425COMMAND rm -rf ${LIBPATH}/libAliMDC.a
426COMMAND ar x ${RAWDatabaseALIB}
427COMMAND ar x ${MDCALIB}
428COMMAND ar x ${ESDALIB}
429COMMAND ar x ${STEERBaseALIB}
430COMMAND ar r ${LIBPATH}/libAliMDC.a *.o
431COMMAND ar t ${RAWDatabaseALIB} | xargs rm
432COMMAND ar t ${MDCALIB} | xargs rm
433COMMAND ar t ${ESDALIB} | xargs rm
434COMMAND ar t ${STEERBaseALIB} | xargs rm
435COMMAND ${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 -ldl -lz
436COMMAND @echo "Target alimdc-static made"
437)
438
439add_custom_command(
440TARGET ${LIBPATH}
441COMMAND mkdir -p ${LIBPATH}
442)
443
444
445#include (MakefileDA)
446include (InstallRequiredSystemLibraries)
447include (CPack)
448
449# Install data
450# ------------------------------
451install ( DIRECTORY data
452 DESTINATION . )
453install ( DIRECTORY OCDB
454 DESTINATION .
455 PATTERN ".svn" EXCLUDE)
456install ( DIRECTORY QAref
457 DESTINATION .
458 PATTERN ".svn" EXCLUDE)
459install ( DIRECTORY GRP
460 DESTINATION .
461 PATTERN ".svn" EXCLUDE)
462
463#
464# EOF
465#
466