forked from key4hep/k4geo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
138 lines (102 loc) · 4.78 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
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
#---------------------------
set( PackageName k4geo )
#---------------------------
project(${PackageName})
# project version
SET( ${PackageName}_VERSION_MAJOR 0 )
SET( ${PackageName}_VERSION_MINOR 19 )
SET( ${PackageName}_VERSION_PATCH 0 )
SET( ${PackageName}_VERSION "${${PackageName}_VERSION_MAJOR}.${${PackageName}_VERSION_MINOR}" )
SET( ${PackageName}_SOVERSION "${${PackageName}_VERSION_MAJOR}.${${PackageName}_VERSION_MINOR}" )
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake )
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
include(GNUInstallDirs)
set(CMAKE_INSTALL_LIBDIR lib)
set(CMAKE_INSTALL_CMAKEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
#------------- set the default installation directory to be the source directory
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET( CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR} CACHE PATH
"install prefix path - overwrite with -D CMAKE_INSTALL_PREFIX = ..."
FORCE )
MESSAGE(STATUS "CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX} - overwrite with -D CMAKE_INSTALL_PREFIX" )
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
#---Options-------------------------------------------------------------------------
option(BUILD_TESTING "Enable and build tests" ON)
option(INSTALL_COMPACT_FILES "Copy compact files to install area" OFF)
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
find_package(DD4hep REQUIRED COMPONENTS DDRec DDG4 DDParsers)
# dd4hep_set_compiler_flags() expects DD4hep_SET_RPATH to be set to ON
# otherwise it will not set the rpath when installing
set(DD4HEP_SET_RPATH ON)
dd4hep_set_compiler_flags()
find_package ( ROOT REQUIRED COMPONENTS Geom GenVector)
message ( STATUS "ROOT_VERSION: ${ROOT_VERSION}" )
find_package( Geant4 REQUIRED )
find_package( LCIO REQUIRED)
add_subdirectory(detectorSegmentations)
add_subdirectory(detectorCommon)
file(GLOB sources
./detector/tracker/*.cpp
./detector/calorimeter/*.cpp
./detector/fcal/*.cpp
./detector/other/*.cpp
./detector/CaloTB/*.cpp
./FCalTB/setup/*.cpp
./plugins/LinearSortingPolicy.cpp
./detector/PID/ARC_geo_o1_v01.cpp
)
file(GLOB G4sources
./plugins/TPCSDAction.cpp
./plugins/CaloPreShowerSDAction.cpp
)
if(DD4HEP_USE_PYROOT)
ROOT_GENERATE_DICTIONARY(G__ILDEx ${headers} LINKDEF include/ROOT/LinkDef.h)
list(APPEND sources G__ILDEx.cxx)
endif()
add_dd4hep_plugin(${PackageName} SHARED ${sources})
add_dd4hep_plugin(${PackageName}G4 SHARED ${G4sources})
add_library(lcgeo ALIAS k4geo)
target_include_directories(${PackageName} PRIVATE ${PROJECT_SOURCE_DIR}/detector/include )
target_include_directories(${PackageName}G4 PRIVATE ${PROJECT_SOURCE_DIR}/detector/include )
target_link_libraries(${PackageName} DD4hep::DDCore DD4hep::DDRec DD4hep::DDParsers ROOT::Core LCIO::LCIO detectorSegmentations)
target_link_libraries(${PackageName}G4 DD4hep::DDCore DD4hep::DDRec DD4hep::DDParsers DD4hep::DDG4 ROOT::Core ${Geant4_LIBRARIES} LCIO::LCIO)
#Create this_package.sh file, and install
dd4hep_instantiate_package(${PackageName})
# Destination directories are hardcoded because GNUdirectories are not included
install(TARGETS ${PackageName} ${PackageName}G4
EXPORT ${PROJECT_NAME}Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT shlib
)
#---Testing-------------------------------------------------------------------------
if(BUILD_TESTING)
include(CTest)
add_subdirectory(lcgeoTests)
set(BUILDNAME "${CMAKE_SYSTEM}-${CMAKE_CXX_COMPILER}-${CMAKE_BUILD_TYPE}" CACHE STRING "set build string for cdash")
endif(BUILD_TESTING)
#--- install remaining targets--------------------------
FILE(GLOB hfiles "ILD/include/*.h")
INSTALL(FILES ${hfiles}
DESTINATION include/${PackageName}
)
#--- install compact files------------------------------
if(INSTALL_COMPACT_FILES)
INSTALL(DIRECTORY CaloTB CLIC FCalTB FCCee ILD fieldmaps SiD DESTINATION share/k4geo )
endif()
# create k4geoConfig and friends
INSTALL(EXPORT ${PROJECT_NAME}Targets
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_CMAKEDIR}
FILE k4geoConfig-targets.cmake)
include(CMakePackageConfigHelpers)
configure_package_config_file(cmake/k4geoConfig.cmake.in ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}/k4geoConfig.cmake
PATH_VARS CMAKE_INSTALL_CMAKEDIR
INSTALL_DESTINATION ${CMAKE_INSTALL_CMAKEDIR} )
write_basic_package_version_file(
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}/k4geoConfigVersion.cmake
VERSION ${${PackageName}_VERSION}
COMPATIBILITY SameMajorVersion )
install(FILES ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}/k4geoConfig.cmake
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}/k4geoConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_CMAKEDIR} )