fix for mac
[u/mrichter/AliRoot.git] / CMakeLists.txt
1 # -*- mode: cmake -*-
2
3 # Check if cmake has the required version
4 cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
5
6 # Set name of our project to AliRoot. To be done after check of cmake version
7 project(AliRoot NONE)
8
9 # Set AliRoot variables
10 set(CMAKE_VERBOSE_MAKEFILES OFF)
11 #fix for MACOSX
12 SET(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem")
13 SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem") 
14
15 set(ALICE_INSTALL $ENV{ALICE_INSTALL})
16 set(ALICE_ROOT $ENV{ALICE_ROOT})
17 set(ALICE_STATIC_BUILD OFF CACHE BOOL "Build also statics libs")
18 execute_process(COMMAND root-config --arch OUTPUT_VARIABLE ALICE_TARGET)
19 string (REGEX REPLACE "\n" "" ALICE_TARGET ${ALICE_TARGET})
20
21 if(NOT ALICE_INSTALL)
22 message(FATAL_ERROR "Please set environment variable ALICE_INSTALL to the AliRoot installation directory")
23 endif(NOT ALICE_INSTALL)
24 if(NOT ALICE_ROOT)
25 message(FATAL_ERROR "Please set environment variable ALICE_ROOT to the AliRoot source directory")
26 endif(NOT ALICE_ROOT)
27
28
29 message("ALICE_ROOT: ${ALICE_ROOT}")
30
31
32 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ 
33 set(PROJECT_BINARY_DIR ${ALICE_INSTALL})
34 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin/tgt_${ALICE_TARGET})
35 set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib/tgt_${ALICE_TARGET})
36 set(CMAKE_MODULE_PATH "${ALICE_ROOT}/cmake/modules")
37
38 # To fix a hack that has been introduced for the Mac
39 if(APPLE)
40   set(CMAKE_INSTALL_NAME_TOOL CMAKE_INSTALL_NAME_TOOL-NOTFOUND)
41 endif(APPLE)
42
43 # Setup ROOT and C, C++ , Fortran Compilers
44 find_package(ROOT 5.0.0 REQUIRED)
45 set(CMAKE_C_COMPILER $ENV{CC})
46 enable_language(C)
47 set(CMAKE_CXX_COMPILER $ENV{CXX})
48 enable_language(CXX)
49 set(CMAKE_Fortran_COMPILER $ENV{F77})
50 enable_language(Fortran)
51
52 # Load some basic macros which are needed later on
53 #Include(WriteConfigFile)
54
55 include (CTest)
56 include(ALICEMacros)
57
58 # Check if the user wants to build the project in the source directory
59 Check_out_of_Source_Build()
60
61 # searches for needed packages
62
63 Set(ALIROOT_INSTALL_DIR ${ALICE_INSTALL}/${ALICE_TARGET})
64
65 # Setup GEANT3
66 find_package(GEANT3)
67
68 # Setup RuleChecker
69 find_package(RuleChecker)
70
71 # Check if DATE is installed
72 find_package(DATE)
73
74 # Setup system dependent flags 
75 SetupSystem()
76
77 Include(CreateSubCMakeFiles)
78 CreateSubCMakeFiles()
79
80
81 # Set the library version in the main CMakeLists.txt
82
83 set(ALIROOT_MAJOR_VERSION 0)
84 set(ALIROOT_MINOR_VERSION 0)
85 set(ALIROOT_PATCH_VERSION 0)
86 set(ALIROOT_VERSION "${ALIROOT_MAJOR_VERSION}.${ALIROOT_MINOR_VERSION}.${ALIROOT_PATCH_VERSION}")
87
88 set(ALIROOT_LIBRARY_PROPERTIES ${ALIROOT_LIBRARY_PROPERTIES}
89     VERSION "${ALIROOT_VERSION}"
90     SOVERSION "${ALIROOT_MAJOR_VERSION}"
91     SUFFIX ".so"
92 )
93
94 # Set version variables
95 find_program( READLINK_PROGRAM readlink)
96
97 if(READLINK_PROGRAM) 
98   execute_process(COMMAND readlink -f ${ALICE_ROOT} 
99     COMMAND xargs svn info
100     OUTPUT_VARIABLE _svn_out)
101 else(READLINK_PROGRAM)
102   execute_process(COMMAND svn info ${ALICE_ROOT} 
103     OUTPUT_VARIABLE _svn_out)
104 endif(READLINK_PROGRAM)
105
106 string(REGEX REPLACE "^.*Revision: ([^\n]*).*$" "\\1" 
107   ALIROOT_SVN_REVISION ${_svn_out})
108 string(REGEX REPLACE "^.*URL: ([^\n]*).*$" "\\1"
109   ALIROOT_SVN_BRANCH ${_svn_out})
110 string(REGEX REPLACE "^.*AliRoot/([^\n]*)" "\\1" ALIROOT_SVN_BRANCH ${ALIROOT_SVN_BRANCH})
111
112
113 # Additional targets
114 add_custom_target(check-all COMMENT "Checking coding conventions")
115 message(STATUS "REVISION: ${ALIROOT_SVN_REVISION}")
116 message(STATUS "BRANCH: ${ALIROOT_SVN_BRANCH}")
117
118 # Delete and recreate header ARVersion Header file 
119 execute_process(COMMAND cmake -E remove "${CMAKE_CURRENT_BINARY_DIR}/STEER/ARVersion.h")
120 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/STEER/ARVersion.h.in ${CMAKE_CURRENT_BINARY_DIR}/STEER/ARVersion.h @ONLY)
121
122 # Get list of enabled root features
123 execute_process(COMMAND root-config --features OUTPUT_VARIABLE FEATURES)
124 string(REGEX MATCH "pythia6" PYTHIA6 ${FEATURES})
125 string(REGEX MATCH "pythia8" PYTHIA8 ${FEATURES})
126 string(REGEX MATCH "opengl" OPENGL ${FEATURES})
127 if(PYTHIA6)
128   message(STATUS "Pythia6 enabled")
129 endif(PYTHIA6)
130 if(PYTHIA8)
131   message(STATUS "Pythia8 enabled")
132 endif(PYTHIA8)
133 if(OPENGL)
134   message(STATUS "OpenGL enabled")      
135 endif(OPENGL)   
136 option (TFLUKA "Build TFluka" OFF)
137 option (THYDJET "Build THydjet" OFF)
138 option (SHUTTLE "Build SHUTTLE" OFF)
139
140         
141 # Recurse into the given subdirectories.  This does not actually
142 # cause another cmake executable to run.  The same process will walk through
143 # the project's entire directory structure.
144 Add_subdirectory(STEER)
145 Add_subdirectory(PHOS) 
146 Add_subdirectory(TRD) 
147 Add_subdirectory(TPC)
148 Add_subdirectory(ZDC) 
149 Add_subdirectory(MUON) 
150 Add_subdirectory(PMD) 
151 Add_subdirectory(FMD)
152 Add_subdirectory(TOF) 
153 Add_subdirectory(ITS) 
154 Add_subdirectory(ACORDE) 
155 Add_subdirectory(HMPID) 
156 Add_subdirectory(T0) 
157 Add_subdirectory(BCM) 
158 Add_subdirectory(STRUCT) 
159 Add_subdirectory(EVGEN) 
160 Add_subdirectory(RALICE) 
161 Add_subdirectory(VZERO) 
162 Add_subdirectory(THijing)
163 Add_subdirectory(THbtp) 
164 Add_subdirectory(EMCAL) 
165 Add_subdirectory(THerwig) 
166 Add_subdirectory(TEPEMGEN) 
167 Add_subdirectory(FASTSIM) 
168 Add_subdirectory(TPHIC) 
169 Add_subdirectory(RAW) 
170 Add_subdirectory(MONITOR) 
171 Add_subdirectory(ANALYSIS) 
172 Add_subdirectory(JETAN)
173 Add_subdirectory(HLT) 
174 Add_subdirectory(LHC) 
175 Add_subdirectory(ESDCheck) 
176 Add_subdirectory(STAT) 
177 Add_subdirectory(TTherminator) 
178 Add_subdirectory(CORRFW) 
179 Add_subdirectory(DPMJET) 
180 Add_subdirectory(TDPMjet) 
181 Add_subdirectory(PWG0) 
182 Add_subdirectory(PWG1) 
183 Add_subdirectory(PWG2) 
184 Add_subdirectory(PWG3) 
185 Add_subdirectory(PWG4)
186 Add_subdirectory(TRIGGER) 
187 Add_subdirectory(TUHKMgen) 
188 Add_subdirectory(EPOS) 
189 if(PYTHIA8)
190 Add_subdirectory(PYTHIA8) 
191 endif(PYTHIA8)
192 if(OPENGL)
193 Add_subdirectory(EVE) 
194 endif(OPENGL)
195 if(TFLUKA)
196 Add_subdirectory(TFluka)
197 endif(TFLUKA)
198 if(THYDJET)     
199 Add_subdirectory(THydjet)
200 endif(THYDJET)
201 if(SHUTTLE)
202 Add_subdirectory(SHUTTLE)
203 endif(SHUTTLE)  
204 Add_subdirectory(LHAPDF) 
205 Add_subdirectory(HIJING) 
206 Add_subdirectory(MICROCERN) 
207 Add_subdirectory(HERWIG) 
208 if(PYTHIA6)
209 Add_subdirectory(PYTHIA6)
210 endif(PYTHIA6)
211 Add_subdirectory(ALIROOT)
212 add_subdirectory(test)
213 add_test ("Aliroot_executable" aliroot -q) 
214 #copy testing files
215 configure_file("CTestCustom.ctest" "${PROJECT_BINARY_DIRECTORY}" COPYONLY)