summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2019-06-12 13:09:13 +0200
committerSimon Hausmann <simon.hausmann@qt.io>2019-06-12 14:22:30 +0000
commit319fd4ea9ae89874671296c33880805c401844c9 (patch)
tree35926f0a5c407ab9f02ce048ced19d5f24907a63
parentefa9998521cb061051fe8b75d0df3206d0b32ec5 (diff)
Make WinMain linkage compatible with Qt 5
In Qt 5, the Qt5Core target was extended by Qt5CoreConfigExtras.cmake to have a generator expression as interface linkage that would conditionally link WinMain. This patch implements the same through regular interface linkage right in corelib. Since the linkage happens through a generator expression, our dependency generator does not see this as a dependency. Therefore we add this as an unconditional package dependency for corelib, on Windows. In theory this could be done also in winmain's CMakeLists.txt, as targets can be extended outside of their directory. However this adds a directory id (WinMain:@<023423>) to the linkage, which mysteriously is not removed on the exported core target. Change-Id: If2abb9ba790f51274f582c9ec28c13d968b84302 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CMake Build Bot
-rw-r--r--cmake/QtPostProcess.cmake5
-rw-r--r--src/corelib/CMakeLists.txt11
-rw-r--r--src/corelib/Qt5CoreMacros.cmake4
-rw-r--r--src/winmain/CMakeLists.txt2
4 files changed, 16 insertions, 6 deletions
diff --git a/cmake/QtPostProcess.cmake b/cmake/QtPostProcess.cmake
index 24f0621fc4..dc16514825 100644
--- a/cmake/QtPostProcess.cmake
+++ b/cmake/QtPostProcess.cmake
@@ -59,6 +59,11 @@ function(qt_internal_create_module_depends_file target)
get_target_property(target_deps "${target}" _qt_target_deps)
set(target_deps_seen "")
+ get_target_property(extra_depends "${target}" QT_EXTRA_PACKAGE_DEPENDENCIES)
+ if(NOT extra_depends STREQUAL "${extra_depends}-NOTFOUND")
+ list(APPEND target_deps ${extra_depends})
+ endif()
+
set(qtdeps "")
set(third_party_deps "")
set(third_party_deps_seen "")
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index 1932af8b6d..f6571df7c6 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -1080,6 +1080,17 @@ if(WIN32)
endif()
qt_internal_add_link_flags_gc_sections(Core PRIVATE)
+
+if(WIN32)
+ set(isExe $<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>)
+ set(isWin32 $<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>)
+ set(isNotExcluded $<NOT:$<BOOL:$<TARGET_PROPERTY:Qt5_NO_LINK_QTMAIN>>>)
+ set(isPolicyNEW $<TARGET_POLICY:CMP0020>)
+
+ target_link_libraries(Core INTERFACE $<$<AND:${isExe},${isWin32},${isNotExcluded},${isPolicyNEW}>:Qt::WinMain>)
+ qt_internal_module_info(win_main_module WinMain)
+ set_property(TARGET Core APPEND PROPERTY QT_EXTRA_PACKAGE_DEPENDENCIES "${win_main_module_versioned}\\\;${PROJECT_VERSION}")
+endif()
# special case end
qt_create_tracepoints(Core qtcore.tracepoints)
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
index 7b4c7e9d3b..738816ee4e 100644
--- a/src/corelib/Qt5CoreMacros.cmake
+++ b/src/corelib/Qt5CoreMacros.cmake
@@ -397,10 +397,6 @@ function(add_qt_gui_executable target)
endif()
target_link_libraries("${target}" PRIVATE Qt::Core Qt::Gui)
- if(WIN32)
- target_link_libraries("${target}" PRIVATE Qt::WinMain)
- endif()
-
if(ANDROID)
qt_android_generate_deployment_settings("${target}")
endif()
diff --git a/src/winmain/CMakeLists.txt b/src/winmain/CMakeLists.txt
index 10c3252f43..1095a0e907 100644
--- a/src/winmain/CMakeLists.txt
+++ b/src/winmain/CMakeLists.txt
@@ -23,6 +23,4 @@ extend_target(WinMain CONDITION NOT WINRT
extend_target(WinMain CONDITION MINGW
DEFINES QT_NEEDS_QMAIN
)
-
-extend_target(Core LIBRARIES WinMain)
# special case end