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 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--copy-dt-needed-entries" ) |
35 |
|
36 |
# Mute compile warnings (i.e. remove the -Wsomething compiler options). |
37 |
# Warnigns can be shown by adding -DPAMVMC_SHOW_WARNINGS=1 to the invocation of cmake. |
38 |
if(NOT "${PAMVMC_SHOW_WARNINGS}" STREQUAL "1") |
39 |
string(REPLACE " -Wall" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
40 |
string(REPLACE " -W " "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
41 |
string(REPLACE " -Wno-non-virtual-dtor" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
42 |
string(REPLACE " -Wno-long-long" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
43 |
string(REPLACE " -Wwrite-strings" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
44 |
string(REPLACE " -Wpointer-arith" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
45 |
string(REPLACE " -Woverloaded-virtual" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
46 |
string(REPLACE " -Wno-variadic-macros" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
47 |
string(REPLACE " -Wshadow" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) |
48 |
endif() |
49 |
|
50 |
# Enable compilation of Fortran code |
51 |
enable_language(Fortran) |
52 |
|
53 |
##### PamVMC build |
54 |
# Include PamVMC directories |
55 |
include_directories(. |
56 |
include |
57 |
cal/include |
58 |
trk/include |
59 |
trk/include/f77 |
60 |
tof/include |
61 |
ac/include |
62 |
s4/include |
63 |
nd/include |
64 |
PamG4RunConfiguration |
65 |
PamG4RunConfiguration/include |
66 |
) |
67 |
|
68 |
# Build PamG4RunConfiguration library |
69 |
root_generate_dictionary(PamG4RunConfigurationDict |
70 |
PamG4RunConfiguration/include/PamG4RunConfiguration.h |
71 |
LINKDEF PamG4RunConfiguration/include/PamG4RunConfigurationLinkDef.h |
72 |
) |
73 |
add_library(PamG4RunConfiguration SHARED |
74 |
PamG4RunConfiguration/src/PamG4RegionConstruction.cxx |
75 |
PamG4RunConfiguration/src/PamG4RunConfiguration.cxx |
76 |
PamG4RunConfigurationDict.cxx |
77 |
) |
78 |
|
79 |
# Build PamVMC_fc library |
80 |
file(GLOB HDR RELATIVE ${CMAKE_SOURCE_DIR} "include/*.h") |
81 |
list(REMOVE_ITEM HDR "include/PamVMC_fcLinkDef.h") |
82 |
file(GLOB AC_HDR RELATIVE ${CMAKE_SOURCE_DIR} "ac/include/*.h") |
83 |
file(GLOB CAL_HDR RELATIVE ${CMAKE_SOURCE_DIR} "cal/include/*.h") |
84 |
file(GLOB ND_HDR RELATIVE ${CMAKE_SOURCE_DIR} "nd/include/*.h") |
85 |
file(GLOB S4_HDR RELATIVE ${CMAKE_SOURCE_DIR} "s4/include/*.h") |
86 |
file(GLOB TRK_HDR RELATIVE ${CMAKE_SOURCE_DIR} "trk/include/*.h") |
87 |
file(GLOB TOF_HDR RELATIVE ${CMAKE_SOURCE_DIR} "tof/include/*.h") |
88 |
|
89 |
root_generate_dictionary(PamVMC_fcDict |
90 |
${HDR} |
91 |
${AC_HDR} |
92 |
${CAL_HDR} |
93 |
${ND_HDR} |
94 |
${S4_HDR} |
95 |
${TRK_HDR} |
96 |
${TOF_HDR} |
97 |
LINKDEF include/PamVMC_fcLinkDef.h |
98 |
) |
99 |
|
100 |
file(GLOB SRC "src/*.cxx") |
101 |
file(GLOB AC_SRC "ac/src/*.cxx") |
102 |
file(GLOB CAL_SRC "cal/src/*.cxx") |
103 |
file(GLOB ND_SRC "nd/src/*.cxx") |
104 |
file(GLOB S4_SRC "s4/src/*.cxx") |
105 |
file(GLOB TRK_SRC "trk/src/*.cxx") |
106 |
file(GLOB TRK_FSRC "trk/src/f77/*.F") |
107 |
file(GLOB TOF_SRC "tof/src/*.cxx") |
108 |
|
109 |
set(PamVMC_fc_SOURCE |
110 |
${SRC} |
111 |
${AC_SRC} |
112 |
${CAL_SRC} |
113 |
${ND_SRC} |
114 |
${S4_SRC} |
115 |
${TRK_SRC} |
116 |
${TRK_FSRC} |
117 |
${TOF_SRC} |
118 |
PamVMC_fcDict.cxx |
119 |
) |
120 |
|
121 |
|
122 |
add_library(PamVMC_fc SHARED ${PamVMC_fc_SOURCE}) |
123 |
|
124 |
# Build PamVMC.exe |
125 |
link_directories($ENV{PAM_LIB}) |
126 |
add_executable(PamVMC.exe G4main/PamVMCmain.cxx) |
127 |
target_link_libraries(PamVMC.exe |
128 |
PamVMC_fc |
129 |
PamG4RunConfiguration |
130 |
${ROOT_LIBRARIES} |
131 |
XMLParser |
132 |
${Geant4VMC_LIBRARIES} |
133 |
yoda |
134 |
DarthVader |
135 |
gfortran |
136 |
) |
137 |
|
138 |
###### Install rules |
139 |
install(TARGETS PamVMC.exe DESTINATION bin) |
140 |
install(TARGETS PamVMC_fc PamG4RunConfiguration DESTINATION lib) |