[CMake] Change variable default

Ilja Golshtein ilejncs at narod.ru
Thu Apr 28 12:42:40 EDT 2011


Tim,

thank you.

Compiler and environment specific things become defined during "project" command execution.
It is too late to check if it is set afterwards because it actually IS SET.

I assume you are lucky and default value for CMAKE_Fortran_FLAGS_RELEASE is
empty, isn't it?

So the tricky point is to place customization code in proper place.

In my case 
==
set(CMAKE_CXX_FLAGS_DEBUG  "-g -wall"
  CACHE
  STRING "" 
  )
==
works perfectly if put at the top of CMakeLists.txt


28.04.2011, 19:23, "Tim Gallagher" <tim.gallagher at gatech.edu>:
> We do this:
>
> if(NOT CMAKE_Fortran_FLAGS_RELEASE)
>    set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -xhost" CACHE STRING "" FORCE)
> endif()
>
> In other words, if the flags haven't been set yet (initial start up), set them to what we want. If they have been set (either changed by the user, or specified on the cmake/ccmake line with -D), leave them alone.
>
> Tim
>
> ----- Original Message -----
> From: "Ilja Golshtein" <ilejncs at narod.ru>;
> To: cmake at cmake.org
> Sent: Thursday, April 28, 2011 9:03:43 AM
> Subject: [CMake] Change variable default
>
> Hello!
>
> There are some CMAKE variables with default values. For example CMAKE_CXX_FLAGS_DEBUG default value is '-g'.
> How is it possible to make it '-g -Wall'?
>
> What I don't want to have: User choice overwritten.
>
> What I want to have: Modified a variable cmake-time default. It must be possible to change the variable via cmake -D or ccmake GUI.
>
> Thanks.
>
> --
> Best regards,
> Ilja Golshtein.
> _______________________________________________
> 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
> _______________________________________________
> 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

-- 
Best regards,
Ilja Golshtein.


More information about the CMake mailing list