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