Back to home page

EIC code displayed by LXR

 
 

    


Warning, /geant4/examples/extended/geometry/vecGeomNavigation/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 cmake_minimum_required(VERSION 3.16...3.27)
0002 project(exampleVecGeomNav)
0003 
0004 option(WITH_ROOT "WITH ROOT SUPPORT" OFF)
0005 option(BUILTIN_G4VECGEOMNAV "Build G4VecGeomNav from source (requires VecGeom)" ON)
0006 
0007 find_package(Geant4 REQUIRED gdml)
0008 find_package(VecGeom REQUIRED)
0009 if(WITH_ROOT)
0010   find_package(ROOT REQUIRED)
0011   find_package(TGeo2VecGeom REQUIRED)
0012 endif()
0013 
0014 #-------------------------------------------------------------------
0015 ## Option to use built-in G4VecGeomNav
0016 ################################################################################
0017 # Minimum version of G4VecGeomNav we need.
0018 set(G4VecGeomNav_VERSION "") # 2021.06.18") # 0.1")
0019 
0020 if(BUILTIN_G4VECGEOMNAV)
0021   include(FetchContent)
0022 
0023   FetchContent_Declare(
0024     g4vecgeomnav
0025     GIT_REPOSITORY https://gitlab.cern.ch/VecGeom/g4vecgeomnav.git
0026     GIT_TAG master
0027   )
0028 
0029   FetchContent_GetProperties(g4vecgeomnav)
0030 
0031   # G4VecGeomNav builds a shared lib by default. As this links to Geant4 libs, if Geant4 is 
0032   # static-only, then we should also build G4VecGeomNav statically because:
0033   # - Geant4 static libs are not guaranteed to be PIC
0034   # - Geant4 symbols will be duplicated in g4vecgeomnav and the exampleVecGeomNac program
0035   if(Geant4_static_FOUND AND (NOT Geant4_shared_FOUND))
0036     set(BUILD_STATIC_LIBS ON)
0037   endif()
0038 
0039   if(NOT g4vecgeomnav_POPULATED)
0040     FetchContent_Populate(g4vecgeomnav)
0041     message(STATUS "${g4vecgeomnav_SOURCE_DIR}, ${g4vecgeomnav_BINARY_DIR}")
0042     add_subdirectory(${g4vecgeomnav_SOURCE_DIR} ${g4vecgeomnav_BINARY_DIR})
0043   endif()
0044 else()
0045   find_package(G4VecGeomNav REQUIRED)  ## 'Glue' code bridging Geant4-VecGeom navigation
0046 endif()
0047 
0048 set(G4VecGeomNav_LIBRARIES G4VecGeomNav::g4vecgeomnav)
0049 
0050 
0051 #-------------------------------------------------------------------
0052 # Locate sources for this project
0053 file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
0054 
0055 # define the main target :
0056 add_executable(exampleVecGeomNav exampleVecGeomNav.cc ${sources})
0057 
0058 target_include_directories(exampleVecGeomNav PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")
0059 
0060 # we depend on G4VecGeomNav / VecGeom , optionally ROOT
0061 target_link_libraries(exampleVecGeomNav
0062   PRIVATE
0063     ${Geant4_LIBRARIES}
0064     G4VecGeomNav::g4vecgeomnav
0065     VecGeom::vecgeom
0066 )
0067 
0068 # As used in G4VecGeomNav - to refine
0069 if(WITH_ROOT)
0070   target_link_libraries(exampleVecGeomNav
0071     PRIVATE
0072       ROOT::Geom
0073       ${TGeo2VecGeom_LIBRARIES}
0074       ${ROOT_LIBRARIES}
0075   )
0076 endif()
0077 
0078 #----------------------------------------------------------------------------
0079 # Copy all scripts to the build/OUTPUT directory. This is so that, after
0080 # install, we can run the executable directly because it relies on these
0081 # scripts being in the current working directory.
0082 #
0083 set(EXVECGEOMNAVIGATION_SCRIPTS
0084   TestNTST.gdml
0085   vecgeomNav.in
0086   )
0087 
0088 foreach(_script ${EXVECGEOMNAVIGATION_SCRIPTS})
0089   configure_file(
0090     ${_script}
0091     ${PROJECT_BINARY_DIR}/${_script}
0092     COPYONLY
0093     )
0094 endforeach()