From 6732fa3a291e77acad3ab6ba829d1026462dc139 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 11 Jun 2019 15:46:31 +0200 Subject: Fix linking of examples Provide add_qt_gui_executable() as function in our public API that takes care of automaticWinMain linkage. We can use this in the future to encapsulate similarplatform-specific behavior and adjustments, such as module generation onAndroid. In order for the examples to see the function in Qt5CoreMacros, three more additional fixes were required: * Do the build_repo_end() call _before_ attempting to build the examples, as we need the build_repo_end() to include QtPostProcess and complete the creation of all the target config files. Otherwise the find_package() calls in the examples see something incomplete. * Add more QT_NO_CREATE_TARGET guards * Always call find_dependency on the dependencies, regardless of the target creation mode. This way a find_package(Qt5 COMPONENTS Widgets) will still load Qt5CoreMacros. Change-Id: I03ce856e2f4312a050fe8043b8331cbe8a6c93e6 Reviewed-by: Qt CMake Build Bot Reviewed-by: Leander Beernaert Reviewed-by: Alexandru Croitor --- src/corelib/Qt5CoreMacros.cmake | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index bae1518375..8d4943aa3f 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -388,3 +388,14 @@ if (NOT CMAKE_VERSION VERSION_LESS 2.8.9) endforeach() endmacro() endif() + +function(add_qt_gui_executable target) + add_executable(${ARGV}) + target_link_libraries("${target}" PRIVATE Qt::Core Qt::Gui) + + list(FIND ARGV WIN32 WIN32_OPTION_IDX) + if(WIN32 AND NOT WIN32_OPTION_IDX EQUAL -1) + target_link_libraries("${target}" PRIVATE Qt::WinMain) + endif() +endfunction() + -- cgit v1.2.3