forked from ALLPix/allpix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
166 lines (140 loc) · 5.64 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
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(ALLPIX)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
# ROOT
include(FindROOT.cmake)
set(INCLUDE_DIRECTORIES
${ROOT_INCLUDE_DIR}
)
include_directories( ${INCLUDE_DIRECTORIES})
set(LINK_DIRECTORIES
${ROOT_LIBRARY_DIR}
)
link_directories( ${LINK_DIRECTORIES} )
#----------------------------------------------------------------------------
# Find Geant4 package, activating all available UI and Vis drivers by default
# You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui
# to build a batch mode only executable
#
option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
if(WITH_GEANT4_UIVIS)
find_package(Geant4 REQUIRED ui_all vis_all)
else()
find_package(Geant4 REQUIRED)
endif()
#----------------------------------------------------------------------------
# Find HepMC (required package)
#
find_package(HepMC REQUIRED)
#----------------------------------------------------------------------------
# Find ThePEG (required package)
#
find_package(ThePEG REQUIRED)
# Find Herwig (required package)
#
find_package(Herwig REQUIRED)
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
# Setup include directory for this project
#
include(${Geant4_USE_FILE})
#----------------------------------------------------------------------------
# Find Pythia8 (required package)
#
find_package(Pythia8 REQUIRED)
if(PYTHIA8_FOUND)
message(STATUS "G4 Examples: Pythia8 found. --> HepMCEx03 example with Pythia8 enabled.")
add_definitions(-DG4LIB_USE_PYTHIA8)
else()
message(STATUS "G4 Examples: Pythia8 -- NOT found.")
set(PYTHIA8_LIBRARY "")
set(PYTHIA8_HEPMC_LIBRARY "")
set(PYTHIA8_HAPDF_LIBRARY "")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-shadow -Wno-all")
#----------------------------------------------------------------------------
# Locate sources and headers for this project
# NB: headers are included so they will show up in IDEs
#
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include
${Geant4_INCLUDE_DIR}
${HEPMC_INCLUDE_DIR}
${PYTHIA8_INCLUDE_DIR}
${THEPEG_INCLUDE_DIR})
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/SelDict.cc ${PROJECT_SOURCE_DIR}/src/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
ROOT_GENERATE_DICTIONARY(HepMC include/HepMCG4Classes.hh LINKDEF include/HepMCG4LinkDef.h )
add_library(HepMCdict SHARED HepMC.cxx)
target_link_libraries(HepMCdict ${HEPMC_LIBRARIES} ${ROOT_LIBRARIES})
#----------------------------------------------------------------------------
# Add the executable, and link it to the Geant4 libraries
#
add_executable(allpix allpix.cc ${sources} ${headers})
target_link_libraries(allpix ${Geant4_LIBRARIES} ${HEPMC_LIBRARIES} ${THEPEG_LIBRARIES} ${HERWIG_LIBRARIES}
${PYTHIA8_LIBRARY}
${PYTHIA8_HEPMC_LIBRARY} ${PYTHIA8_HAPDF_LIBRARY}
HepMCdict ${ROOT_LIBRARIES})
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build B5. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
file(GLOB MACROLIST RELATIVE ${PROJECT_SOURCE_DIR} "macros/*.in")
file(GLOB GDMLLIST RELATIVE ${PROJECT_SOURCE_DIR} "models/*.gdml")
set(ALLPIX_SCRIPTS
${MACROLIST}
${GDMLLIST}
macros/oneDetector_vis.in
macros/mpx3rx_vis.in
macros/mpx3rx.in
models/pixeldetector.xml
models/clicpix_box_materials.xml
share/Erf.dat
share/GDML_EUDETAlHolder/EUDETAlHolder.gdml
share/GDML_EUDETAlHolder/EUDETAlHolder_materials.xml
)
foreach(_script ${ALLPIX_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
#----------------------------------------------------------------------------
# rootcling - dictionaries
#add_custom_target(TARGET rootcling PRE_BUILD
#COMMAND @echo "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
add_custom_target(rootcling_build ALL DEPENDS ALLPIX)
add_custom_command(TARGET rootcling_build PRE_BUILD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMAND rootcling -v0 -f SelDict.cc -c -p -I./include
AllPix_Hits_WriteToEntuple.h
AllPix_Frames_WriteToEntuple.h allpix_dm.h
AllPixDigitAnimation.hh LinkDef.h
COMMAND mv SelDict.cc ./src/SelDict.cc
COMMAND mv SelDict_rdict.pcm ${PROJECT_BINARY_DIR}/SelDict_rdict.pcm)
#rootcint -v0 -f SelDict.cc -c -p -I./include
# AllPix_Hits_WriteToEntuple.h
# AllPix_Frames_WriteToEntuple.h allpix_dm.h
# AllPixDigitAnimation.hh LinkDef.h)
#----------------------------------------------------------------------------
# Add program to the project targets
# (this avoids the need of typing the program name after make)
#
add_custom_target(ALLPIX DEPENDS allpix)
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS allpix DESTINATION bin)