[CMake] How to support separate debug and release build directories?

Marc Herbert marc.herbert at gmail.com
Sun Jul 14 02:03:24 EDT 2019


Le ven. 21 juin 2019 à 11:40, Michael Jackson <mike.jackson at bluequartz.net>
a écrit :

>
>   cd Foo
>
>    mkdir Debug && cd Debug
>
>    cmake -DCMAKE_BUILD_TYPE=Debug ../
>
>    make -j
>
>
>
> We have just created a Debug build in the Debug Directory. Now, the same
> is analogous for the Release build.
>
>
>
> Cd Foo
>
> Mkdir Release && cd Release
>
> Cmake -DCMAKE_BUILD_TYPE=Release ../
>
> Make -j
>
>
>

Or, from CMake 3.13, simpler:

cd foo
cmake -B release/ -DCMAKE_BUILD_TYPE=Release
cmake -B debug/ -DCMAKE_BUILD_TYPE=Debug
make -j -C build & make -j -C debug



>  I am not finding it easy to find 'patterns' for these sort of issues. I
> would have thought that configuring a project with separate debug and
> release directories would be quite typical. But it's hard to find the
> recommended way of doing such things.
>

It is typical:
https://gitlab.kitware.com/cmake/community/wikis/FAQ#what-is-an-out-of-source-build

In this case CMake doesn't recommend anything because it assumes this is
implemented outside/on top of CMake
https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html

Marc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190713/67885bee/attachment-0001.html>


More information about the CMake mailing list