| Summary: | Geant4Config.cmake cannot be run more than once. | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | Ben Morgan <Ben.Morgan> |
| Component: | cmake | Assignee: | Ben Morgan <Ben.Morgan> |
| Status: | CLOSED FIXED | ||
| Severity: | major | ||
| Priority: | P3 | ||
| Version: | other | ||
| Hardware: | All | ||
| OS: | All | ||
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. |
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.