[Cmake] Some problems

David Svoboda xsvobod2 at informatics . muni . cz
Wed, 18 Jun 2003 16:57:22 +0200


On Wed, 18 Jun 2003, Bill Hoffman wrote:

> 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

First I must say "I'm sorry" because I made many changes in my
CMakeLists.txt and that caused fall of cmake. That's why I wrote
the sentence containing "cannot resolve it". But it was my fault. Now 
let's go back to the problem:

I tried the same:

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

$ grep BUILD_TYPE CMakeCache.txt
CMAKE_BUILD_TYPE:STRING=
MY_BUILD_TYPE:STRING=RELEASE

I'm using cmake version 1.6 - Is it the reason?

-David