[Cmake] Some problems

Bill Hoffman bill . hoffman at kitware . com
Wed, 18 Jun 2003 10:36:12 -0400


At 10:26 AM 6/18/2003, David Svoboda wrote:
>On Wed, 18 Jun 2003, Bill Hoffman wrote:
>
>> OK, I see.   
>> 
>> The PROJECT command enables the language and sets many of the
>> built-in variables.   So, CMAKE_BUILD_TYPE is set by cmake, and
>> the default value can not be overridden.   So, after the PROJECT
>> command the variable has already been initialized and can not be
>> re-initialized.
>> 
>> The way around this is to create a project specific variable. 
>> 
>> SET(MY_BUILD_TYPE RELEASE CACHE STRING "Debug/Release")
>> SET(CMAKE_BUILD_TYPE ${MY_BUILD_TYPE} CACHE STATIC "see MY_BUILD_TYPE")
>> 
>> 
>> Then CMAKE_BUILD_TYPE would always be set to MY_BUILD_TYPE.
>> 
>> 
>> 
>> -Bill
>
>Yes, I think I understand, what you mean. Unfortunately your code is
>incorrect - cmake cannot resolve it.

I just tried with CMake 1.6.7 and the following works:

PROJECT(foo)
SET(MY_BUILD_TYPE RELEASE CACHE STRING "Debug/Release")
SET(CMAKE_BUILD_TYPE ${MY_BUILD_TYPE} CACHE STATIC "see MY_BUILD_TYPE")

And if I look in the cache, things are set as expected:
$ grep BUILD_TYPE CMakeCache.txt
//see MY_BUILD_TYPE
CMAKE_BUILD_TYPE:STATIC=RELEASE
MY_BUILD_TYPE:STRING=RELEASE

What do you mean by "cannot resolve it"?

-Bill