]>
Commit | Line | Data |
---|---|---|
da32329d AM |
1 | ########################################################################### |
2 | # | |
3 | # Copyright 2010 | |
4 | # | |
5 | # This file is part of Starlight. | |
6 | # | |
7 | # Starlight is free software: you can redistribute it and/or modify | |
8 | # it under the terms of the GNU General Public License as published by | |
9 | # the Free Software Foundation, either version 3 of the License, or | |
10 | # (at your option) any later version. | |
11 | # | |
12 | # Starlight is distributed in the hope that it will be useful, | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
16 | # | |
17 | # You should have received a copy of the GNU General Public License | |
18 | # along with Starlight. If not, see <http://www.gnu.org/licenses/>. | |
19 | # | |
20 | ########################################################################### | |
21 | # | |
22 | # File and Version Information: | |
23 | # $Rev:: 165 $: revision of last commit | |
24 | # $Author:: odjuvsla $: author of last commit | |
25 | # $Date:: 2013-10-06 16:18:10 +0200 #$: date of last commit | |
26 | # | |
27 | # Description: | |
28 | # Starlight build file | |
29 | # | |
30 | # | |
31 | ########################################################################### | |
32 | ||
33 | ||
34 | # check if cmake has the required version | |
35 | cmake_minimum_required(VERSION 2.6.0 FATAL_ERROR) | |
36 | ||
37 | ||
38 | # set verbosity | |
39 | set(CMAKE_VERBOSE_MAKEFILE 0) # if set to 1 compile and link commands are displayed during build | |
40 | # the same effect can be achieved by calling 'make VERBOSE=1' | |
41 | ||
42 | ||
43 | # The version number. 9999 indicates trunk | |
44 | set (Starlight_VERSION_MAJOR 9999) | |
45 | set (Starlight_VERSION_MINOR 1) | |
46 | set (Starlight_VERSION_MINOR_MINOR 0) | |
47 | ||
48 | # define project | |
49 | project(starlight) | |
50 | find_package (Threads) | |
51 | ||
52 | ||
53 | # load some common cmake macros | |
54 | # set path, where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked | |
55 | ||
56 | message(STATUS "Using cmake module path '${CMAKE_MODULE_PATH}'") | |
57 | set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules ${CMAKE_MODULE_PATH}) | |
58 | message(STATUS "Using cmake module path '${CMAKE_MODULE_PATH}'") | |
59 | include(CommonMacros) | |
60 | ||
61 | ||
62 | # force out-of-source builds. | |
63 | enforce_out_of_source_build() | |
64 | ||
65 | ||
66 | # warn user if system is not UNIX | |
67 | if(NOT UNIX) | |
68 | message(FATAL_ERROR "This is an unsupported system.") | |
69 | endif() | |
70 | message(STATUS "Detected host system '${CMAKE_HOST_SYSTEM_NAME}' version '${CMAKE_HOST_SYSTEM_VERSION}' architecture '${CMAKE_HOST_SYSTEM_PROCESSOR}'") | |
71 | message(STATUS "Compiling for system '${CMAKE_SYSTEM_NAME}' version '${CMAKE_SYSTEM_VERSION}' architecture '${CMAKE_SYSTEM_PROCESSOR}'") | |
72 | ||
73 | option (CPP11 "Enable compilation with C++11 features" OFF) | |
74 | ||
75 | # define build types | |
76 | # set a default build type for single-configuration CMake generators, if no build type is set. | |
77 | set(CMAKE_BUILD_TYPE RELWITHDEBINFO) | |
78 | if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) | |
79 | message(STATUS "No build type was specified. Setting build type to 'Release'.") | |
80 | set(CMAKE_BUILD_TYPE Release) | |
81 | endif() | |
82 | # common compiler flags | |
83 | if (CMAKE_COMPILER_IS_GNUCC) | |
84 | execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) | |
85 | message(STATUS "GCC_VERSTION") | |
86 | message(STATUS ${GCC_VERSION}) | |
87 | if (GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6) | |
88 | message(STATUS "GCC_VERSION>=4.6") | |
89 | if(CPP11) | |
90 | set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror -Wno-error=unused-but-set-variable -Wno-error=unused-but-set-parameter -std=c++11") | |
91 | message(STATUS "Enabling usage of C++11 features") | |
92 | else() | |
93 | set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror -Wno-error=unused-but-set-variable -Wno-error=unused-but-set-parameter") | |
94 | endif() | |
95 | else() | |
96 | message(STATUS "GCC_VERSION<4.6") | |
45d54d9a | 97 | set(CMAKE_CXX_FLAGS "-Wall -Wextra ") |
da32329d AM |
98 | if(CPP11) |
99 | message(WARNING "C++11 feautures not supported for your compiler") | |
100 | endif() | |
101 | endif() | |
102 | else() | |
103 | message(STATUS "Not GCC") | |
45d54d9a | 104 | set(CMAKE_CXX_FLAGS "-Wall -Wextra") |
da32329d AM |
105 | if(CPP11) |
106 | message(WARNING "C++11 feautures not supported for your compiler") | |
107 | endif() | |
108 | endif() | |
109 | # flags for specific build types | |
110 | set(CMAKE_CXX_FLAGS_DEBUG "-g") | |
111 | set(CMAKE_CXX_FLAGS_RELEASE "-O3") | |
112 | set(CMAKE_CXX_LDFLAGS_DEBUG "-g") | |
113 | # report global build settings | |
114 | message(STATUS "Using CXX compiler '${CMAKE_CXX_COMPILER}'") | |
115 | message(STATUS "Using CXX general compiler flags '${CMAKE_CXX_FLAGS}'") | |
116 | foreach(_BUILD_TYPE "DEBUG" "MINSIZEREL" "RELEASE" "RELWITHDEBINFO") | |
117 | message(STATUS "Using CXX compiler flags '${CMAKE_CXX_FLAGS_${_BUILD_TYPE}}' for build type ${_BUILD_TYPE}") | |
118 | endforeach() | |
119 | message(STATUS "Build type is '${CMAKE_BUILD_TYPE}'") | |
120 | ||
121 | ||
122 | # redirect output files | |
123 | #set(LIBRARY_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/lib") | |
124 | message(STATUS "Using library output path '${LIBRARY_OUTPUT_PATH}'") | |
125 | #set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin") | |
126 | message(STATUS "Using executable output path '${EXECUTABLE_OUTPUT_PATH}'") | |
127 | ||
128 | ||
129 | # make CMAKE_SOURCE_DIR accessible in source code via predefined macro CMAKE_SOURCE_DIR | |
130 | if(CMAKE_SOURCE_DIR) | |
131 | add_definitions(-D'CMAKE_SOURCE_DIR=\"${CMAKE_SOURCE_DIR}\"') | |
132 | else() | |
133 | add_definitions(-D'CMAKE_SOURCE_DIR=\"\"') | |
134 | endif() | |
135 | ||
136 | ||
137 | # make SVN version string accessible in source code via predefined macro SVN_VERSION | |
138 | find_package(Subversion) | |
139 | if(Subversion_FOUND) | |
140 | # unfortunately CMAKE only parses 'svn info' | |
141 | find_program(SVNVERSION_EXECUTABLE | |
142 | svnversion | |
143 | ) | |
144 | if(NOT SVNVERSION_EXECUTABLE) | |
145 | message(STATUS "Could not find subversion command 'svnversion'. Repository version unknown.") | |
146 | else() | |
147 | execute_process( | |
148 | COMMAND ${SVNVERSION_EXECUTABLE} "${CMAKE_SOURCE_DIR}" | |
149 | OUTPUT_VARIABLE SVN_VERSION | |
150 | RESULT_VARIABLE _SVNVERSION_RETURN | |
151 | OUTPUT_STRIP_TRAILING_WHITESPACE) | |
152 | if(NOT ${_SVNVERSION_RETURN}) | |
153 | message(STATUS "Subversion repository revision is '${SVN_VERSION}'") | |
154 | else() | |
155 | message(STATUS "Error running 'svnversion'. Repository version unknown.") | |
156 | set(SVN_VERSION "") | |
157 | endif() | |
158 | endif() | |
159 | else() | |
160 | message(STATUS "Could not find subversion installation. Repository version unknown.") | |
161 | endif() | |
162 | if(SVN_VERSION) | |
163 | add_definitions(-D'SVN_VERSION=\"${SVN_VERSION}\"') | |
164 | else() | |
165 | add_definitions(-D'SVN_VERSION=\"\"') | |
166 | endif() | |
167 | ||
168 | ||
169 | # setup doxygen | |
170 | find_package(Doxygen) | |
171 | if(NOT DOXYGEN_FOUND) | |
172 | message(WARNING "Cannot find Doxygen. No HTML documentation will be generated.") | |
173 | else() | |
174 | set(DOXYGEN_TARGET "doxygen") | |
175 | set(DOXYGEN_DOC_DIR "${CMAKE_SOURCE_DIR}/doxygen") | |
176 | set(DOXYGEN_CONF "${CMAKE_SOURCE_DIR}/starlightDoxyfile.conf") | |
177 | message(STATUS "Run 'make ${DOXYGEN_TARGET}' to create Doxygen documentation files in '${DOXYGEN_DOC_DIR}'") | |
178 | add_custom_target(${DOXYGEN_TARGET} | |
179 | COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_CONF} | |
180 | DEPENDS ${DOXYGEN_CONF} | |
181 | WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | |
182 | ) | |
183 | endif() | |
184 | ||
185 | ||
186 | # setup Pythia 8 | |
187 | option (ENABLE_PYTHIA "Enable compilation against pythia (necessary for certain processes)" OFF) | |
188 | if(ENABLE_PYTHIA) | |
189 | find_package(Pythia8) | |
190 | if(PYTHIA8_FOUND) | |
191 | set(optionalLibs ${optionalLibs} ${PYTHIA8_LIBRARY}) | |
192 | find_package(LHAPDF REQUIRED) # implemented for dummy version in Pythia8 | |
193 | set(optionalLibs ${optionalLibs} ${LHAPDF_LIBRARIES}) | |
194 | option(ENABLE_PYTHIA "Should we use the Pythia8 library" ON) | |
195 | else() | |
196 | option(ENABLE_PYTHIA "Should we use the Pythia8 library" OFF) | |
197 | endif() | |
198 | endif() | |
199 | ||
200 | # setup Pythia 6 | |
201 | option (ENABLE_PYTHIA6 "Enable compilation against pythia 6 (necessary for certain processes)" OFF) | |
202 | if(ENABLE_PYTHIA6) | |
203 | find_package(Pythia6 REQUIRED) | |
204 | if(PYTHIA6_FOUND) | |
205 | set(optionalLibs ${optionalLibs} ${PYTHIA6_LIBRARY}) | |
206 | option (ENABLE_PYTHIA6 "Enable compilation against pythia 6 (necessary for certain processes)" ON) | |
207 | include_directories(pythia6) | |
208 | else(PYTHIA6_FOUND) | |
209 | option (ENABLE_PYTHIA6 "Enable compilation against pythia 6 (necessary for certain processes)" OFF) | |
210 | endif(PYTHIA6_FOUND) | |
211 | endif() | |
212 | ||
213 | # setup DPMJET | |
214 | option (ENABLE_DPMJET "Enable compilation against DPMJet" OFF) | |
215 | if(ENABLE_DPMJET) | |
216 | find_package(DPMJet REQUIRED) | |
217 | if(DPMJET_FOUND) | |
218 | option (ENABLE_DPMJET "Enable compilation against DPMJet" ON) | |
219 | else(DPMJET_FOUND) | |
220 | option (ENABLE_DPMJET "Enable compilation against DPMJet" OFF) | |
221 | endif(DPMJET_FOUND) | |
222 | endif(ENABLE_DPMJET) | |
223 | ||
224 | # setup TStarLight | |
225 | option (ENABLE_TSTARLIGHT "Enable ROOT interface for Starlight" OFF) | |
226 | if(ENABLE_TSTARLIGHT) | |
227 | find_package(ROOT REQUIRED) | |
228 | set(TSTARLIGHT_DICTIONARY ${CMAKE_CURRENT_BINARY_DIR}/TStarLight_dict.cxx) # set dictionary path | |
229 | root_generate_dictionary( | |
230 | "${TSTARLIGHT_DICTIONARY}" # path to dictionary to generate | |
231 | "${CMAKE_SOURCE_DIR}/TStarLight;${CMAKE_SOURCE_DIR}/include;${ROOT_INCLUDE_DIR};" # list of includes | |
232 | "${CMAKE_SOURCE_DIR}/TStarLight/TStarLight.h" # list of classes to process | |
233 | "${CMAKE_SOURCE_DIR}/TStarLight/TStarLightLinkDef.h" # ROOT linkDef file | |
234 | ) | |
235 | set(SOURCES_SL TStarLight/TStarLight.cxx ${TSTARLIGHT_DICTIONARY}) # append dictionary to sources | |
236 | endif(ENABLE_TSTARLIGHT) | |
237 | ||
238 | # set include directories | |
239 | set(INCLUDE_DIRECTORIES | |
240 | ${CMAKE_SOURCE_DIR}/include | |
241 | ${PROJECT_BINARY_DIR} | |
242 | # ${PYTHIA8_INCLUDE_DIR} | |
243 | ) | |
244 | ||
245 | if(ENABLE_TSTARLIGHT) | |
246 | set(INCLUDE_DIRECTORIES ${ROOT_INCLUDE_DIR} ${INCLUDE_DIRECTORIES}) | |
247 | endif(ENABLE_TSTARLIGHT) | |
248 | ||
249 | include_directories(${INCLUDE_DIRECTORIES}) | |
250 | ||
251 | # Set our source files, include the generated dictionary | |
252 | set(SOURCES | |
253 | src/bessel.cpp | |
254 | src/beam.cpp | |
255 | src/inputParameters.cpp | |
256 | src/beambeamsystem.cpp | |
257 | src/starlightparticle.cpp | |
258 | src/gammaaluminosity.cpp | |
259 | src/randomgenerator.cpp | |
260 | src/nucleus.cpp | |
261 | src/eventchannel.cpp | |
262 | src/gammaavm.cpp | |
263 | src/psifamily.cpp | |
264 | src/gammagammasingle.cpp | |
265 | src/photonNucleusCrossSection.cpp | |
266 | src/wideResonanceCrossSection.cpp | |
267 | src/narrowResonanceCrossSection.cpp | |
268 | src/readinluminosity.cpp | |
269 | src/twophotonluminosity.cpp | |
270 | src/gammagammaleptonpair.cpp | |
271 | src/starlight.cpp | |
272 | src/upcevent.cpp | |
273 | src/vector3.cpp | |
274 | src/lorentzvector.cpp | |
275 | src/filewriter.cpp | |
276 | src/eventfilewriter.cpp | |
277 | src/starlightparticlecodes.cpp | |
278 | src/starlightStandalone.cpp | |
279 | src/nBodyPhaseSpaceGen.cpp | |
280 | src/inputParser.cpp | |
281 | src/incoherentPhotonNucleusLuminosity.cpp | |
282 | src/incoherentVMCrossSection.cpp | |
283 | ) | |
284 | if(ENABLE_PYTHIA) | |
285 | set (SOURCES | |
286 | ${SOURCES} | |
287 | #src/PythiaStarlight.cpp | |
288 | src/pythiadecayer.cpp | |
289 | ) | |
290 | include_directories(${PYTHIA8_INCLUDE_DIR}) | |
291 | endif() | |
292 | if(ENABLE_PYTHIA6) | |
293 | set (SOURCES | |
294 | ${SOURCES} | |
295 | src/starlightpythia.cpp | |
296 | src/spectrum.cpp | |
297 | src/spectrumprotonnucleus.cpp | |
298 | ) | |
299 | endif() | |
300 | if(ENABLE_DPMJET) | |
301 | set (SOURCES | |
302 | ${SOURCES} | |
303 | src/starlightdpmjet.cpp | |
304 | src/spectrum.cpp | |
305 | src/spectrumprotonnucleus.cpp | |
306 | ) | |
307 | endif() | |
308 | ||
309 | # add Starlight library to the build system | |
310 | set(THIS_LIB "Starlib") | |
311 | add_library(${THIS_LIB} STATIC ${SOURCES}) | |
312 | ||
313 | if(ENABLE_TSTARLIGHT) | |
314 | ## build shared starlight library | |
315 | set(THIS_LIB "StarLight") | |
316 | add_library(${THIS_LIB} SHARED ${SOURCES}) | |
317 | include_directories(${INCLUDE_DIRECTORIES} ${CMAKE_SOURCE_DIR}/TStarLight ${ROOT_INCLUDE_DIR}) | |
318 | add_library(TStarLight SHARED ${SOURCES_SL}) | |
319 | endif(ENABLE_TSTARLIGHT) | |
320 | ||
321 | #make_shared_library("${THIS_LIB}" "${SOURCES}" | |
322 | # "${PYTHIA8_LIBRARY}" | |
323 | # "${LHAPDF_LIBRARIES}" | |
324 | #) | |
325 | ||
326 | if(ENABLE_DPMJET) | |
327 | enable_language(Fortran) | |
328 | set(DPMJET_LIB "DpmJetLib") | |
329 | message(STATUS "DPMJet objects: ${DPMJET_OBJECTS}") | |
330 | add_library(${DPMJET_LIB} STATIC dpmjet/dpmjetint.f ${DPMJET_OBJECTS}) | |
331 | set(optionalLibs ${optionalLibs} ${DPMJET_LIB}) | |
332 | endif() | |
333 | ||
334 | if(ENABLE_PYTHIA6) | |
335 | enable_language(Fortran) | |
336 | endif() | |
337 | ||
338 | # add starlight executable to the build system | |
339 | add_executable(starlight src/main.cpp) | |
340 | #target_link_libraries(starlight Starlib ${PYTHIA8_LIBRARY} ${LHAPDF_LIBRARIES} ${PYTHIA6_LIBRARY} ${DPMJET_LIB} ) | |
341 | target_link_libraries(starlight Starlib ${optionalLibs} ${CMAKE_THREAD_LIBS_INIT}) | |
342 | ||
343 | #make_executable(starlight src/main.cpp ${THIS_LIB}) | |
344 | ||
345 | configure_file ( | |
346 | "${PROJECT_SOURCE_DIR}/starlightconfig.h.in" | |
347 | "${PROJECT_BINARY_DIR}/starlightconfig.h" | |
348 | ) | |
349 | # Erase xsec values in case changes in code affects the xsec, executed during make process | |
350 | add_custom_command (TARGET Starlib POST_BUILD COMMAND touch ARGS slight.txt) | |
351 | add_custom_command (TARGET Starlib POST_BUILD COMMAND cp ARGS slight.txt slight.txt.bak) | |
352 | add_custom_command (TARGET Starlib POST_BUILD COMMAND echo ARGS '' > slight.txt ) | |
353 | ||
354 | ||
355 | message(STATUS "Cmake did not find any errors. run 'make' to build the project.") | |
356 | message(STATUS "On multi-core machines 'make -j#', where # is the number of parallel jobs, can speedup compilation considerably.") |