AW: AW: [CMake] Overriding default values
Filipe Sousa
filipe at ipb.pt
Fri Sep 2 05:57:52 EDT 2005
On Friday 02 September 2005 10:48, Sören Freudiger wrote:
> yeah, nice thing to put this in a macro. but the scheme is the same.
> Indeed
>
> MACRO(ADD_CXX_FLAGS)
> SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGN}")
> MESSAGE(${CMAKE_CXX_FLAGS})
> ENDMACRO(ADD_CXX_FLAGS)
>
> ADD_CXX_FLAGS("/wd4996")
>
> this will lead to following problem:
> first CMake->configure: "/wd4996"
> second CMake->configure: "/wd4996 /wd4996"
> third CMake->configure: "/wd4996 /wd4996 /wd4996"
Works here
fsousa at neptuno ~/tmp/rm $ cmake .
/wd4996
-- Configuring done
-- Generating done
-- Build files have been written to: /home/fsousa/tmp/rm
fsousa at neptuno ~/tmp/rm $ cmake .
/wd4996
-- Configuring done
-- Generating done
-- Build files have been written to: /home/fsousa/tmp/rm
fsousa at neptuno ~/tmp/rm $ cmake .
/wd4996
-- Configuring done
-- Generating done
-- Build files have been written to: /home/fsousa/tmp/rm
fsousa at neptuno ~/tmp/rm $
> ...
> and this macro has no effect to the cached value!
>
> better:
> MACRO(ADD_CXX_FLAGS)
> REMOVE(CMAKE_CXX_FLAGS ${ARGN})
> SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGN}" CACHE STRING "common C++
> build flags" FORCE)
> ENDMACRO(ADD_CXX_FLAGS)
>
> btw thanks for the tip "${CMAKE_CXX_FLAGS} ${ARGN}" this avoids the
> semicolon problem ;-)
>
> SirAnn
>
> -----Ursprüngliche Nachricht-----
> Von: cmake-bounces+muffmolch=gmx.de at cmake.org
> [mailto:cmake-bounces+muffmolch=gmx.de at cmake.org] Im Auftrag von Filipe
> Sousa
> Gesendet: Freitag, 2. September 2005 11:27
> An: cmake at cmake.org
> Betreff: Re: AW: [CMake] Overriding default values
>
> 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
>
> _______________________________________________
> 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/9d41a08a/attachment.pgp
More information about the CMake
mailing list