1 |
project(PamVMC) |
2 |
cmake_minimum_required(VERSION 2.6) |
3 |
|
4 |
###### Find external packages |
5 |
# ROOT |
6 |
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR} ${CMAKE_MODULE_PATH}) |
7 |
find_package(ROOT REQUIRED) |
8 |
include_directories(${ROOT_INCLUDE_DIR}) |
9 |
|
10 |
# GEANT4 |
11 |
find_package(Geant4 REQUIRED) |
12 |
include(${Geant4_USE_FILE}) |
13 |
|
14 |
# VGM |
15 |
find_package(VGM REQUIRED) |
16 |
|
17 |
# GEANT4VMC |
18 |
find_package(Geant4VMC REQUIRED) |
19 |
include_directories(${Geant4VMC_INCLUDE_DIRS}) |
20 |
|
21 |
# PAMELA software include directories |
22 |
include_directories($ENV{PAM_INC} $ENV{PAM_INC}/yoda) |
23 |
|
24 |
###### Adjust configuration |
25 |
# Some compiler options have been set by external packages e.g. Geant4. |
26 |
|
27 |
# Remove the -pedantic compiler option introduced by Geant4. |
28 |
# This is necessary in order to avoid to trigger an error when initializing static const float |
29 |
# variables (e.g. trk/include/PamVMCTrkDig.h:97) |
30 |
string(REPLACE " -pedantic" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
31 |
|
32 |
# Automatically recurse over linked linbraries. |
33 |
# For binutils >= 2.22 (http://unix.derkeiler.com/Mailing-Lists/FreeBSD/current/2011-12/msg00257.html) |
34 |
execute_process( |
35 |
COMMAND ld -v |
36 |
OUTPUT_VARIABLE LD_VERSION_LONG |
37 |
OUTPUT_STRIP_TRAILING_WHITESPACE) |
38 |
string(REGEX MATCH "[0-9]*\\.[0-9]*" LD_VERSION ${LD_VERSION_LONG}) |
39 |
if(NOT ${LD_VERSION} STRLESS "2.22") |
40 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--copy-dt-needed-entries" ) |
41 |
endif() |
42 |
|
43 |
# Mute compile warnings (i.e. remove the -Wsomething compiler options). |
44 |
# Warnigns can be shown by adding -DPAMVMC_SHOW_WARNINGS=1 to the invocation of cmake. |
45 |
if(NOT "${PAMVMC_SHOW_WARNINGS}" STREQUAL "1") |
46 |
string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
47 |
string(REPLACE " -W " "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
48 |
string(REPLACE " -Wno-non-virtual-dtor" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
49 |
string(REPLACE " -Wno-long-long" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
50 |
string(REPLACE " -Wwrite-strings" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
51 |
string(REPLACE " -Wpointer-arith" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
52 |
string(REPLACE " -Woverloaded-virtual" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
53 |
string(REPLACE " -Wno-variadic-macros" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
54 |
string(REPLACE " -Wshadow" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
55 |
endif() |
56 |
|
57 |
# Enable compilation of Fortran code |
58 |
enable_language(Fortran) |
59 |
|
60 |
##### PamVMC build |
61 |
# Include PamVMC directories |
62 |
include_directories(. |
63 |
include |
64 |
cal/include |
65 |
trk/include |
66 |
trk/include/f77 |
67 |
tof/include |
68 |
ac/include |
69 |
s4/include |
70 |
nd/include |
71 |
PamG4RunConfiguration |
72 |
PamG4RunConfiguration/include |
73 |
) |
74 |
|
75 |
# Build PamG4RunConfiguration library |
76 |
root_generate_dictionary(PamG4RunConfigurationDict |
77 |
PamG4RunConfiguration/include/PamG4RunConfiguration.h |
78 |
LINKDEF PamG4RunConfiguration/include/PamG4RunConfigurationLinkDef.h |
79 |
) |
80 |
add_library(PamG4RunConfiguration SHARED |
81 |
PamG4RunConfiguration/src/PamG4RegionConstruction.cxx |
82 |
PamG4RunConfiguration/src/PamG4RunConfiguration.cxx |
83 |
PamG4RunConfigurationDict.cxx |
84 |
) |
85 |
|
86 |
# Build PamVMC_fc library |
87 |
file(GLOB HDR RELATIVE ${CMAKE_SOURCE_DIR} "include/*.h") |
88 |
list(REMOVE_ITEM HDR "include/PamVMC_fcLinkDef.h") |
89 |
file(GLOB AC_HDR RELATIVE ${CMAKE_SOURCE_DIR} "ac/include/*.h") |
90 |
file(GLOB CAL_HDR RELATIVE ${CMAKE_SOURCE_DIR} "cal/include/*.h") |
91 |
file(GLOB ND_HDR RELATIVE ${CMAKE_SOURCE_DIR} "nd/include/*.h") |
92 |
file(GLOB S4_HDR RELATIVE ${CMAKE_SOURCE_DIR} "s4/include/*.h") |
93 |
file(GLOB TRK_HDR RELATIVE ${CMAKE_SOURCE_DIR} "trk/include/*.h") |
94 |
file(GLOB TOF_HDR RELATIVE ${CMAKE_SOURCE_DIR} "tof/include/*.h") |
95 |
|
96 |
root_generate_dictionary(PamVMC_fcDict |
97 |
${HDR} |
98 |
${AC_HDR} |
99 |
${CAL_HDR} |
100 |
${ND_HDR} |
101 |
${S4_HDR} |
102 |
${TRK_HDR} |
103 |
${TOF_HDR} |
104 |
LINKDEF include/PamVMC_fcLinkDef.h |
105 |
) |
106 |
|
107 |
file(GLOB SRC "src/*.cxx") |
108 |
file(GLOB AC_SRC "ac/src/*.cxx") |
109 |
file(GLOB CAL_SRC "cal/src/*.cxx") |
110 |
file(GLOB ND_SRC "nd/src/*.cxx") |
111 |
file(GLOB S4_SRC "s4/src/*.cxx") |
112 |
file(GLOB TRK_SRC "trk/src/*.cxx") |
113 |
file(GLOB TRK_FSRC "trk/src/f77/*.F") |
114 |
file(GLOB TOF_SRC "tof/src/*.cxx") |
115 |
|
116 |
set(PamVMC_fc_SOURCE |
117 |
${SRC} |
118 |
${AC_SRC} |
119 |
${CAL_SRC} |
120 |
${ND_SRC} |
121 |
${S4_SRC} |
122 |
${TRK_SRC} |
123 |
${TRK_FSRC} |
124 |
${TOF_SRC} |
125 |
PamVMC_fcDict.cxx |
126 |
) |
127 |
|
128 |
link_directories($ENV{PAM_LIB}) |
129 |
add_library(PamVMC_fc SHARED ${PamVMC_fc_SOURCE}) |
130 |
target_link_libraries(PamVMC_fc |
131 |
${ROOT_LIBRARIES} |
132 |
${Geant4VMC_LIBRARIES} |
133 |
XMLParser |
134 |
gfortran |
135 |
yoda |
136 |
DarthVader |
137 |
) |
138 |
|
139 |
# Build PamVMC.exe |
140 |
add_executable(PamVMC.exe G4main/PamVMCmain.cxx) |
141 |
target_link_libraries(PamVMC.exe |
142 |
PamVMC_fc |
143 |
PamG4RunConfiguration |
144 |
) |
145 |
|
146 |
# Build libPrimaryInfo.so |
147 |
include_directories(aux/spectra_generator/) |
148 |
root_generate_dictionary(PrimaryInfoDict |
149 |
aux/spectra_generator/PrimaryInfo.h |
150 |
LINKDEF aux/spectra_generator/LinkDef.h |
151 |
) |
152 |
add_library(PrimaryInfo SHARED PrimaryInfoDict.cxx) |
153 |
|
154 |
# Build sp_gen |
155 |
add_executable(sp_gen |
156 |
aux/spectra_generator/sp_gen.C |
157 |
) |
158 |
target_link_libraries(sp_gen |
159 |
${ROOT_LIBRARIES} |
160 |
PamVMC_fc |
161 |
yoda |
162 |
DarthVader |
163 |
) |
164 |
###### Install rules |
165 |
install(TARGETS PamVMC.exe sp_gen DESTINATION bin) |
166 |
install(TARGETS PamVMC_fc PamG4RunConfiguration PrimaryInfo DESTINATION lib) |
167 |
install(FILES config/g4config.in config/test.dtd config/g4Config.C config/g3Config.C DESTINATION config) |
168 |
file(GLOB auxFiles "aux/parameters_l*") |
169 |
set(auxFiles ${auxFiles} aux/CalibTrk_00110_000_000.root aux/resxy_new.root) |
170 |
install(FILES ${auxFiles} DESTINATION lib/tgt_$ENV{PLATFORM}) |