MantisBT - CMake
View Issue Details
0014818CMakeCMakepublic2014-03-20 03:282016-06-10 14:31
Daniel Hasemann 
Kitware Robot 
normalmajoralways
closedmoved 
x86_64Kubuntu10.04
CMake 2.8.9 
 
0014818: Out-of-source build does not work if an 'in-source' CMakeCache.txt file is available
I had the following problem: My CMake builds are in-source-builds at the moment and I am refactoring it to out-of-source builds. Because of old 'in-source' CMakeCache file, the out-of-source build does not work as long as this is available.
IMHO the out-of-source build must not depend on in-source CMakeCache.txt
cd src
ls
# foo.c bar.c CMakeCache.txt CMakeLists.txt build/ [...]
rm -rf build
mkdir build
cd build
cmake ..

nothing does happen because of ../CMakeCache.txt
No tags attached.
related to 0006672closed Kitware Robot Detect In-Source build BEFORE creating CMakeCache.txt 
Issue History
2014-03-20 03:28Daniel HasemannNew Issue
2014-03-20 03:44Eric NOULARDRelationship addedrelated to 0006672
2014-03-20 03:45Eric NOULARDNote Added: 0035442
2014-03-20 03:49Eric NOULARDNote Added: 0035443
2014-03-20 10:52Daniel HasemannNote Added: 0035455
2014-03-21 13:59Ben BoeckelNote Added: 0035473
2016-06-10 14:29Kitware RobotNote Added: 0042511
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0035442)
Eric NOULARD   
2014-03-20 03:45   
Hi Daniel,

Have a look at related bug 0006672 you'll see this is a long-running well-known issue.
(0035443)
Eric NOULARD   
2014-03-20 03:49   
The reason is stated in cmake command line help:

$ cmake --help
Usage

  cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>


in order to support

cmake [options] <path-to-existing-build>

in a backward compatible way the behavior you observe should be kept.
CMake consider the source dir as an existing build dir precisely because
there is a CMakeCache.txt ini it.
(0035455)
Daniel Hasemann   
2014-03-20 10:52   
Ok, backwards compatibility is one of the most important things. Is it possible to force out-of-source builds or to deny in-source builds with a cmake option or an environment variable?
(0035473)
Ben Boeckel   
2014-03-21 13:59   
There is 'if ("${ParaView_SOURCE_DIR}" STREQUAL "${ParaView_BINARY_DIR}")' that ParaView does to detect and error if so, but that won't get you anywhere. The CMakeCache.txt needs to be moved out of the way for CMake to continue with the out-of-source build (since by the time you detect the error, the build directory has already been determined).
(0042511)
Kitware Robot   
2016-06-10 14:29   
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.