Back to home page

EIC code displayed by LXR

 
 

    


Warning, /epic/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
0002 
0003 # CMP0074: find_package() uses <PackageName>_ROOT variables
0004 cmake_policy(SET CMP0074 NEW)
0005 
0006 PROJECT(epic
0007   LANGUAGES CXX
0008   DESCRIPTION "DD4hep Geometry Description of the EPIC Experiment"
0009   )
0010 
0011 # Set version based on git
0012 include(cmake/git_version.cmake)
0013 set_git_version(CMAKE_PROJECT_VERSION)
0014 
0015 # C++ standard
0016 set(CMAKE_CXX_STANDARD 17)
0017 set(CMAKE_CXX_STANDARD 17 CACHE STRING "Set the C++ standard to be used")
0018 if(NOT CMAKE_CXX_STANDARD MATCHES "17|20|23")
0019   message(FATAL_ERROR "Unsupported C++ standard: ${CMAKE_CXX_STANDARD}")
0020 endif()
0021 set(CMAKE_CXX_STANDARD_REQUIRED ON)
0022 set(CMAKE_CXX_EXTENSIONS OFF)
0023 
0024 # Build type
0025 if (NOT CMAKE_BUILD_TYPE)
0026   set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build type configuration" FORCE)
0027   message(STATUS "Setting default build type: ${CMAKE_BUILD_TYPE}")
0028 endif()
0029 
0030 # Error on all warnings
0031 if(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
0032   add_compile_options(-Wall -Wextra -Werror -pedantic)
0033 endif()
0034 
0035 # Export compile commands as json for run-clang-tidy
0036 set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
0037 
0038 # Install to the top directory by default
0039 if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
0040     set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/prefix CACHE PATH "Install in $src/prefix/ directory by default" FORCE)
0041 endif()
0042 
0043 # Install into GNU standard directories
0044 include(GNUInstallDirs)
0045 
0046 # Dependencies
0047 find_package(DD4hep 1.27 REQUIRED COMPONENTS DDCore DDRec)
0048 find_package(fmt REQUIRED)
0049 
0050 #-----------------------------------------------------------------------------------
0051 set(a_lib_name ${PROJECT_NAME})
0052 
0053 set(DD4HEP_SET_RPATH TRUE)
0054 dd4hep_configure_output(INSTALL ${CMAKE_INSTALL_PREFIX})
0055 dd4hep_set_compiler_flags()
0056 
0057 file(GLOB sources CONFIGURE_DEPENDS src/*.cpp)
0058 dd4hep_add_plugin(${a_lib_name}
0059   SOURCES ${sources}
0060   USES ROOT::Core ROOT::Gdml
0061   )
0062 target_link_libraries(${a_lib_name}
0063   PUBLIC DD4hep::DDCore DD4hep::DDRec fmt::fmt
0064   )
0065 
0066 #-----------------------------------------------------------------------------------
0067 # Parse jinja templates: once by default, and once for all yml files
0068 set(TEMPLATE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/templates)
0069 set(TEMPLATE_XML ${PROJECT_NAME}.xml.jinja2)
0070 
0071 file(GLOB CONFIG_YMLS ${CMAKE_CURRENT_SOURCE_DIR}/configurations/*.yml)
0072 foreach(config_yml ${CONFIG_YMLS})
0073     get_filename_component(config ${config_yml} NAME_WE)
0074     add_custom_target(${config}.xml ALL)
0075     add_custom_command(TARGET ${config}.xml
0076         COMMAND
0077             ${CMAKE_CURRENT_SOURCE_DIR}/bin/make_detector_configuration
0078                 --dir ${TEMPLATE_DIR}
0079                 --template ${TEMPLATE_XML}
0080                 --config ${config_yml}
0081                 --output ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_${config}.xml
0082         COMMENT "Creating configuration ${config} for ${PROJECT_NAME}"
0083         )
0084     install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_${config}.xml
0085         DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/
0086         )
0087 endforeach()
0088 
0089 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_full.xml
0090     DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/
0091     RENAME ${PROJECT_NAME}.xml
0092     )
0093 
0094 #-----------------------------------------------------------------------------------
0095 # Install the detector description files.
0096 install(DIRECTORY compact/
0097     DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/compact
0098     FILES_MATCHING PATTERN "*.xml" PATTERN "*.gdml"
0099     )
0100 
0101 #-----------------------------------------------------------------------------------
0102 # Install the detector calibration files.
0103 install(DIRECTORY calibrations/
0104     DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/calibrations
0105     )
0106 
0107 #-----------------------------------------------------------------------------------
0108 # Configure and install compact/version.xml
0109 #
0110 configure_file(templates/version.xml.in ${CMAKE_CURRENT_BINARY_DIR}/version.xml @ONLY)
0111 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/version.xml
0112     DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/compact
0113 )
0114 
0115 #-----------------------------------------------------------------------------------
0116 # Configure and install detector setup script
0117 #
0118 configure_file(templates/thisepic.sh.in ${CMAKE_CURRENT_BINARY_DIR}/thisepic.sh @ONLY)
0119 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/thisepic.sh
0120     DESTINATION ${CMAKE_INSTALL_BINDIR}
0121 )
0122 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/thisepic.sh
0123     DESTINATION ${CMAKE_INSTALL_PREFIX}
0124     RENAME setup.sh
0125 )
0126 
0127 # install programs
0128 install(PROGRAMS bin/g4MaterialScan_to_csv
0129   DESTINATION ${CMAKE_INSTALL_BINDIR}
0130 )