On Fri, 2019-06-21 at 14:19 +0100, David Aldrich wrote:
> Thanks for the help I have received in the past few days. I am making
> incremental improvements to my CMake project and have a new
> challenge.  I am running CMake 3.13 on Centos 7.6, targeting make. 
> My CMake file successfully builds debug or release targets and puts
> the executable in an out-of-source build directory.  I have added
> debug and release make targets so I can execute 'make debug' etc.
> 
> I now want to support separate target directories: build/debug and
> build/release.  I've shown my CMakeLists.txt below. So far I've just
> added an attempt to support build/debug:
> 
> if (CMAKE_BUILD_TYPE EQUAL "DEBUG")
>     message("debug mode")
>     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/debug)
> endif (CMAKE_BUILD_TYPE EQUAL "DEBUG")
> 
> but:
> 
> $ cmake3 -DCMAKE_BUILD_TYPE=DEBUG ..
> 
> puts the target into build, not build/debug.

The conventional solution to this is to run cmake in the "build/debug"
directory.

> I would also like this to work if I use the make targets e.g. make
> debug.

I think that's outside the scope of the Makefile generator.  For that
generator, CMAKE_BUILD_TYPE is a configuration-wide setting.  If you
want a different configuration, you need a different build directory
(where "build directory" is wherever you run cmake).

-- 
Braden McDaniel <bra...@endoframe.com>

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to