[CMake] change of CMAKE_BINARY_DIR in CMakeLists.txt

Alexander Neundorf a.neundorf-work at gmx.net
Wed Aug 22 11:33:20 EDT 2007


On Wednesday 22 August 2007 10:57, Maik Keller wrote:
> Hello!
>
> I'd like to create a (build-)directory which name depends on the compiler I
> am going to use. Let's assume my binary directory and my source directory
> are the same. For MS Windows Visual Studio I tried to do something like the
> following:
>
> IF(MSVC)
>   FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/MSVC)
> ENDIF(MSVC)
>
> SET(CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR}/MSVC)
> SET(PROJECT_BINARY_DIR ${CMAKE_BINARY_DIR})
>
> I expect that the Visual Studio Solution-file will be created in the
> MSVC-directory but I does not happen. These files are still created in the
> CMAKE_SOURCE_DIR-directory.
>
> Is there anything I am doing wrong?

You can't change CMAKE_BINARY_DIRECTORY. 
Once you run cmake, these variables are set implicitely.
If you need special names for the build directories, write a script which 
creates these build dirs and then runs cmake with the appropriate options in 
it.

Alex


More information about the CMake mailing list