Problem 1261 - Geant4Config.cmake cannot be run more than once.
Summary: Geant4Config.cmake cannot be run more than once.
Status: CLOSED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: cmake (show other problems)
Version: other
Hardware: All All
: P3 major
Assignee: Ben Morgan
URL:
Depends on:
Blocks:
 
Reported: 2011-11-08 16:51 CET by Ben Morgan
Modified: 2011-11-08 20:04 CET (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description Ben Morgan 2011-11-08 16:51:06 CET
Geant4Config.cmake cannot be used by more than one call to find_package. This is problematic if users wish to find a base install of Geant4 and then check for components optionally, for example

find_package(Geant4 REQUIRED)

if(APP_CANUSE_GDML)
  find_package(Geant4 QUIET COMPONENTS gdml)

  if(Geant4_gdml_FOUND)
    ... do something ...
  else()
    ... do something else ...
  endif()
endif()


The cause is the direct inclusion of Geant4LibraryDepends.cmake, because re-running includes this file again, and so we get multiple targets of the same name, which CMake doesn't like.

The suggested fix is to protect the inclusion with a guard based on the truth of a variable which is set the first time the file is loaded.
Comment 1 Ben Morgan 2011-11-08 20:03:54 CET
Fixed in tag cmake-V09-04-32

The inclusion of Geant4LibraryDepends is protected with a flag that is set the first time the file is included. Multiple calls can now be made to find_package(Geant4 ...), so different components can be enabled as required.