[CMake] CMAKE_CONFIGURATION_TYPES and CMAKE_BUILD_TYPE_INIT ...

Axel Roebel Axel.Roebel at ircam.fr
Wed Apr 5 14:57:47 EDT 2006


On Wednesday 05 April 2006 19:03, Brad King wrote:
> 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)

Yes, I tried like that as well!

> > 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

It appears to me that the suggestion you gave above will not work
with the command line. It work if you run cmake the second time, but the first 
time your MYPROJ_RAN_ONCE will be undefined such 
that the force will override the command line.

I know that I can run it twice to force the command line, but from
a user interface point of view this is quite annoying, becuase other people 
may use the project and will not know what is happening.

For a proper default value scheme the command line should be
able to override the default value. As far as I see this 
is not possible!

> > 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 know, I wanted to say 

make cmclean 
make rebuild_cache

where cmclean is a custom target that removes the cache.
It would be really nice if you can do 
make edit_cache
and later
make cmclean 
make rebuild_cache

to re-initialize to the default values.

> > 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.

Hm, it seems to me simply loading a module from a predefined location, 
relative to the cmake_source_dir would be all that is needed.
This is the same mechanism as the -C flag besides the fact that
it is no error if the file is not found. I think it would significantly 
improve the user interface. A single set of default values for all
projects is rather problematic.

Thanks for your efforts anyway.
I appreciate cmake a lot.

Axel

> -Brad
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake

-- 
Axel Roebel    
IRCAM Analysis/Synthesis Team
Email: Axel.Roebel at ircam.fr | Phone: ++33-1-4478 4845 | Fax: ++33-1-4478 1540


More information about the CMake mailing list