Problem 1253

Summary: Incorrect setting of Geant4_LIBRARIES by Geant4Config.cmake for pure static build
Product: Geant4 Reporter: Ben Morgan <Ben.Morgan>
Component: cmakeAssignee: Ben Morgan <Ben.Morgan>
Status: CLOSED FIXED    
Severity: trivial    
Priority: P5    
Version: other   
Hardware: All   
OS: All   

Description Ben Morgan 2011-10-11 13:20:55 CEST
This was originally reported by Jean Jacquemier with geant4-09-04-ref-09. When building Geant4 with pure static libraries, application builds using Geant4Config.cmake will fail with the message (here, using TestEm1 as an example):

Linking CXX executable TestEm1
/usr/bin/ld: cannot find -lG4clhep
collect2: ld returned 1 exit status
make[3]: *** [TestEm1] Error 1
make[2]: *** [CMakeFiles/TestEm1.dir/all] Error 2
make[1]: *** [CMakeFiles/TestEm1.dir/rule] Error 2
make: *** [TestEm1] Error 2

This was diagnosed as incorrect CMake list syntax in Geant4Config.cmake when the optionally packaged libraries G4clhep, G4expat and G4zlib are appended to the Geant4_LIBRARIES variable. This uses the incorrect syntax

foreach(item "a;b;c")
  list(APPEND somelist ${item}${suffix})
endforeach()

which works fine in the shared library case because the suffix variable is blank and the lists are joined. However, in the static library case, suffix='-static' and this results in 'a;b;c-static' getting appended so somelist!

The simple fix is to use the correct CMake syntax:

foreach(item a;b;c)
  list(APPEND somelist ${item}${suffix})
endforeach()
Comment 1 Ben Morgan 2011-10-11 13:27:00 CEST
Fixed as of revision #53022. Will mark as closed once next cmake category tag is proposed.