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