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