[CMake] Setting CMAKE_CXX_FLAGS_<> in CMakeLists.txt

David Cole david.cole at kitware.com
Sun Jun 24 13:24:22 EDT 2007


A variable is not cached (in CMakeCache.txt) by a SET command unless CACHE
is specified. A cached variable is not changed by a SET command unless FORCE
is used...

See "cmake --help-command SET" for more info....

Setting the CMAKE_CXX_FLAGS_DEBUG even without getting it cached should have
the effect you want however. If you build a .o file with "make VERBOSE=1"
you should see the flags you set being used for the compile...


HTH,
David


On 6/24/07, Michael Hammer <michael.hammer at tugraz.at> wrote:
>
> Hi!
>
> I have a problem with setting compiler flags. I would like to change
> the default debug flags to "-g3 -Wall --pedantic" or at least create
> a new build type to use my needed compiler flags. I found an info in
> the wiki (http://www.cmake.org/Wiki/CMake_Useful_Variables) and tried
> the following statement in CMakeLists.txt in the project root:
>
> SET(CMAKE_CXX_FLAGS_DEBUG "-g3 -Wall --pedantic")
>
> But even in the first run (with empty build directory) no change of
> this variable in the CmakeCache happened. The entry was still:
>
> ---
> //Flags used by the compiler during debug builds.
> CMAKE_CXX_FLAGS_DEBUG:STRING=-g
> ---
>
> So I thought let's try to create a new build type, I added the
> following lines, again in the root CMakeLists.txt:
>
> ---
> SET(CMAKE_BUILD_TYPE devel)
> SET(CMAKE_CXX_FLAGS_DEVEL "-g3 -Wall --pedantic")
> ---
>
> The same effect her - nothing! *grml* There was no new variable named
> CMAKE_CXX_FLAGS_DEVEL as I would expect it. (Again after creating a
> new CMakeCache) May be anyone could help me with this problem? I am
> sure I am understanding something wrong about variables which are
> changeable in configure process and those which aren't. But I am also
> sure there must be a way to write CMakeLists.txt code to configure
> compiler flags. Now I am forced to edit the CMakeCache manually and I
> have to change the CMAKE_CXX_FLAGS_DEBUG variable each time I create
> a new build tree ...
>
> Thanks for any help,
>
> Michael
>
> ----------------------------------------------------------------------
>                                                                   __
> Dipl.-Ing. (MSc) Michael Hammer (Scientific Assistant)     __  _|  |_
> Institute for Strength of Materials /                     |  ||      |
>             Graz University of Technology                  |_    _||__|
> phone: +43 (0) 316 873 / 7667                               |__|
> fax:   +43 (0) 316 873 / 7169
> http://www.fest.TUGraz.at/                    michael.hammer at tugraz.at
> ----------------------------------------------------------------------
>
>
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20070624/761f06f8/attachment.htm


More information about the CMake mailing list