coverity fixes
[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
f72dcc4f 33set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
e969a926 34
6db31708 35include(ALICE_CMake)
f2cec6fb 36
6db31708 37#--------------------------------------------------------------------------------#
38# Find Packages #
39#--------------------------------------------------------------------------------#
e969a926 40
6db31708 41# Subversion
42# ------------------------------
e969a926 43
6db31708 44find_package(Subversion REQUIRED)
f7d3fd75 45
6db31708 46# ROOT
47# ------------------------------
f7d3fd75 48
6db31708 49find_package(ROOT REQUIRED)
3ea0d710 50
6db31708 51# IRST Rule Checker
52# ------------------------------
e969a926 53
6db31708 54find_package(RuleChecker)
e969a926 55
6db31708 56# DATE
57# ------------------------------
e969a926 58
6db31708 59find_package(DATE)
e969a926 60
6db31708 61# GEANT3
62# ------------------------------
e969a926 63
6db31708 64find_package(GEANT3)
e969a926 65
6db31708 66# AMORE
67# ------------------------------
68
69find_package(AMORE)
70
71#--------------------------------------------------------------------------------#
72# Environment/Compiler Configuration #
73#--------------------------------------------------------------------------------#
74
75ALICE_CheckOutOfSourceBuild()
76ALICE_RootConfig(CMAKE_CXX_COMPILER --cxx)
77ALICE_RootConfig(CMAKE_C_COMPILER --cc)
78ALICE_RootConfig(CMAKE_Fortran_COMPILER --f77)
79ALICE_ConfigurePlatform()
80ALICE_ConfigureCompiler()
81
82
83#--------------------------------------------------------------------------------#
84# AliRoot Path Settings #
85#--------------------------------------------------------------------------------#
86
87ALICE_DevFlagsOutput()
88set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/tgt_${ALICE_TARGET}")
89set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/tgt_${ALICE_TARGET}")
90set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib/tgt_${ALICE_TARGET}")
91set(CMAKE_INCLUDE_EXPORT_DIRECTORY "${PROJECT_BINARY_DIR}/include")
92file(MAKE_DIRECTORY ${CMAKE_INCLUDE_EXPORT_DIRECTORY})
93set(EXPORTDIRS "${ALICE_INSTALL}/include")
94set(BINLIBDIRS "-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
95
96#--------------------------------------------------------------------------------#
97# AliRoot Modules #
98#--------------------------------------------------------------------------------#
99
100# Exclude Module from all target
101# ------------------------------
102
45526b5e 103#set(EXCLUDEMODULES THydjet SHUTTLE)
6db31708 104
105# Standard Modules
106# ------------------------------
45526b5e 107set(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 )
108
109if(THydjet)
110 list(APPEND ALIROOTMODULES THydjet)
111endif(THydjet)
112
113if(SHUTTLE)
114 list(APPEND ALIROOTMODULES SHUTTLE)
115endif(SHUTTLE)
6db31708 116
117# Additional Modules
118# ------------------------------
119list(APPEND ALIROOTMODULES TUHKMgen EPOS)
120
121# EVE
122# ------------------------------
123ALICE_RootConfig(EVE --has-opengl)
124if(NOT EVE STREQUAL "no")
125 list(APPEND ALIROOTMODULES EVE)
126endif(NOT EVE STREQUAL "no")
127
128# CERN Modules
129# ------------------------------
130set(CERNMODULES LHAPDF HIJING MICROCERN HERWIG)
131
132# Check for Pythia 6
133if(EXISTS ${ROOTINCDIR}/TPythia6.h)
134 set(PYTHIA6 TRUE)
135 list(APPEND CERNMODULES PYTHIA6 RALICE EVGEN)
136else()
45526b5e 137 message(FATAL_ERROR "ROOT must have Pythia6 enabled !")
6db31708 138endif(EXISTS ${ROOTINCDIR}/TPythia6.h)
139
140# Set Final list of modules
141set(MODULES ${ALIROOTMODULES} ${CERNMODULES} ALIROOT)
142
143# Set Module directories
144set(MODDIRS ${MODULES})
145
146# Libraries for Linking
147# ------------------------------
148set(ALILIBS MUON TPC PMD TRD FMD TOF ITS PHOS ACORDE HMPID VZERO ZDC STRUCT T0 EVGEN STEER TRIGGER)
149set(LIBS ${ROOTCLIBS} ${ROOTPLIBS} ${SYSLIBS})
150
151# Configure ARVerion.h
152# ------------------------------
153if(Subversion_FOUND)
154 Subversion_WC_INFO(${PROJECT_SOURCE_DIR} PROJECT)
155 set(ALIROOT_SVN_REVISION ${PROJECT_WC_REVISION})
156 set(ALIROOT_SVN_BRANCH ${PROJECT_WC_URL})
157 string(REGEX MATCH "[^/]+$" ALIROOT_SVN_BRANCH ${ALIROOT_SVN_BRANCH})
158 message(STATUS "Aliroot Revision - ${ALIROOT_SVN_REVISION} Branch - ${ALIROOT_SVN_BRANCH}")
159 if(EXISTS ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
160 file(REMOVE ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
161 endif(EXISTS ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
162 configure_file(${PROJECT_SOURCE_DIR}/cmake/ARVersion.h.tmp ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h @ONLY)
163endif(Subversion_FOUND)
164
165#--------------------------------------------------------------------------------#
166# Build Modules #
167#--------------------------------------------------------------------------------#
168
169# Module Variables
170# ------------------------------
171set(ALLLIBS)
172set(ALLEXECS)
173set(INCLUDEFILES)
174set(BINLIBS)
175set(EXPORTFILES)
176
177# Top Level Build Targets
178# ------------------------------
179
180add_custom_target(alilibs-static)
181add_custom_target(include-headers)
45526b5e 182add_custom_target(DA-all)
6db31708 183# Add Modules
184# ------------------------------
185foreach(MODULE ${MODDIRS})
45526b5e 186 set(${MODULE}ALIBS)
6db31708 187 configure_file(${PROJECT_SOURCE_DIR}/cmake/Module.tmp ${PROJECT_SOURCE_DIR}/${MODULE}/CMakeLists.txt @ONLY)
188 add_custom_target(${MODULE}-all ALL)
529f129e 189 add_custom_target(${MODULE}-all-static)
6db31708 190 add_dependencies(alilibs-static "${MODULE}-static")
191 add_subdirectory(${MODULE})
6db31708 192endforeach(MODULE)
193
c3b22277 194if(DATE_FOUND AND AMORE_FOUND)
195 include (CMakeDA)
196endif(DATE_FOUND AND AMORE_FOUND)
197
6db31708 198#--------------------------------------------------------------------------------#
199# Additional Targets #
200#--------------------------------------------------------------------------------#
201
202include (InstallRequiredSystemLibraries)
203include (CPack)
e969a926 204