[CMake] CMake internal cache deletion seems to nullify command-line cache var settings
Wheeler, Frederick W (GE Global Research)
wheeler at ge.com
Wed Feb 9 10:02:05 EST 2011
I think I found a CMake bug where cache variables set on the
command-line (CMAKE_INSTALL_PREFIX:PATH) are not set as expected when
the cache is deleted by cmake because a variable like
CMAKE_C_COMPILER:FILEPATH is set. I've reduced this down as much as I
could. I'm demonstrating the bug using the ITK source tree, but I doubt
that matters.
My workaround is to always remove the cache file before running cmake.
########################################################################
####
# make a build dir
rm -rf $DEV/cmake_debug
mkdir $DEV/cmake_debug
cd $DEV/cmake_debug
# system info
% uname -a
Linux tanaga 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64
x86_64 x86_64 GNU/Linux
% /local/wheeler/dev/cmake-2.8.3/bin/cmake --version
cmake version 2.8.3
########################################################################
####
# Step 1
Remove the cache file and run CMake, setting CMAKE_INSTALL_PREFIX on
the command-line. CMAKE_INSTALL_PREFIX gets set correctly.
rm -f CMakeCache.txt
/local/wheeler/dev/cmake-2.8.3/bin/cmake \
-G"Unix Makefiles" \
-DCMAKE_INSTALL_PREFIX:PATH=/local/wheeler/dev/itk_usr_gcc_rel \
-DCMAKE_C_COMPILER:FILEPATH=gcc \
/local/wheeler/dev/itk_src
grep CMAKE_INSTALL_PREFIX:PATH CMakeCache.txt
CMAKE_INSTALL_PREFIX:PATH=/local/wheeler/dev/itk_usr_gcc_rel
########################################################################
####
# Step 2
Do not remove the cache file, but re-run cmake, but without setting
CMAKE_INSTALL_PREFIX:PATH or CMAKE_C_COMPILER:FILEPATH. No problem,
the setting of CMAKE_INSTALL_PREFIX is preserved.
# rm -f CMakeCache.txt
/local/wheeler/dev/cmake-2.8.3/bin/cmake \
-G"Unix Makefiles" \
/local/wheeler/dev/itk_src
grep CMAKE_INSTALL_PREFIX:PATH CMakeCache.txt
CMAKE_INSTALL_PREFIX:PATH=/local/wheeler/dev/itk_usr_gcc_rel
########################################################################
####
# Step 3
Do not remove the cache file, but re-run cmake setting
CMAKE_INSTALL_PREFIX:PATH and CMAKE_C_COMPILER:FILEPATH.
CMAKE_INSTALL_PREFIX is no longer set the way I want it.
# rm -f CMakeCache.txt
/local/wheeler/dev/cmake-2.8.3/bin/cmake \
-G"Unix Makefiles" \
-DCMAKE_INSTALL_PREFIX:PATH=/local/wheeler/dev/itk_usr_gcc_rel \
-DCMAKE_C_COMPILER:FILEPATH=gcc \
/local/wheeler/dev/itk_src
grep CMAKE_INSTALL_PREFIX:PATH CMakeCache.txt
CMAKE_INSTALL_PREFIX:PATH=/usr/local
########################################################################
####
In Step 3 I get this warning from CMake. Should be no problem since
CMAKE_INSTALL_PREFIX is explicitly set on the command line.
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
It seems that when CMake clears the cache because I set
CMAKE_C_COMPILER:FILEPATH it reverts CMAKE_INSTALL_PREFIX:PATH to its
default value and does not honor the -DCMAKE_INSTALL_PREFIX:PATH=... on
the cmake command-line. Also note that I am not changing the value of
CMAKE_C_COMPILER:FILEPATH.
If this is not a bug, then I suggest the warning cmake issues (above)
also explain that even variables settings made with the -D option may
not be honored.
########################################################################
####
More information about the CMake
mailing list