On 12-10-2010 13:24, Michael Wild wrote:

The FORCE is OK, but you should do this only once, and only if CMAKE_CXX_FLAGS 
is the default. You don't want to upset your users, do you? Something like this 
should do:

if(CMAKE_COMPILER_IS_GNUCXX AND NOT __CHECKED_CXX_FLAGS)
   # this is the guard so we do this only once
   set(__CHECKED_CXX_FLAGS TRUE CACHE INTERNAL "Whether we checked the CXX flags 
already")
   if("${CMAKE_CXX_FLAGS}" STREQUAL "${CMAKE_CXX_FLAGS_INIT}")
     # only override defaults if the user didn't do so already!
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} Wall -Woverloaded-virtual 
-Wno-unknown-pragmas -Werror"
       CACHE STRING "Flags used by the compiler during all build types." FORCE)
   endif()
endif()

This way the flags end up in the cache and can be changed by the user without 
having to change the CMakeLists.txt file, and it also respects the user's 
choice of flags if he provides them in the initial CMake-run.


Thanks, I'll try it that way.

Thomas

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to