summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-10-05 16:49:53 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-10-12 13:35:48 +0200
commitc6a5cdcee6a218fe445c8c2fb3549d8b265561e4 (patch)
tree6a30fb07e7dad782a7f971db7f62c38f5e51f0e2 /cmake
parent7c12c8d113b9a7eae00e06ba75a6c6cce0d97d3d (diff)
CMake: Introduce Qt6::Startup target
Add an abstraction over Qt::WinMain (aka qtmain.lib) and iOS's runtime linker entry point (_qt_main_wrapper). The Core target will now link against the Startup target on all platforms, instead of just WinMain on Windows. The creation and linkage interface definition of the Startup target is done at find_package(Qt6Core) time via the private call of _qt_internal_setup_startup_target(). This will add automatic linkage of WinMain to executables marked with the WIN32_EXECUTABLE property on Windows. As well as the addition of the '-Wl,-e,_qt_main_wrapper' linker flag when linking iOS executables. Qt users can opt out of this behavior by either setting the QT_NO_LINK_QTMAIN property or variable. This is in line with Qt 5 behavior. Task-number: QTBUG-87060 Change-Id: I7d5e9f1be0e402cf8e67e6f55bfd285f9e6b04f4 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBaseGlobalTargets.cmake1
-rw-r--r--cmake/QtBuild.cmake1
-rw-r--r--cmake/QtPrlHelpers.cmake10
-rw-r--r--cmake/QtStartupHelpers.cmake16
4 files changed, 28 insertions, 0 deletions
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake
index dae6cb5d13..b317d191b9 100644
--- a/cmake/QtBaseGlobalTargets.cmake
+++ b/cmake/QtBaseGlobalTargets.cmake
@@ -460,6 +460,7 @@ qt_copy_or_install(FILES
cmake/QtSeparateDebugInfo.cmake
cmake/QtSetup.cmake
cmake/QtSimdHelpers.cmake
+ cmake/QtStartupHelpers.cmake
cmake/QtStandaloneTestsConfig.cmake.in
cmake/QtSyncQtHelpers.cmake
cmake/QtTargetHelpers.cmake
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index e0cad89cb9..bd186c28b9 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -478,6 +478,7 @@ include(QtRpathHelpers)
include(QtSanitizerHelpers)
include(QtScopeFinalizerHelpers)
include(QtSimdHelpers)
+include(QtStartupHelpers)
include(QtSyncQtHelpers)
include(QtTargetHelpers)
include(QtTestHelpers)
diff --git a/cmake/QtPrlHelpers.cmake b/cmake/QtPrlHelpers.cmake
index 7977afd030..932565f318 100644
--- a/cmake/QtPrlHelpers.cmake
+++ b/cmake/QtPrlHelpers.cmake
@@ -29,6 +29,16 @@ function(qt_internal_walk_libs target out_var dict_name operation)
return()
endif()
list(APPEND collected ${target})
+
+ if(target STREQUAL "${QT_CMAKE_EXPORT_NAMESPACE}::Startup")
+ # We can't (and don't need to) process Startup, because it contains $<TARGET_PROPERTY:prop>
+ # genexes which get replaced with $<TARGET_PROPERTY:Startup,prop> genexes in the code below
+ # and that causes 'INTERFACE_LIBRARY targets may only have whitelisted properties.' errors
+ # with CMake versions equal to or lower than 3.18. These errors are super unintuitive to
+ # debug because there's no mention that it's happening during a file(GENERATE) call.
+ return()
+ endif()
+
if(NOT TARGET ${dict_name})
add_library(${dict_name} INTERFACE IMPORTED GLOBAL)
endif()
diff --git a/cmake/QtStartupHelpers.cmake b/cmake/QtStartupHelpers.cmake
new file mode 100644
index 0000000000..0e7288e9cf
--- /dev/null
+++ b/cmake/QtStartupHelpers.cmake
@@ -0,0 +1,16 @@
+# Set up some internal requirements for the Startup target.
+#
+# The creation of the Startup target and its linkage setup happens in 2 places:
+# - in src/corelib/CMakeLists.txt when building qtbase.
+# - at find_package(Qt6Core) time.
+#
+# See _qt_internal_setup_startup_target() in Qt6CoreMacros.cmake for the implementation of that.
+function(qt_internal_setup_startup_target)
+ set(dependent_target "Core")
+
+ # On windows, find_package(Qt6Core) should call find_package(Qt6WinMain) so that Startup can
+ # link against WinMain.
+ if(WIN32)
+ qt_record_extra_qt_package_dependency("${dependent_target}" WinMain "${PROJECT_VERSION}")
+ endif()
+endfunction()