[CMake] setting CMAKE_BINARY_DIR has no effect

Voisard, Shane S CIV NSWCDD, K54 christopher.voisard at navy.mil
Tue Nov 24 12:24:42 EST 2009


command line cmake (2.6.4) is always putting the generated build files under
the current working directory from which cmake is executed, regardless of
the value of CMAKE_BINARY_DIR.
 
I have this directory tree; the names are symbolic, not absolute:
parent (current working dir)
 |
 |
top-level-cmake  (project root contains top-level CMakeLists.txt)

I execute this command from within parent:
cmake.exe -G "Visual Studio 8 2005" \
          -C "top-level-cmake\init_cache.txt" top-level-cmake

The file "init_cache.txt" contains the command:
set (CMAKE_BINARY_DIR "${CMAKE_BINARY_DIR}/top-level-cmake" CACHE STRING "" FORCE)
 
The value of CMAKE_BINARY_DIR before the set command is 'parent'
The value of CMAKE_BINARY_DIR after the set command is 'parent/top-level-cmake'
 
cmake executes and finishes with the output:
-- Build files have been written to: parent
 
 
I have also tried setting the values for CMAKE_SOURCE_DIR, PROJECT_SOURCE_DIR, 
PROJECT_BINARY_DIR in various combinations, but with no effect.
 
I have read the 2.6 manpage, the cmake wiki and several mailing list postings,
but I have not found a solution to this problem.
 
This is important to us because we want to evolve our workflow so that 
cmake is executed from within another build script.  

Thanks,
Shane Voisard


More information about the CMake mailing list