bugfix
[u/mrichter/AliRoot.git] / CMakeLists.txt
... / ...
CommitLineData
1# -*- mode: cmake -*-
2
3# Check if cmake has the required version
4Cmake_Minimum_Required(VERSION 2.6 FATAL_ERROR)
5
6# Set name of our project to AliRoot. To be done after check of cmake version
7Project(AliRoot NONE)
8
9# Set AliRoot variables
10Set(ALICE_ROOT $ENV{ALICE_ROOT})
11Set(ALICE $ENV{ALICE})
12Set(ALICE_STATIC_BUILD OFF CACHE BOOL "Build also statics libs")
13
14MESSAGE("ALICE_ROOT: ${ALICE_ROOT}")
15Set(CMAKE_VERBOSE_MAKEFILE ON)
16
17# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/
18SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
19SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
20Set(CMAKE_MODULE_PATH "${ALICE_ROOT}/cmake/modules")
21
22# To fix a hack that has been introduced for the Mac
23If(APPLE)
24 Set(CMAKE_INSTALL_NAME_TOOL CMAKE_INSTALL_NAME_TOOL-NOTFOUND)
25Endif(APPLE)
26
27# Setup ROOT
28Find_package(ROOT 5.0.0 REQUIRED)
29
30Set(CMAKE_C_COMPILER $ENV{CC})
31Enable_Language(C)
32
33Set(CMAKE_CXX_COMPILER $ENV{CXX})
34Enable_Language(CXX)
35
36Set(CMAKE_Fortran_COMPILER $ENV{F77})
37Enable_Language(Fortran)
38
39# Load some basic macros which are needed later on
40#Include(WriteConfigFile)
41Include(Dart)
42Include(ALICEMacros)
43
44# Check if the user wants to build the project in the source directory
45Check_out_of_Source_Build()
46
47# searches for needed packages
48
49Set(ALIROOT_INSTALL_DIR ${ALICE_ROOT}/${ALICE_TARGET})
50
51# Setup GEANT3
52Find_package(GEANT3 REQUIRED)
53
54# Setup RuleChecker
55Find_Package(RuleChecker)
56
57# Check if DATE is installed
58Find_Package(DATE)
59
60# Setup system dependent flags
61SetupSystem()
62
63
64Option(GENERATE_FILES "Generate CMake input files from package files" OFF)
65if(GENERATE_FILES)
66 Include(CreateSubCMakeFiles)
67 CreateSubCMakeFiles()
68endif(GENERATE_FILES)
69
70# Set the library version in the main CMakeLists.txt
71SET(ALIROOT_MAJOR_VERSION 0)
72SET(ALIROOT_MINOR_VERSION 0)
73SET(ALIROOT_PATCH_VERSION 0)
74SET(ALIROOT_VERSION "${ALIROOT_MAJOR_VERSION}.${ALIROOT_MINOR_VERSION}.${ALIROOT_PATCH_VERSION}")
75SET(ALIROOT_LIBRARY_PROPERTIES ${ALIROOT_LIBRARY_PROPERTIES}
76 VERSION "${ALIROOT_VERSION}"
77 SOVERSION "${ALIROOT_MAJOR_VERSION}"
78 SUFFIX ".so"
79)
80
81# Set version variables
82Find_program( READLINK_PROGRAM readlink)
83
84If(READLINK_PROGRAM)
85 Execute_process(COMMAND readlink -f ${ALICE_ROOT}
86 COMMAND xargs svn info
87 OUTPUT_VARIABLE _svn_out)
88Else(READLINK_PROGRAM)
89 Execute_process(COMMAND svn info ${ALICE_ROOT}
90 OUTPUT_VARIABLE _svn_out)
91Endif(READLINK_PROGRAM)
92
93String(REGEX REPLACE "^.*Revision: ([^\n]*).*$" "\\1"
94 ALIROOT_SVN_REVISION ${_svn_out})
95String(REGEX REPLACE "^.*URL: https://alisoft.cern.ch/AliRoot/([^\n]*).*$" "w \\1"
96 ALIROOT_SVN_BRANCH ${_svn_out})
97String(REPLACE "/" "\\\\/"
98 ALIROOT_SVN_BRANCH ${ALIROOT_SVN_BRANCH})
99
100# Additional targets
101Add_Custom_Target(check-all COMMENT "Checking coding conventions")
102
103# Configure special include file
104# Only if there is a change in the file
105If(UNIX)
106 Set(_in ${CMAKE_CURRENT_SOURCE_DIR}/STEER/ARVersion.h.in)
107 Set(_out ${CMAKE_CURRENT_BINARY_DIR}/STEER/ARVersion.h)
108 If(NOT EXISTS ${_out})
109 Add_custom_target(ARversion ALL
110 COMMAND sed < ${_in}
111 -e "s/\\@ALIROOT_SVN_REVISION\\@/${ALIROOT_SVN_REVISION}/"
112 -e "s/\\@ALIROOT_SVN_BRANCH\\@/${ALIROOT_SVN_BRANCH}/"
113 -e "s/\\@ALIROOT_VERSION\\@/${ALIROOT_VERSION}/" > ${_out})
114 Install(FILES ${_out} DESTINATION ${ALIROOT_INSTALL_DIR}/include)
115 Else(NOT EXISTS ${_out})
116 FILE(READ "${_out}" contents)
117 STRING(REGEX REPLACE ";" "\\\\;" contents "${contents}")
118 STRING(REGEX REPLACE "\n" ";" contents "${contents}")
119 Foreach(line ${contents})
120 If(line MATCHES "^.*ALIROOT_SVN_REVISION.*$")
121 STRING(REGEX REPLACE "^.*ALIROOT_SVN_REVISION[ ](.*)$" "\\1" _result_svn_rev "${line}")
122 EndIf(line MATCHES "^.*ALIROOT_SVN_REVISION.*$")
123 If(line MATCHES "^.*ALIROOT_SVN_BRANCH.*$")
124 STRING(REGEX REPLACE "^.*ALIROOT_SVN_BRANCH[ ]\"(.*)\"$" "\\1" _result_svn_branch "${line}")
125 EndIf(line MATCHES "^.*ALIROOT_SVN_BRANCH.*$")
126 If(line MATCHES "^.*ALIROOT_VERSION.*$")
127 STRING(REGEX REPLACE "^.*ALIROOT_VERSION[ ](.*)$" "\\1" _result_aliroot_version "${line}")
128 EndIf(line MATCHES "^.*ALIROOT_VERSION.*$")
129 EndForeach(line ${contents})
130 If(_result_aliroot_version STREQUAL ${ALIROOT_VERSION} AND _result_svn_rev STREQUAL ${ALIROOT_SVN_REVISION} AND _result_svn_branch STREQUAL ${ALIROOT_SVN_BRANCH})
131# MESSAGE("VERSION: ${_result_aliroot_version}")
132# MESSAGE("VERSION: ${ALIROOT_VERSION}")
133# MESSAGE("REVISION: ${_result_svn_rev}")
134# MESSAGE("REVISION: ${ALIROOT_SVN_REVISION}")
135# MESSAGE("BRANCH: ${_result_svn_branch}")
136# MESSAGE("BRANCH: ${ALIROOT_SVN_BRANCH}")
137 Else(_result_aliroot_version STREQUAL ${ALIROOT_VERSION} AND _result_svn_rev STREQUAL ${ALIROOT_SVN_REVISION} AND _result_svn_branch STREQUAL ${ALIROOT_SVN_BRANCH})
138 Add_custom_target(ARversion ALL
139 COMMAND sed < ${_in}
140 -e "s/\\@ALIROOT_SVN_REVISION\\@/${ALIROOT_SVN_REVISION}/"
141 -e "s/\\@ALIROOT_SVN_BRANCH\\@/${ALIROOT_SVN_BRANCH}/"
142 -e "s/\\@ALIROOT_VERSION\\@/${ALIROOT_VERSION}/" > ${_out})
143 Install(FILES ${_out} DESTINATION ${ALIROOT_INSTALL_DIR}/include)
144 EndIf(_result_aliroot_version STREQUAL ${ALIROOT_VERSION} AND _result_svn_rev STREQUAL ${ALIROOT_SVN_REVISION} AND _result_svn_branch STREQUAL ${ALIROOT_SVN_BRANCH})
145 EndIf(NOT EXISTS ${_out})
146
147Endif(UNIX)
148
149# This would work, but just once... we want this to happen at every make
150# Configure_file(${CMAKE_CURRENT_SOURCE_DIR}/STEER/ARVersion.h.in
151#${CMAKE_CURRENT_BINARY_DIR}/STEER/ARVersion.h @ONLY)
152
153# Recurse into the given subdirectories. This does not actually
154# cause another cmake executable to run. The same process will walk through
155# the project's entire directory structure.
156
157#Add_subdirectory(PYTHIA8)
158#Add_subdirectory(TFluka)
159#Add_subdirectory(THydjet)
160
161Add_subdirectory(ACORDE)
162Add_subdirectory(ANALYSIS)
163Add_subdirectory(BCM)
164Add_subdirectory(CORRFW)
165Add_subdirectory(DPMJET)
166Add_subdirectory(EMCAL)
167Add_subdirectory(EPOS)
168Add_subdirectory(ESDCheck)
169Add_subdirectory(EVE)
170Add_subdirectory(EVGEN)
171Add_subdirectory(FASTSIM)
172Add_subdirectory(FMD)
173Add_subdirectory(HERWIG)
174Add_subdirectory(HIJING)
175Add_subdirectory(HLT)
176Add_subdirectory(HMPID)
177Add_subdirectory(ITS)
178Add_subdirectory(JETAN)
179Add_subdirectory(LHAPDF)
180Add_subdirectory(LHC)
181Add_subdirectory(MICROCERN)
182Add_subdirectory(MONITOR)
183Add_subdirectory(MUON)
184Add_subdirectory(PHOS)
185Add_subdirectory(PMD)
186Add_subdirectory(PWG0)
187Add_subdirectory(PWG1)
188Add_subdirectory(PWG2)
189Add_subdirectory(PWG3)
190Add_subdirectory(PWG4)
191Add_subdirectory(PYTHIA6)
192Add_subdirectory(RALICE)
193Add_subdirectory(RAW)
194Add_subdirectory(STAT)
195Add_subdirectory(STEER)
196Add_subdirectory(STRUCT)
197Add_subdirectory(T0)
198Add_subdirectory(TDPMjet)
199Add_subdirectory(TEPEMGEN)
200Add_subdirectory(THbtp)
201Add_subdirectory(THerwig)
202Add_subdirectory(THijing)
203#Add_subdirectory(TIsajet)
204Add_subdirectory(TOF)
205Add_subdirectory(TPC)
206Add_subdirectory(TPHIC)
207Add_subdirectory(TRD)
208Add_subdirectory(TRIGGER)
209Add_subdirectory(TTherminator)
210Add_subdirectory(TUHKMgen)
211Add_subdirectory(VZERO)
212Add_subdirectory(ZDC)
213#
214Add_subdirectory(ALIROOT)
215