Tim,

I guess the difference is "project" command defines 
CMAKE_CXX_FLAGS_DEBUG and does not define CMAKE_Fortran_FLAGS_DEBUG.

Regarding  CMAKE_*_FLAGS_*_INIT, you are right, but what if user explicitly set 
the same value as INIT? 
It would be overwritten!

Anyway, I am happy with the solution to put CMAKE_CXX_FLAGS_DEBUG
before "project" command.

Thank you!


28.04.2011, 20:49, "Tim Gallagher" <[email protected]>:
> To put it in context, our cmake file looks like:
>
> <define project/language/etc>
> <find required libraries>
> if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
>    if(NOT CMAKE_Fortran_FLAGS_RELEASE)
>       set(CMAKE_Fortran_FLAGS_RELEASE "-O2 -xhost" CACHE STRING "" FORCE)
>    endif()
>   set(CMAKE_Fortran_FLAGS_DEBUG
>       "${CMAKE_Fortran_FLAGS_DEBUG} -check noarg_temp_created -C -traceback" 
> CA\
> CHE STRING "" FORCE)
> endif()
> <setup options for the project>
> <define executable>
>
> The other way you can try it, if it's not empty, is to do
>
> if(${CMAKE_Fortran_FLAGS_RELEASE} STREQUAL 
> ${CMAKE_Fortran_FLAGS_RELEASE_INIT})
>
> As far as I know, CMAKE_*_FLAGS_*_INIT are the default values that it gets 
> set to when cmake starts up. So if you check against that, you will see if 
> the user has modified it.
>
> Tim
>
> ----- Original Message -----
> From: "Ilja Golshtein" <[email protected]>;
> To: [email protected]
> Cc: [email protected]
> Sent: Thursday, April 28, 2011 12:42:40 PM
> Subject: Re: [CMake] Change variable default
>
> 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" <[email protected]>;:
>
>>  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" <[email protected]>;;
>>  To: [email protected]
>>  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.
> _______________________________________________
> 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.
_______________________________________________
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