Problem 1253 - Incorrect setting of Geant4_LIBRARIES by Geant4Config.cmake for pure static build
Summary: Incorrect setting of Geant4_LIBRARIES by Geant4Config.cmake for pure static b...
Status: CLOSED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: cmake (show other problems)
Version: other
Hardware: All All
: P5 trivial
Assignee: Ben Morgan
URL:
Depends on:
Blocks:
 
Reported: 2011-10-11 13:20 CEST by Ben Morgan
Modified: 2018-05-08 14:52 CEST (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-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.