forked from HEP-FCC/FCCDetectors
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
58 lines (46 loc) · 2.44 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.15)
project(FCCDetectors)
include(GNUInstallDirs)
include(CTest)
# CMake variable setup------------------------------------------
# Default for install prefix
# ``-DCMAKE_INSTALL_PREFIX=<location>`` when invoking CMake
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/InstallArea/ CACHE PATH
"Install path prefix, prepended onto install directories." FORCE )
endif()
# Set up C++ Standard
# ``-DCMAKE_CXX_STANDARD=<standard>`` when invoking CMake
set(CMAKE_CXX_STANDARD 17 CACHE STRING "")
if(NOT CMAKE_CXX_STANDARD MATCHES "14|17|20")
message(FATAL_ERROR "Unsupported C++ standard: ${CMAKE_CXX_STANDARD}")
endif()
# Find CMake scripts
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
# Dependencies--------------------------------------------------
find_package(DD4hep)
# Environment for tests----------------------------------------
get_target_property(ddcore_lib DD4hep::DDCore LOCATION)
get_filename_component(ddcore_loc ${ddcore_lib} DIRECTORY)
function(k4_set_test_env _testname)
foreach(_subdir DetCommon DetFCCeeCLD DetFCCeeCommon DetFCCeeECalInclined DetFCCeeHCalTile DetFCCeeIDEA DetFCCeeIDEA-LAr DetFCChhBaseline1 DetFCChhCalDiscs DetFCChhECalInclined DetFCChhECalSimple DetFCChhHCalTile DetFCChhTailCatcher DetFCChhTrackerTkLayout DetSegmentation DetSensitive DetTrackerSimple)
set( _subdirs "${CMAKE_BINARY_DIR}/Detector/${_subdir}:${_subdirs}")
endforeach()
set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}:${CMAKE_CURRENT_BINARY_DIR}:${ddcore_loc}:${_subdirs}:$ENV{LD_LIBRARY_PATH}")
set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT "ROOT_INCLUDE_PATH=${ddcore_loc}/../include:$ENV{ROOT_INCLUDE_PATH}")
set_property(TEST ${_testname} APPEND PROPERTY ENVIRONMENT "DD4hepINSTALL=${ddcore_loc}/../")
endfunction()
# Setting RPATH ------------------------------------------------
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Subdirectories -----------------------------------------------
add_subdirectory(Detector)
# Installation and export --------------------------------------
install(FILES
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
)
install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE ${PROJECT_NAME}::
FILE "${PROJECT_NAME}Targets.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/"
)