MantisBT - CMake
View Issue Details
0009980CMakeCMakepublic2009-11-30 12:492016-06-10 14:31
David Faure 
Bill Hoffman 
normalfeaturealways
closedmoved 
CMake-2-8 
 
0009980: Separate user-specified and cached variables
cmake is really missing the equivalent of autoconf's config.status: a way to re-run cmake with the same options as initially (plus any options modified by hand in cmake-gui, I suppose).

This would be useful for many use cases.
Use case 1: going to an old cmake project, and cmake needs to be rerun again for some reason (e.g. Qt is now in a different prefix). If one didn't write down the options he passed cmake, one has to figure them out again. I keep shell scripts around in every project, but that's just manual work that other buildsystems automate -- simply remembering which options were given by the user. The suggestion of "deleting the stuff from the cache that doesn't apply anymore" isn't a solution; in the example of Qt there are countless variables that depend on its location.

Use case 2: changing the compiler. See the bug report in the "Additional information" field.
I edited the cache file to change the path to gcc. After doing that, I typed
make, and cmake realized I had changed the compiler and re-configured
everything, including... losing my install prefix!
This is exactly why cmake should differenciate between the options set by the
user and the options it found itself. So that it never loses the options set
by the user, like the install prefix....

Details below:

> cmake -DCMAKE_BUILD_TYPE=debug -DCMAKE_INSTALL_PREFIX=$KDEDIR .
[...]
> grep INSTALL_PREFIX CMakeCache.txt
CMAKE_INSTALL_PREFIX:PATH=/d/kde/inst/kde4
> grep gcc CMakeCache.txt
CMAKE_C_COMPILER:FILEPATH=/usr/lib/icecc/bin/gcc

OK, let's change gcc to use ccache:

> perl -pi -e 's,/usr/lib/icecc/bin/gcc,/usr/lib/ccache/gcc,' CMakeCache.txt
> grep gcc CMakeCache.txt
CMAKE_C_COMPILER:FILEPATH=/usr/lib/ccache/gcc

> make
Executing command /d/qt/4/kde-qt-4.6/bin/qmake -query QT_VERSION
-- Configuring done
You have changed variables that require your cache to be deleted.
Configure will be re-run and you may have to reset some variables.
The following variables have changed:
CMAKE_C_COMPILER= /usr/lib/ccache/gcc
[...]

> grep INSTALL_PREFIX CMakeCache.txt
CMAKE_INSTALL_PREFIX:PATH=/usr/local

Whoops, where did my install prefix go???
No tags attached.
Issue History
2009-11-30 12:49David FaureNew Issue
2010-08-29 10:17Kovarththanan RajaratnamSeveritymajor => feature
2010-12-15 09:02David ColeStatusnew => assigned
2010-12-15 09:02David ColeAssigned To => Bill Hoffman
2011-07-06 14:57Alex NeundorfNote Added: 0027013
2012-05-15 13:05David FaureNote Added: 0029475
2016-06-10 14:27Kitware RobotNote Added: 0041629
2016-06-10 14:27Kitware RobotStatusassigned => resolved
2016-06-10 14:27Kitware RobotResolutionopen => moved
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0027013)
Alex Neundorf   
2011-07-06 14:57   
In cmake-gui there is in the Tools menu an entry "Show my changes".
Does this help ?

Alex
(0029475)
David Faure   
2012-05-15 13:05   
I don't see how any GUI helps preventing the "typing make and losing settings" issue...
(0041629)
Kitware Robot   
2016-06-10 14:27   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.