Back to home page

EIC code displayed by LXR

 
 

    


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

0001 cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR)
0002 
0003 project(IRT
0004   VERSION 1.0.5
0005   LANGUAGES CXX
0006 )
0007 
0008 cmake_policy(SET CMP0079 NEW) # allow `target_link_libraries` from any dir
0009 
0010 #----------------------------------------------------------------------------
0011 # options
0012 option(EVALUATION  "Build evaluation programs"                          OFF)
0013 option(DELPHES     "Delphes card production"                            ON)
0014 option(IRT_ROOT_IO "Generate dictionary for ROOT I/O of libIRT objects" ON)
0015 
0016 #----------------------------------------------------------------------------
0017 # dependencies
0018 
0019 list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
0020 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
0021 find_package(ROOT 6 REQUIRED COMPONENTS Core RIO Hist Tree)
0022 include(${ROOT_USE_FILE})
0023 
0024 #----------------------------------------------------------------------------
0025 # flags
0026 
0027 include(GNUInstallDirs) # standard GNU installation
0028 include(CheckCXXCompilerFlag)
0029 
0030 set(CMAKE_CXX_FLAGS "-std=c++0x")
0031 
0032 check_cxx_compiler_flag(-std=c++17 HAVE_FLAG_STD_CXX17)
0033 if(HAVE_FLAG_STD_CXX17)
0034   # Have -std=c++17, use it;    
0035   set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
0036 else()
0037   check_cxx_compiler_flag(-std=c++11 HAVE_FLAG_STD_CXX11)
0038   if(HAVE_FLAG_STD_CXX11)
0039     # Have -std=c++11, use it;  
0040     set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
0041   endif()
0042 endif()
0043 
0044 #----------------------------------------------------------------------------
0045 # IRT library
0046 
0047 # headers
0048 include_directories(
0049   ${PROJECT_SOURCE_DIR}/include 
0050   ${ROOT_INCLUDE_DIRS}
0051 )
0052 file(GLOB HEADERS ${PROJECT_SOURCE_DIR}/include/*.h)
0053 list(FILTER HEADERS EXCLUDE REGEX "LinkDef\\.h$")
0054 
0055 # sources
0056 set(IRT_SRC
0057   ${PROJECT_SOURCE_DIR}/source/SphericalSurface.cc
0058   ${PROJECT_SOURCE_DIR}/source/FlatSurface.cc
0059   ${PROJECT_SOURCE_DIR}/source/IRT.cc
0060   ${PROJECT_SOURCE_DIR}/source/ChargedParticle.cc
0061 )
0062 if(IRT_ROOT_IO)
0063   set(IRT_DICT G__${CMAKE_PROJECT_NAME})
0064   list(APPEND IRT_SRC ${IRT_DICT}.cxx)
0065 endif()
0066 
0067 # library target
0068 add_library(${CMAKE_PROJECT_NAME} SHARED ${IRT_SRC} )
0069 target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall -Wno-misleading-indentation)
0070 if(NOT IRT_ROOT_IO)
0071   # disable calling of `ClassDef` etc. if not generating ROOT dictionary
0072   message(STATUS "NOTE: disabling ROOT dictionary generation")
0073   target_compile_definitions(${CMAKE_PROJECT_NAME} PUBLIC DISABLE_ROOT_IO)
0074 endif()
0075 target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC
0076   $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
0077   $<INSTALL_INTERFACE:include>
0078 )
0079 
0080 # ROOT I/O dictionary generation
0081 if(IRT_ROOT_IO)
0082   set(IRT_ROOTMAP
0083     ${CMAKE_CURRENT_BINARY_DIR}/lib${CMAKE_PROJECT_NAME}_rdict.pcm
0084     ${CMAKE_CURRENT_BINARY_DIR}/lib${CMAKE_PROJECT_NAME}.rootmap
0085   )
0086   root_generate_dictionary(${IRT_DICT} ${HEADERS} LINKDEF include/irtLinkDef.h)
0087 endif()
0088 
0089 # linking
0090 target_link_libraries(${CMAKE_PROJECT_NAME} ROOT::Core ROOT::Physics)
0091 
0092 #----------------------------------------------------------------------------
0093 # optional targets
0094 
0095 if(EVALUATION)
0096   add_subdirectory(evaluation)
0097 endif()
0098 
0099 if(DELPHES)
0100   add_subdirectory(delphes)
0101 endif()
0102 
0103 #----------------------------------------------------------------------------
0104 # installation
0105 
0106 install(FILES
0107   ${HEADERS}
0108   DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
0109 )
0110 install(TARGETS ${CMAKE_PROJECT_NAME}
0111   EXPORT ${CMAKE_PROJECT_NAME}Targets
0112   LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
0113   ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
0114   RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
0115   INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}
0116 )
0117 if(IRT_ROOT_IO)
0118   install(FILES
0119     ${IRT_ROOTMAP}
0120     DESTINATION ${CMAKE_INSTALL_LIBDIR}
0121   )
0122 endif()
0123 
0124 #----------------------------------------------------------------------------
0125 # package config
0126 
0127 include(CMakePackageConfigHelpers)
0128 
0129 install(EXPORT ${CMAKE_PROJECT_NAME}Targets
0130   FILE ${CMAKE_PROJECT_NAME}Targets.cmake
0131   DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}
0132 )
0133 
0134 set(TARGETS_INSTALL_PATH ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}/${CMAKE_PROJECT_NAME}Targets.cmake)
0135 
0136 configure_package_config_file(
0137   cmake/${CMAKE_PROJECT_NAME}Config.cmake.in
0138   ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
0139   INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}
0140   PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR TARGETS_INSTALL_PATH
0141 )
0142 
0143 write_basic_package_version_file(
0144   "${CMAKE_PROJECT_NAME}ConfigVersion.cmake"
0145   VERSION ${VERSION}
0146   COMPATIBILITY SameMajorVersion
0147 )
0148 
0149 install(FILES
0150   ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
0151   ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake
0152   DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}
0153 )
0154