Skip to content
Snippets Groups Projects
  • Stephan Hageboeck's avatar
    03e04e5f
    [CMake] Remove force overwrite of compiler optimisation flags. · 03e04e5f
    Stephan Hageboeck authored
    In CMake, variables like CMAKE_CXX_FLAGS_RELEASE etc should be cache
    variables, so users can set them from outside. ROOT, however, FORCE
    overwrote them, so users cannot change anything.
    Now, the variables are not set by ROOT at all, we use the CMake
    defaults.
    It is fine to append or replace substrings, but the variables should NOT
    be overwritten to give users some options.
    
    In case ROOT wants to move away from CMake defaults, it can be done like
    this:
    diff --git a/CMakeLists.txt b/CMakeLists.txt
    index e40b84a920..ab41612006 100644
    --- a/CMakeLists.txt
    +++ b/CMakeLists.txt
    @@ -29,6 +29,11 @@ endforeach()
    
     include(cmake/modules/CaptureCommandLine.cmake)
    
    +set(CMAKE_CXX_FLAGS_DEBUG_INIT "-O1 -g")
    +set(CMAKE_CXX_FLAGS_ASSERT_INIT "-O2 -g")
    +
     project(ROOT)
    03e04e5f
    History
    [CMake] Remove force overwrite of compiler optimisation flags.
    Stephan Hageboeck authored
    In CMake, variables like CMAKE_CXX_FLAGS_RELEASE etc should be cache
    variables, so users can set them from outside. ROOT, however, FORCE
    overwrote them, so users cannot change anything.
    Now, the variables are not set by ROOT at all, we use the CMake
    defaults.
    It is fine to append or replace substrings, but the variables should NOT
    be overwritten to give users some options.
    
    In case ROOT wants to move away from CMake defaults, it can be done like
    this:
    diff --git a/CMakeLists.txt b/CMakeLists.txt
    index e40b84a920..ab41612006 100644
    --- a/CMakeLists.txt
    +++ b/CMakeLists.txt
    @@ -29,6 +29,11 @@ endforeach()
    
     include(cmake/modules/CaptureCommandLine.cmake)
    
    +set(CMAKE_CXX_FLAGS_DEBUG_INIT "-O1 -g")
    +set(CMAKE_CXX_FLAGS_ASSERT_INIT "-O2 -g")
    +
     project(ROOT)