Change CMake build Directory

991 Views Asked by At

I would like to change the Working Directory of cmake. For example currently when I run the cmake from c/ directory where is the CMakeLists.txt, this will be the created directories and files:

c/CMakeFiles/
c/implementation/
c/cmake_install
// ...

This is really ugly and our application is Cross-platform, so this is not good. Currently I use Cmake from c/build directory like this:

cmake .. -Dparam=qnx-debug
cmake .. -Dparam=linux-release

So based on the parameters (and if I run cmake from c/) I wanna create a directory structure like this:

c/build/qnx-debug/CMakeFiles
c/build/qnx-debug/implementation
// ...
// or when I want build for linux
c/build/linux-release/CMakeFiles
c/build/linux-release/implementation
// ...

Is this possible with cmake or only with bash?

Regards, Krisztian

1

There are 1 best solutions below

0
On

Looks like the answer is no, but you can make the command a little cleaner by using the undocumented -H and -B arguments to cmake. They specify the directories of the source and the build files, respectively.

For what it's worth, I've used premake and it does support out-of-source builds without wrappers.