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