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

David Aldrich david.aldrich.ntml at gmail.com
Fri Jun 21 09:42:45 EDT 2019


>
> Do never test CMAKE_BUILD_TYPE in CMakeLists.txt files, it is ignored in
> multiple generators (e.g. Visual Studio).
>

Does that mean I shouldn't have this in CMakeLists.txt? :

# Specify a Release build by default
if(NOT CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE "Release")
  message(STATUS "Build type not specified: Use Release by default")
endif(NOT CMAKE_BUILD_TYPE)


>
> Just use the appropriate variables that contain suffixes regarding the
> configuration.
>
> e.g
>
> set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/debug)
> set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/release)
>
> See [0] for a list with _<CONFIG> variables.
>
> [0]: https://cmake.org/cmake/help/v3.15/manual/cmake-variables.7.html
>
> HTH
>

Thank you. That is working for me.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190621/6c3fd7b7/attachment.html>


More information about the CMake mailing list