[CMake] CMAKE_CONFIGURATION_TYPES and CMAKE_BUILD_TYPE_INIT ...

Brad King brad.king at kitware.com
Wed Apr 5 13:03:36 EDT 2006


Axel Roebel wrote:
> On Wednesday 05 April 2006 14:19, Eric BOIX wrote:
> 
>>	Dear Brad King,
>>
>>Quoting Brad King <brad.king at kitware.com>:
>>
>>>To get options in the GUI they need to be cache settings.  Use the CACHE
>>>form of the SET command.
>>>
>>>IF(NOT CMAKE_BUILD_TYPE)
>>>  SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
>>>      "Build Configuration")
>>>ENDIF(NOT CMAKE_BUILD_TYPE)
>>
>>I had to add the FORCE flag in order to see the result appear in the GUIs.
>>I hope this is ok ?
> 
> 
> I had in fact the same problem as you. I would like to have a default 
> CMAKE_INSTALL_PREFIX
> different of /usr/local.
> 
> so the NOT test above will not work because CMAKE_INSTALL_PREFIX is never 
> empty. Therefore, I test for the existance of CMakeCache.txt and FORCE the 
> new default value if this file does not exist.

IF(NOT MYPROJ_RAN_ONCE)
   SET(MYPROJ_RAN_ONCE 1 CACHE INTERNAL "")
   SET(CMAKE_INSTALL_PREFIX /my/default CACHE STRING
       "Install prefix" FORCE)
ENDIF(NOT MYPROJ_RAN_ONCE)

> The unfortunate side effect is that I cannot override the default value by 
> means of command line arguments.

cmake /path/to/src -DCMAKE_INSTALL_PREFIX:PATH=/my/prefix

> Would there be a better way to change default values?
> Note, that I don't want -C to be used because I want the proper default values 
> to be used in the make rebuild_cache target!

make rebuild_cache just re-runs CMake starting with the current cache.

> I wonder whether it would not be much easier of cmake would take into account
> a default values file like ${CMAKE_SOURCE_DIR}/CMakeDefaults.cmake
> which would be used (if it exists) to set default values much like the -C 
> command line option.

This is somewhat tricky to implement.  We once tried implementing a 
"PreLoad.cmake" that works like this but it has some problems.  We'll 
probably try again sometime.

-Brad


More information about the CMake mailing list