-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
162 lines (105 loc) · 3.97 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
# BASIC DEFINITIONS ========================================================================
# define minimum version of cmake
cmake_minimum_required(VERSION 3.2)
# define project name and its language
project(EPIC CXX)
# define c++ standard and issue all the warning demanded by this standard
add_definitions(-pedantic -Wno-vla-extension)
set(CMAKE_CXX_STANDARD 14)
if (NOT DEFINED CMAKE_MACOSX_RPATH)
set(CMAKE_MACOSX_RPATH 0)
endif()
# VERSION ==================================================================================
# read file
file(READ ${CMAKE_SOURCE_DIR}/data/version.txt VERSION_STR)
# strip spaces
string(STRIP ${VERSION_STR} VERSION_STR)
# get major, minor and patch versions
string(REGEX MATCH "^[0-9]*\\." TMP_STR ${VERSION_STR})
string(REGEX REPLACE "\\." "" EPIC_VERSION_MAJOR ${TMP_STR})
string(REGEX MATCH "\\.[0-9]*\\." TMP_STR ${VERSION_STR})
string(REGEX REPLACE "\\." "" EPIC_VERSION_MINOR ${TMP_STR})
string(REGEX MATCH "\\.[0-9]*$" TMP_STR ${VERSION_STR})
string(REGEX REPLACE "\\." "" EPIC_VERSION_PATCH ${TMP_STR})
message("-- EPIC version is: " ${EPIC_VERSION_MAJOR} "." ${EPIC_VERSION_MINOR} "." ${EPIC_VERSION_PATCH})
# configure
configure_file(${CMAKE_SOURCE_DIR}/cmake/Version/EpicVersion.h_in ${CMAKE_SOURCE_DIR}/include/EpicVersion.h)
# AUTOMOC ==================================================================================
# tell cmake to run Qt moc when necessary
set(CMAKE_AUTOMOC ON)
# as moc files are generated in the binary dir, tell cmake to always look for includes there
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# FIND LIBRARIES ===========================================================================
# find libraries: additional modules
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# find libraries: Qt
find_package(Qt5 COMPONENTS Core Sql XmlPatterns)
if(${Qt5_FOUND})
find_package(Qt5Widgets)
message("-- Found Qt5: " ${Qt5Widgets_VERSION})
set(QT_LIBRARY_CORE "Qt5::Core")
set(QT_LIBRARY_SQL "Qt5::Sql")
set(QT_LIBRARY_XML "Qt5::XmlPatterns")
else()
find_package(Qt4 COMPONENTS QtCore QtSql QtXmlPatterns)
if(${Qt4_FOUND})
set(QT_LIBRARY_CORE "Qt4::QtCore")
set(QT_LIBRARY_SQL "Qt4::QtSql")
set(QT_LIBRARY_XML "Qt4::QtXmlPatterns")
else()
message(FATAL_ERROR "Neither Qt5 nor Qt4 found in this system")
endif()
endif()
# find libraries: gsl
find_package(GSL)
# find libraries: SFML
find_package(SFML COMPONENTS system REQUIRED)
# find libraries: ElementaryUtils
find_package(ElementaryUtils REQUIRED)
# find libraries: NumA++
find_package(NumA++ REQUIRED)
# find libraries: PARTONS
find_package(PARTONS REQUIRED)
# find libraries: Apfel++
find_package(Apfel++ REQUIRED)
# find libraries: Root
find_package(ROOT COMPONENTS Core Hist Minuit Foam REQUIRED)
# find libraries: HepMC3
find_package(HepMC3 REQUIRED)
foreach(HEPMC3_COMPONENT ${HEPMC3_COMPONENTS})
if(${HEPMC3_COMPONENT} STREQUAL "rootIO")
message("-- Found HEPMC3 root IO")
add_compile_definitions(WITH_HEPMC3ROOTIO)
endif()
endforeach()
# directories containing headers
include_directories(${GSL_INCLUDE_DIRS} ${QT_INCLUDE_DIRS} ${SFML_INCLUDE_DIR} ${ElementaryUtils_INCLUDE_DIR} ${NumA++_INCLUDE_DIR} ${PARTONS_INCLUDE_DIR} ${Apfel++_INCLUDE_DIR} ${ROOT_INCLUDE_DIRS} ${HEPMC3_INCLUDE_DIR})
# FINALIZE ==================================================================================
# generate list of source files
file(
GLOB_RECURSE
source_files
src/*
)
# define target executable
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin)
add_executable(
epic
${source_files}
)
# define libraries to be linked
target_link_libraries(
epic
${GSL_LIBRARIES}
${QT_LIBRARIES}
${SFML_LIBRARIES}
${ElementaryUtils_LIBRARIES}
${NumA++_LIBRARIES}
${PARTONS_LIBRARIES}
${Apfel++_LIBRARIES}
${ROOT_LIBRARIES}
${HEPMC3_LIBRARIES}
${QT_LIBRARY_CORE}
${QT_LIBRARY_SQL}
${QT_LIBRARY_XML}
)