AW: [CMake] Overriding default values

Filipe Sousa filipe at ipb.pt
Fri Sep 2 05:27:15 EDT 2005


On Friday 02 September 2005 10:21, Sören Freudiger wrote:
> to add new flags is quite simple (e.g. /wd4996):
>
> #first remove existing flag (elsewise eachtime you'll configuring you will
> add this option again)
> REMOVE(CMAKE_CXX_FLAGS "/wd4996")
> #then add the "new option"
> SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "/wd4996")
> #last thing is adding ";/wd4996" so you have to reomove the semicolon:
> STRING(REGEX REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
> #or by doing this
> REMOVE(CMAKE_CXX_FLAGS ";")
>
> #if you also want to change the cache variable:
> SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "common C++ build
> flags" FORCE)
>
> if there's a better, shorter way, plaese let me know!

MACRO(ADD_CXX_FLAGS)
  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGN}")
ENDMACRO(ADD_CXX_FLAGS)

MACRO(ADD_C_FLAGS)
  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARGN}")
ENDMACRO(ADD_C_FLAGS)

MACRO(ADD_C_FLAGS_IF condition)
  IF(${condition})
    ADD_C_FLAGS(${ARGN})
  ENDIF(${condition})
ENDMACRO(ADD_C_FLAGS_IF)

MACRO(ADD_CXX_FLAGS_IF condition)
  IF(${condition})
    ADD_CXX_FLAGS(${ARGN})
  ENDIF(${condition})
ENDMACRO(ADD_CXX_FLAGS_IF)

ADD_CXX_FLAGS("/wd4996")

ADD_CXX_FLAGS_IF(WIN32 "/wd4996")

> -----Ursprüngliche Nachricht-----
> Von: cmake-bounces+muffmolch=gmx.de at cmake.org
> [mailto:cmake-bounces+muffmolch=gmx.de at cmake.org] Im Auftrag von James
> Bigler
> Gesendet: Donnerstag, 1. September 2005 23:25
> An: cmake at cmake.org
> Betreff: [CMake] Overriding default values
>
> CMake attempts to provide some values for the following variables:
>
> CMAKE_CXX_FLAGS
> CMAKE_CXX_FLAGS_DEBUG            -g
> CMAKE_CXX_FLAGS_MINSIZEREL       -O3
> CMAKE_CXX_FLAGS_RELEASE          -O2
> CMAKE_CXX_FLAGS_RELWITHDEBINFO   -O2
>
> How can I change the default and allow the user to make changes the
> persists across configuation?
>
> Thanks,
> James
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake

-- 
Filipe Sousa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/cmake/attachments/20050902/34c9d97c/attachment.pgp


More information about the CMake mailing list