Warning, /geant4/examples/extended/eventgenerator/HepMC/HepMCEx02/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 #----------------------------------------------------------------------------
0002 # Setup the project
0003 cmake_minimum_required(VERSION 3.16...3.27)
0004 project(HepMCEx02)
0005
0006 #----------------------------------------------------------------------------
0007 # Find Geant4 package, activating all available UI and Vis drivers by default
0008 # You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui
0009 # to build a batch mode only executable
0010 #
0011 option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
0012 if(WITH_GEANT4_UIVIS)
0013 find_package(Geant4 REQUIRED ui_all vis_all)
0014 else()
0015 find_package(Geant4 REQUIRED)
0016 endif()
0017
0018 #----------------------------------------------------------------------------
0019 # Setup Geant4 include directories and compile definitions
0020 #
0021 include(${Geant4_USE_FILE})
0022
0023 #----------------------------------------------------------------------------
0024 # Find HepMC (required package)
0025 #
0026 find_package(HepMC REQUIRED)
0027
0028 #----------------------------------------------------------------------------
0029 # Find Pythia6 (optional package)
0030 #
0031 find_package(Pythia6 QUIET)
0032 if(Pythia6_FOUND)
0033 message(STATUS "G4 Examples: Pythia6 found. --> HepMCEx02 example with Pythia6 enabled.")
0034 endif()
0035
0036 #----------------------------------------------------------------------------
0037 # Locate sources and headers for this project
0038 #
0039 include_directories(${PROJECT_SOURCE_DIR}/include
0040 ${Geant4_INCLUDE_DIR}
0041 ${HEPMC_INCLUDE_DIR})
0042 file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
0043 file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
0044
0045 #----------------------------------------------------------------------------
0046 # Add the executable, and link it to the Geant4 libraries
0047 #
0048 add_executable(HepMCEx02 HepMCEx02.cc ${sources} ${headers})
0049 target_compile_definitions(example_MyPythia PRIVATE $<$<BOOL:${Pythia6_FOUND}>:G4LIB_USE_PYTHIA>)
0050 #target_link_libraries(HepMCEx02 ${Geant4_LIBRARIES}
0051 # ${HEPMC_LIBRARIES} ${HEPMC_FIO_LIBRARIES}
0052 # $<$<BOOL:${Pythia6_FOUND}>:Pythia6::Pythia6>
0053 # gfortran)
0054 target_link_libraries(HepMCEx02 ${Geant4_LIBRARIES}
0055 ${HEPMC_LIBRARIES} ${HEPMC_FIO_LIBRARIES}
0056 $<$<BOOL:${Pythia6_FOUND}>:Pythia6::Pythia6>)
0057
0058 # if pythia is compiled with g77, link with -lg2c instead.
0059 #target_link_libraries(HepMCEx02 ${Geant4_LIBRARIES}
0060 # ${HEPMC_LIBRARIES} ${HEPMC_FIO_LIBRARIES}
0061 # $<$<BOOL:${Pythia6_FOUND}>:Pythia6::Pythia6>
0062 # g2c)
0063
0064 #----------------------------------------------------------------------------
0065 # Copy all scripts to the build directory, i.e. the directory in which we
0066 # build HepMCEx02. This is so that we can run the executable directly because it
0067 # relies on these scripts being in the current working directory.
0068 #
0069 set(HepMCEx02_SCRIPTS
0070 hepmc_ascii.in hepmc_ascii.out hepmc_pygen.in hepmc_pygen.out pyh4mu.mac pyset.mac vis.mac
0071 data/example_MyPythia.dat
0072 )
0073
0074 foreach(_script ${HepMCEx02_SCRIPTS})
0075 configure_file(
0076 ${PROJECT_SOURCE_DIR}/${_script}
0077 ${PROJECT_BINARY_DIR}/${_script}
0078 COPYONLY
0079 )
0080 endforeach()
0081
0082 #----------------------------------------------------------------------------
0083 # Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
0084 #
0085 install(TARGETS HepMCEx02 DESTINATION bin)
0086