Skip to content

Commit

Permalink
[cmake] Find HepMC3 only once (#250)
Browse files Browse the repository at this point in the history
The package warns that "multiple calls to find_package(HepMC3) are
not recommended", so move it to the top-level CMakeLists.txt. Also
replace add_definitions by the more specific add_compile_definitions.
  • Loading branch information
hahnjo committed Jun 20, 2023
1 parent 4db5b59 commit 46242a8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ else()
message(STATUS "Did not find Geant4")
endif()

# Find HepMC3, used by integration examples to load realistic events
find_package(HepMC3 QUIET)

if(HepMC3_FOUND)
message(STATUS "HepMC3 found ${HEPMC3_INCLUDE_DIR}")
add_compile_definitions(HEPMC3_FOUND)
endif()

# Set up debugging levels for CUDA:
# - For RelWithDebInfo (the default), generate line info to enable profiling.
add_compile_options("$<$<AND:$<COMPILE_LANGUAGE:CUDA>,$<CONFIG:RelWithDebInfo>>:--generate-line-info>")
Expand Down
8 changes: 0 additions & 8 deletions examples/Example14/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
# SPDX-FileCopyrightText: 2022 CERN
# SPDX-License-Identifier: Apache-2.0

find_package(HepMC3 QUIET)

if(HepMC3_FOUND)
message(STATUS "HepMC3 found ${HEPMC3_INCLUDE_DIR}")
add_definitions(-DHEPMC3_FOUND)
endif()


if(NOT TARGET G4HepEm::g4HepEm)
message(STATUS "Disabling example14 (needs G4HepEm)")
return()
Expand Down
8 changes: 0 additions & 8 deletions examples/Example17/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
# SPDX-FileCopyrightText: 2022 CERN
# SPDX-License-Identifier: Apache-2.0

find_package(HepMC3 QUIET)

if(HepMC3_FOUND)
message(STATUS "HepMC3 found ${HEPMC3_INCLUDE_DIR}")
add_definitions(-DHEPMC3_FOUND)
endif()


if(NOT TARGET G4HepEm::g4HepEm)
message(STATUS "Disabling example17 (needs G4HepEm)")
return()
Expand Down

0 comments on commit 46242a8

Please sign in to comment.