You will need to specify the target properties ARCHIVE_OUTPUT_DIRECTORY_<CONFIG> , LIBRARY_OUTPUT_DIRECTORY_<CONFIG> and / or RUNTIME_OUTPUT_DIRECTORY_<CONFIG> for each type of configuration and each target you target.
To influence all goals, you can set variables with names as with CMAKE_ prepended. Any relevant goal added after they are set will be affected.
So, for example, you can either do:
add_library(MyLib ${Sources}) set_target_properties(MyLib PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR} ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
or you could do:
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}) add_library(MyLib ${Sources})
Having said that, I usually find it better if generators with multiple configurations, such as Xcode and MSVC, just add configuration-dependent directories. Unless you plan to change the default exes and lib names as well, these multi-configuration IDEs overwrite one configuration output with another. Therefore, itโs hard to say whether you are looking at Debug or Release exe, for example.
For generators with a single connector, I believe that for each configuration for individual configurations it is necessary to have separate assembly trees.
In principle, I would not fight with the generator. CMake automates so much build process that I never find this small difference between generators a problem. You rarely have to consider whether the output path of the config directory contains or not.
source share