[CMake] setting CMAKE_BINARY_DIR has no effect

David Cole david.cole at kitware.com
Tue Nov 24 12:40:19 EST 2009


You can't set any of those variables. They are all determined by CMake.

The CMAKE_BINARY_DIR is the current working directory when you run cmake or
ccmake for the very first time. Or, if you are running cmake-gui, you can
set it to a value before the first configure. After that, it is set in stone
for that build tree and cannot be set like other cmake variables.

Same for all _BINARY_DIR and _SOURCE_DIR variables. They are calculated and
should never be set.


HTH,
David


On Tue, Nov 24, 2009 at 12:24 PM, Voisard, Shane S CIV NSWCDD, K54 <
christopher.voisard at navy.mil> wrote:

> 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
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091124/514d128c/attachment.htm>


More information about the CMake mailing list