Fix build with multi-config VS code generator

We want our libraries to end up in the same bin directory, not inside the
Debug\ or Release\ sub-directories. Their distinct names avoid a clash.

For our tools such as moc, uic, etc. we need to place the release build into
the bin directory explicitly, as by default multi-config generators place
binaries into the Debug\ or Release\ sub-directory.

This is also needed as cmake's automoc itself expects moc to be in the
bin directory.

One effect of this is that with a multi-config build, it is always necessary
to perform a release build first, otherwise the debug build won't find moc/uic.

Change-Id: I1361823ddf5961a5f1bb517e4bca69e621cbce9e
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Simon Hausmann 2019-06-20 10:56:19 +02:00
parent b0bd50d339
commit 1c4510cfc4

View File

@ -1131,6 +1131,8 @@ function(add_qt_module target)
set_target_properties("${target}" PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_LIBDIR}"
RUNTIME_OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_BINDIR}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${QT_BUILD_DIR}/${INSTALL_BINDIR}"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${QT_BUILD_DIR}/${INSTALL_BINDIR}"
ARCHIVE_OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_LIBDIR}"
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
@ -1815,6 +1817,10 @@ function(add_qt_tool name)
)
qt_internal_add_target_aliases("${name}")
set_target_properties("${name}" PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${QT_BUILD_DIR}/${INSTALL_BINDIR}"
)
if(NOT arg_NO_INSTALL AND arg_TOOLS_TARGET)
# Assign a tool to an export set, and mark the module to which the tool belongs.
qt_internal_append_known_modules_with_tools("${arg_TOOLS_TARGET}")