Creating an assembly tree for different types of assembly using CMake

I know how to create output files and inserts in CMake depending on the type of assembly (release, debug, etc.), but to shorten (re) compile time I would like CMake to create them in different subfolders.

Say I have such a tree

|- CMakeLists.txt
|- build/
|- src/

If I have a debug, release, and relwithdebinfo assembly, I want CMake to automatically create a tree for me like

|- CMakeLists.txt
|- build/
|--- Debug/
|--- Release/
|--- RelWithDebInfo/
|- src/

etc. Is this possible, if so, how can I achieve my goal?

I don’t need answers like "you have to run CMake from different folders", since for a visual studio this will lead to several solutions, etc. I want to be able to run CMake from only one folder and have it handle subfolders on its own.

+4
1

CMake , , (, Visual Studio).

, *_OUTPUT_DIRECTORY, :

set_property(TARGET my_lib
    PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/$<CONFIG>/bin)

$<CONFIG>, (Debug, Release ..).

, , , :

, . . (VS, Xcode) , .

, , ARCHIVE_OUTPUT_DIRECTORY, LIBRARY_OUTPUT_DIRECTORY RUNTIME_OUTPUT_DIRECTORY. .

, PDB_OUTPUT_DIRECTORY pdb.

, , , . , Make , -. CMake ( CMAKE_BUILD_TYPE cmake-gui). , CMake .

. , , , , cmake .

+2

Source: https://habr.com/ru/post/1649132/


All Articles