| Summary: | UseGeant4.cmake making mistake with compiler flags in some cases | ||
|---|---|---|---|
| Product: | Geant4 | Reporter: | Yngve Inntjore Levinsen <yngve.inntjore.levinsen> |
| Component: | cmake | Assignee: | Ben Morgan <Ben.Morgan> |
| Status: | CLOSED FIXED | ||
| Severity: | trivial | ||
| Priority: | P5 | ||
| Version: | other | ||
| Hardware: | All | ||
| OS: | All | ||
Edit: by CXX_CMAKE_COMPILE_FLAGS of course I mean CMAKE_CXX_FLAGS. Confirmed - this is due to a syntax error in mixing strings versus lists as described here http://www.cmake.org/Wiki/CMake_FAQ#How_to_convert_a_semicolon_separated_list_to_a_whitespace_separated_string.3F I hadn't seen the issue because it will work when the initial flags aren't set, or the Geant4 specific flags are the same as the initial set supplied by CMake. I'll work on a proper patch - the underlying idea in UseGeant4 being to force the use of the 'standard' Geant4 flags, but allow users to append to these (might need to rethink that..). For now, your suggested fix to UseGeant4.cmake will work, although might result in duplicate flags being used (that probably isn't severe). If you don't want to (or can't) edit UseGeant4.cmake, one can do find_package(Geant4 REQUIRED) include(${Geant4_USE_FILE}) set(CMAKE_CXX_FLAGS "${Geant4_CXX_FLAGS}") set(CMAKE_CXX_FLAGS_DEBUG "${Geant4_CXX_FLAGS_DEBUG}") set(CMAKE_CXX_FLAGS_MINSIZEREL "${Geant4_CXX_FLAGS_MINSIZEREL}") set(CMAKE_CXX_FLAGS_RELEASE "${Geant4_CXX_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_RELWITHDEDINFO "${Geant4_CXX_FLAGS_RELWITHDEBINFO}") which will force the use of the flags used to build Geant4. Whilst it's a little messy, it should cover most use cases, but does mean you can't edit the flags through the cache. Fixed in svn, with tag cmake-V09-04-14 Current fix simply forces use of flags used to build Geant4, so need to investigate other options. Either way, will be in next release. |
If a compiler flag variable like e.g. CXX_CMAKE_COMPILE_FLAGS is non-empty before UseGeant4.cmake is called, there is a ; added to the variable. The example below will produce the error: project(foo) set(CMAKE_CXX_FLAGS "-W -Wa") find_package(Geant4 REQUIRED) include(${Geant4_USE_FILE}) message("PROBLEMATIC FLAGS: ${CMAKE_CXX_FLAGS}") add_executable(foo foo.cc) A solution is to add "" around when you set the variables, like this: set(_tmp_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Geant4_CXX_FLAGS}")