Fix Coverity defects
[u/mrichter/AliRoot.git] / CMakeLists.txt
CommitLineData
6db31708 1# Top level CMakeList.txt file for the AliRoot Build System
2#
3# Author: Johny Jose (johny.jose@cern.ch)
4# Port of previous Makefile build to cmake
e969a926 5
e969a926 6
6db31708 7cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
e969a926 8
6db31708 9#--------------------------------------------------------------------------------#
10# Set Basic CMake Configuration #
11#--------------------------------------------------------------------------------#
b07a2059 12
6db31708 13project(AliRoot CXX C Fortran)
7f40fabf 14set(ALICE_ROOT $ENV{ALICE_ROOT})
6db31708 15set(ALICE $ENV{ALICE})
16
17if(NOT ALICE)
18 message(WARNING "Environment variable ALICE is not set")
19endif(NOT ALICE)
3ea0d710 20
3ea0d710 21if(NOT ALICE_ROOT)
6db31708 22 message(FATAL_ERROR "Please set ALICE_ROOT to the AliRoot source directory")
3ea0d710 23endif(NOT ALICE_ROOT)
24
6db31708 25# Set AliRoot Installation directory
26if(NOT ALICE_INSTALL)
27 message(STATUS "AliRoot files will be installed in ${ALICE_ROOT}. You can specify a different location by setting ALICE_INSTALL environment variable")
28 set(ALICE_INSTALL ${ALICE_ROOT})
29else()
30 message(STATUS "AliRoot files will be installed in ${ALICE_INSTALL}")
31endif(NOT ALICE_INSTALL)
32
dad683d0 33get_filename_component(PROJECT_SOURCE_DIR "${PROJECT_SOURCE_DIR}" REALPATH)
f72dcc4f 34set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
0742852a 35set(CPACK_COMPONENTS_ALL MDC)
e969a926 36
6db31708 37include(ALICE_CMake)
f2cec6fb 38
6db31708 39#--------------------------------------------------------------------------------#
40# Find Packages #
41#--------------------------------------------------------------------------------#
e969a926 42
6db31708 43# Subversion
44# ------------------------------
e969a926 45
6db31708 46find_package(Subversion REQUIRED)
f7d3fd75 47
6db31708 48# ROOT
49# ------------------------------
f7d3fd75 50
6db31708 51find_package(ROOT REQUIRED)
3ea0d710 52
6db31708 53# IRST Rule Checker
54# ------------------------------
e969a926 55
6db31708 56find_package(RuleChecker)
e969a926 57
6db31708 58# DATE
59# ------------------------------
e969a926 60
6db31708 61find_package(DATE)
e969a926 62
6db31708 63# GEANT3
64# ------------------------------
e969a926 65
6db31708 66find_package(GEANT3)
e969a926 67
6db31708 68# AMORE
69# ------------------------------
70
71find_package(AMORE)
72
0742852a 73# AliRoot CPack configuration
74#-------------------------------
75
76find_package(CPack)
77
78
6db31708 79#--------------------------------------------------------------------------------#
80# Environment/Compiler Configuration #
81#--------------------------------------------------------------------------------#
82
83ALICE_CheckOutOfSourceBuild()
84ALICE_RootConfig(CMAKE_CXX_COMPILER --cxx)
85ALICE_RootConfig(CMAKE_C_COMPILER --cc)
86ALICE_RootConfig(CMAKE_Fortran_COMPILER --f77)
87ALICE_ConfigurePlatform()
88ALICE_ConfigureCompiler()
89
90
91#--------------------------------------------------------------------------------#
92# AliRoot Path Settings #
93#--------------------------------------------------------------------------------#
94
95ALICE_DevFlagsOutput()
96set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/tgt_${ALICE_TARGET}")
97set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/tgt_${ALICE_TARGET}")
98set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/tgt_${ALICE_TARGET}")
99set(CMAKE_INCLUDE_EXPORT_DIRECTORY "${PROJECT_BINARY_DIR}/include")
100file(MAKE_DIRECTORY ${CMAKE_INCLUDE_EXPORT_DIRECTORY})
101set(EXPORTDIRS "${ALICE_INSTALL}/include")
102set(BINLIBDIRS "-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
103
0742852a 104
6db31708 105#--------------------------------------------------------------------------------#
106# AliRoot Modules #
107#--------------------------------------------------------------------------------#
108
109# Exclude Module from all target
110# ------------------------------
111
45526b5e 112#set(EXCLUDEMODULES THydjet SHUTTLE)
6db31708 113
0742852a 114
6db31708 115# Standard Modules
116# ------------------------------
c2a2c0b8 117set(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 LHC ESDCheck STAT TTherminator CORRFW DPMJET TDPMjet PWG0 PWG1 PWG2 PWG3 PWG4 TRIGGER PYTHIA8 TAmpt )
45526b5e 118
119if(THydjet)
120 list(APPEND ALIROOTMODULES THydjet)
121endif(THydjet)
122
123if(SHUTTLE)
124 list(APPEND ALIROOTMODULES SHUTTLE)
125endif(SHUTTLE)
6db31708 126
127# Additional Modules
128# ------------------------------
129list(APPEND ALIROOTMODULES TUHKMgen EPOS)
130
131# EVE
132# ------------------------------
133ALICE_RootConfig(EVE --has-opengl)
134if(NOT EVE STREQUAL "no")
135 list(APPEND ALIROOTMODULES EVE)
136endif(NOT EVE STREQUAL "no")
137
138# CERN Modules
139# ------------------------------
140set(CERNMODULES LHAPDF HIJING MICROCERN HERWIG)
141
142# Check for Pythia 6
143if(EXISTS ${ROOTINCDIR}/TPythia6.h)
144 set(PYTHIA6 TRUE)
145 list(APPEND CERNMODULES PYTHIA6 RALICE EVGEN)
146else()
45526b5e 147 message(FATAL_ERROR "ROOT must have Pythia6 enabled !")
6db31708 148endif(EXISTS ${ROOTINCDIR}/TPythia6.h)
149
150# Set Final list of modules
151set(MODULES ${ALIROOTMODULES} ${CERNMODULES} ALIROOT)
152
153# Set Module directories
154set(MODDIRS ${MODULES})
155
156# Libraries for Linking
157# ------------------------------
158set(ALILIBS MUON TPC PMD TRD FMD TOF ITS PHOS ACORDE HMPID VZERO ZDC STRUCT T0 EVGEN STEER TRIGGER)
159set(LIBS ${ROOTCLIBS} ${ROOTPLIBS} ${SYSLIBS})
160
161# Configure ARVerion.h
162# ------------------------------
163if(Subversion_FOUND)
164 Subversion_WC_INFO(${PROJECT_SOURCE_DIR} PROJECT)
165 set(ALIROOT_SVN_REVISION ${PROJECT_WC_REVISION})
166 set(ALIROOT_SVN_BRANCH ${PROJECT_WC_URL})
167 string(REGEX MATCH "[^/]+$" ALIROOT_SVN_BRANCH ${ALIROOT_SVN_BRANCH})
168 message(STATUS "Aliroot Revision - ${ALIROOT_SVN_REVISION} Branch - ${ALIROOT_SVN_BRANCH}")
169 if(EXISTS ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
170 file(REMOVE ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
171 endif(EXISTS ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
172 configure_file(${PROJECT_SOURCE_DIR}/cmake/ARVersion.h.tmp ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h @ONLY)
173endif(Subversion_FOUND)
174
175#--------------------------------------------------------------------------------#
176# Build Modules #
177#--------------------------------------------------------------------------------#
178
179# Module Variables
180# ------------------------------
181set(ALLLIBS)
182set(ALLEXECS)
183set(INCLUDEFILES)
184set(BINLIBS)
185set(EXPORTFILES)
186
187# Top Level Build Targets
188# ------------------------------
189
190add_custom_target(alilibs-static)
191add_custom_target(include-headers)
45526b5e 192add_custom_target(DA-all)
c2a2c0b8 193add_custom_target(check-all)
6a9e2760 194add_custom_target(par-all)
3a8dbb31 195add_custom_target(test-par-all)
7531a2ac 196
6db31708 197# Add Modules
198# ------------------------------
199foreach(MODULE ${MODDIRS})
45526b5e 200 set(${MODULE}ALIBS)
6db31708 201 configure_file(${PROJECT_SOURCE_DIR}/cmake/Module.tmp ${PROJECT_SOURCE_DIR}/${MODULE}/CMakeLists.txt @ONLY)
202 add_custom_target(${MODULE}-all ALL)
c2a2c0b8 203 add_custom_target(${MODULE}-check-all)
3a8dbb31 204 add_custom_target(${MODULE}-par-all)
205 add_custom_target(test-${MODULE}-par-all)
c2a2c0b8 206 add_dependencies(check-all "${MODULE}-check-all")
529f129e 207 add_custom_target(${MODULE}-all-static)
6db31708 208 add_dependencies(alilibs-static "${MODULE}-static")
209 add_subdirectory(${MODULE})
6db31708 210endforeach(MODULE)
211
c3b22277 212if(DATE_FOUND AND AMORE_FOUND)
213 include (CMakeDA)
214endif(DATE_FOUND AND AMORE_FOUND)
215
6db31708 216#--------------------------------------------------------------------------------#
217# Additional Targets #
218#--------------------------------------------------------------------------------#
219
7531a2ac 220# AliMdc RPM
221# ------------------------------
222
6db31708 223include (InstallRequiredSystemLibraries)
224include (CPack)
e969a926 225