[CMake] Strange search order of CMakeCache.txt

Marcel Loose loose at astron.nl
Fri Mar 5 08:19:08 EST 2010


Hi all,

I just spent an hour debugging a very strange phenomenon running CMake
on Mac OS-X, which in the end turned out to be trivial, but completely
unexpected for me.

The problem was caused by the fact that CMake had accidentally been run
once from the source directory. When running CMake in an empty binary
directory it seemed to somehow fail to set CMAKE_BINARY_DIR correctly.

Cause of the problem turned out to be the order in which CMake searches
for the CMakeCache.txt file: first in the directory containing the
CMakeLists.txt file (CMAKE_SOURCE_DIR), then in the (binary) directory
that CMake is being run from (CMAKE_BINARY_DIR). 

Wouldn't it be more logical to start in the binary directory and then
look in the source directory? Or, probably even better, completely
ignore the source directory when searching for the cache file.

Best regards,
Marcel Loose.




More information about the CMake mailing list