Completely reengineered version of CMake build system (Johny)
[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
33set(CMAKE_MODULE_PATH "${ALICE_ROOT}/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
103set(EXCLUDEMODULES THydjet SHUTTLE)
104
105# Standard Modules
106# ------------------------------
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 THydjet PYTHIA8)
108
109# Additional Modules
110# ------------------------------
111list(APPEND ALIROOTMODULES TUHKMgen EPOS)
112
113# EVE
114# ------------------------------
115ALICE_RootConfig(EVE --has-opengl)
116if(NOT EVE STREQUAL "no")
117 list(APPEND ALIROOTMODULES EVE)
118endif(NOT EVE STREQUAL "no")
119
120# CERN Modules
121# ------------------------------
122set(CERNMODULES LHAPDF HIJING MICROCERN HERWIG)
123
124# Check for Pythia 6
125if(EXISTS ${ROOTINCDIR}/TPythia6.h)
126 set(PYTHIA6 TRUE)
127 list(APPEND CERNMODULES PYTHIA6 RALICE EVGEN)
128else()
129 message(FATAL_ERROR "Pythia6 is required !")
130endif(EXISTS ${ROOTINCDIR}/TPythia6.h)
131
132# Set Final list of modules
133set(MODULES ${ALIROOTMODULES} ${CERNMODULES} ALIROOT)
134
135# Set Module directories
136set(MODDIRS ${MODULES})
137
138# Libraries for Linking
139# ------------------------------
140set(ALILIBS MUON TPC PMD TRD FMD TOF ITS PHOS ACORDE HMPID VZERO ZDC STRUCT T0 EVGEN STEER TRIGGER)
141set(LIBS ${ROOTCLIBS} ${ROOTPLIBS} ${SYSLIBS})
142
143# Configure ARVerion.h
144# ------------------------------
145if(Subversion_FOUND)
146 Subversion_WC_INFO(${PROJECT_SOURCE_DIR} PROJECT)
147 set(ALIROOT_SVN_REVISION ${PROJECT_WC_REVISION})
148 set(ALIROOT_SVN_BRANCH ${PROJECT_WC_URL})
149 string(REGEX MATCH "[^/]+$" ALIROOT_SVN_BRANCH ${ALIROOT_SVN_BRANCH})
150 message(STATUS "Aliroot Revision - ${ALIROOT_SVN_REVISION} Branch - ${ALIROOT_SVN_BRANCH}")
151 if(EXISTS ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
152 file(REMOVE ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
153 endif(EXISTS ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h)
154 configure_file(${PROJECT_SOURCE_DIR}/cmake/ARVersion.h.tmp ${CMAKE_INCLUDE_EXPORT_DIRECTORY}/ARVersion.h @ONLY)
155endif(Subversion_FOUND)
156
157#--------------------------------------------------------------------------------#
158# Build Modules #
159#--------------------------------------------------------------------------------#
160
161# Module Variables
162# ------------------------------
163set(ALLLIBS)
164set(ALLEXECS)
165set(INCLUDEFILES)
166set(BINLIBS)
167set(EXPORTFILES)
168
169# Top Level Build Targets
170# ------------------------------
171
172add_custom_target(alilibs-static)
173add_custom_target(include-headers)
174
175# Add Modules
176# ------------------------------
177foreach(MODULE ${MODDIRS})
178 configure_file(${PROJECT_SOURCE_DIR}/cmake/Module.tmp ${PROJECT_SOURCE_DIR}/${MODULE}/CMakeLists.txt @ONLY)
179 add_custom_target(${MODULE}-all ALL)
180 add_custom_target(${MODULE}-static)
181 add_dependencies(alilibs-static "${MODULE}-static")
182 add_subdirectory(${MODULE})
183
184endforeach(MODULE)
185
186if(DATE_FOUND AND AMORE_FOUND)
187 include (CMakeDA)
188endif(DATE_FOUND AND AMORE_FOUND)
189
190#--------------------------------------------------------------------------------#
191# Additional Targets #
192#--------------------------------------------------------------------------------#
193
194include (InstallRequiredSystemLibraries)
195include (CPack)
e969a926 196