MantisBT - CMake
View Issue Details
0007084CMakeCMakepublic2008-05-23 11:362008-09-09 14:21
kentwilliams 
Bill Hoffman 
normalmajoralways
closedwon't fix 
CMake-2-6 
 
0007084: Re-running CMake twice on the same directory corrupts CMakeCache.txt
Found with a complicated batch build system.

If the build directory does not exist (or if you delete the CMakeCache.txt) the build works fine.

If you run CMake a second time with the same command line parameters it writes a new CMakeCache.txt file, but with incorrect values for important CMAKE variables like CMAKE_INSTALL_PREFIX

Clue: The second cmake produces this error message:

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= gcc
CMAKE_CXX_COMPILER= g++
The attached tar file demonstrates the problem:

Untar CMakeTestBatchBuild.tar.gz
cd CMakeTestBatchBuild
sh testscript
No tags attached.
gz CMakeTestBatchBuild.tar.gz (3,443) 2008-05-23 11:36
https://public.kitware.com/Bug/file/1493/CMakeTestBatchBuild.tar.gz
Issue History
2008-05-23 11:36kentwilliamsNew Issue
2008-05-23 11:36kentwilliamsFile Added: CMakeTestBatchBuild.tar.gz
2008-06-06 11:18Bill HoffmanNote Added: 0012277
2008-06-06 11:18Bill HoffmanNote Added: 0012278
2008-06-06 11:19Bill HoffmanStatusnew => assigned
2008-06-06 11:19Bill HoffmanAssigned To => Bill Hoffman
2008-09-09 14:21Bill HoffmanStatusassigned => closed
2008-09-09 14:21Bill HoffmanResolutionopen => won't fix

Notes
(0012277)
Bill Hoffman   
2008-06-06 11:18   
This because CMake thinks the compilers are changing on it, and the cache is cleared, but the cache clearing clears the -D options at the same time. The fix should be to clear all, and then put back the -D option stuff. Or to not see this as a compiler change which it really isn't. But if there was a compiler change, then the -D stuff would still get cleared.
(0012278)
Bill Hoffman   
2008-06-06 11:18   
The work around for now, is to use CC,CXX environment variables to pick the compiler and not -D.