On Mon, 17 Jun 2013 21:15:09 Daniel Stender wrote: > As a matter of fact, the CXX_BUILDFLAGS are recognized after a 2nd cmake run: > http://www.cmake.org/pipermail/cmake/2013-June/055082.html
Interesting... I found another post discussing similar bug: http://www.cmake.org/pipermail/cmake/2008-October/024550.html Although I don't have good understanding of how it works, using the above information I was able to produce patch (attached) that fixes incorrect FLAGS override. I tested it and it looks like no build flags are dropped any more. I would appreciate if you could review the patch and apply it if appropriate. Regards, Dmitry Smirnov. --- Platitude: an idea (a) that is admitted to be true by everyone, and (b) that is not true. -- H. L. Mencken
Last-Update: 2013-06-18 Forwarded: no Author: Dmitry Smirnov <only...@member.fsf.org> Description: fix FLAGS override due to incorrect caching Read more about similar issue at http://www.cmake.org/pipermail/cmake/2008-October/024550.html --- a/cmake/SetDefaultGccFlags.cmake +++ b/cmake/SetDefaultGccFlags.cmake @@ -53,80 +53,80 @@ # Flags common for all build configurations. SET( CMAKE_C_FLAGS "-Wall -Wno-unused -ffast-math ${no_inline_dllexport_cflags_}" - CACHE STRING "Common C flags for all build configurations." FORCE + CACHE STRING "Common C flags for all build configurations." ) SET( CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${stdlibs_shared_static_}" - CACHE STRING "Common C++ flags for all build configurations." FORCE + CACHE STRING "Common C++ flags for all build configurations." ) # Release SET( CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2 ${visibility_cflags_} ${gc_sections_cflags_}" - CACHE STRING "C flags for Release builds." FORCE + CACHE STRING "C flags for Release builds." ) SET( CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O2 ${visibility_cflags_} ${gc_sections_cflags_}" - CACHE STRING "C++ flags for Release builds." FORCE + CACHE STRING "C++ flags for Release builds." ) SET( CMAKE_EXE_LINKER_FLAGS_RELEASE "${gc_sections_ldflags_} ${dead_strip_ldflags_}" - CACHE STRING "Link flags for Release builds." FORCE + CACHE STRING "Link flags for Release builds." ) # MinSizeRel SET( CMAKE_C_FLAGS_MINSIZEREL "-DNDEBUG -Os ${visibility_cflags_} ${gc_sections_cflags_}" - CACHE STRING "C flags for MinSizeRel builds." FORCE + CACHE STRING "C flags for MinSizeRel builds." ) SET( CMAKE_CXX_FLAGS_MINSIZEREL "-DNDEBUG -Os ${visibility_cflags_} ${gc_sections_cflags_}" - CACHE STRING "C++ flags for MinSizeRel builds." FORCE + CACHE STRING "C++ flags for MinSizeRel builds." ) SET( CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${gc_sections_ldflags_} ${dead_strip_ldflags_}" - CACHE STRING "Link flags for MinSizeRel builds." FORCE + CACHE STRING "Link flags for MinSizeRel builds." ) # RelWithDebInfo SET( CMAKE_C_FLAGS_RELWITHDEBINFO "-DNDEBUG -g -O2 ${visibility_cflags_}" - CACHE STRING "C flags for RelWithDebInfo builds." FORCE + CACHE STRING "C flags for RelWithDebInfo builds." ) SET( CMAKE_CXX_FLAGS_RELWITHDEBINFO - "-DNDEBUG -g -O2 ${visibility_cflags_}" - CACHE STRING "C++ flags for RelWithDebInfo builds." FORCE + "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DNDEBUG -g -O2 ${visibility_cflags_}" + CACHE STRING "C++ flags for RelWithDebInfo builds." ) SET( CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "" - CACHE STRING "Link flags for RelWithDebInfo builds." FORCE + CACHE STRING "Link flags for RelWithDebInfo builds." ) # Debug SET( CMAKE_C_FLAGS_DEBUG "-DDEBUG -g" CACHE STRING - "C flags for Debug builds." FORCE + "C flags for Debug builds." ) SET( CMAKE_CXX_FLAGS_DEBUG "-DDEBUG -g" CACHE STRING - "C++ flags for Debug builds." FORCE + "C++ flags for Debug builds." ) SET( CMAKE_EXE_LINKER_FLAGS_DEBUG "" - CACHE STRING "Link flags for Debug builds." FORCE + CACHE STRING "Link flags for Debug builds." ) - SET(COMPILER_FLAGS_OVERRIDDEN YES CACHE INTERNAL "" FORCE) + SET(COMPILER_FLAGS_OVERRIDDEN YES CACHE INTERNAL "") ENDIF(NOT COMPILER_FLAGS_OVERRIDDEN) ENDIF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX --- a/cmake/SetDefaultBuildType.cmake +++ b/cmake/SetDefaultBuildType.cmake @@ -1,9 +1,9 @@ MACRO(ST_SET_DEFAULT_BUILD_TYPE TYPE_) IF(NOT CMAKE_BUILD_TYPE AND NOT DEFAULT_BUILD_TYPE_SET) - SET(DEFAULT_BUILD_TYPE_SET TRUE CACHE INTERNAL "" FORCE) + SET(DEFAULT_BUILD_TYPE_SET TRUE CACHE INTERNAL "") SET( CMAKE_BUILD_TYPE "${TYPE_}" CACHE STRING - "Build type (Release Debug RelWithDebInfo MinSizeRel)" FORCE + "Build type (Release Debug RelWithDebInfo MinSizeRel)" ) ENDIF(NOT CMAKE_BUILD_TYPE AND NOT DEFAULT_BUILD_TYPE_SET) ENDMACRO(ST_SET_DEFAULT_BUILD_TYPE)