summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmake/QtBaseGlobalTargets.cmake1
-rw-r--r--cmake/QtBuild.cmake1
-rw-r--r--cmake/QtPrlHelpers.cmake6
-rw-r--r--cmake/QtStartupHelpers.cmake16
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/corelib/CMakeLists.txt24
-rw-r--r--src/corelib/Qt6CoreConfigExtras.cmake.in2
-rw-r--r--src/corelib/Qt6CoreMacros.cmake99
-rw-r--r--src/entrypoint/CMakeLists.txt14
9 files changed, 31 insertions, 136 deletions
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake
index b6efee7ad6..73bc83aca0 100644
--- a/cmake/QtBaseGlobalTargets.cmake
+++ b/cmake/QtBaseGlobalTargets.cmake
@@ -209,7 +209,6 @@ 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 5fc98f033c..5c03c433e3 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -483,7 +483,6 @@ 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 35d321420c..e3f66c0cc8 100644
--- a/cmake/QtPrlHelpers.cmake
+++ b/cmake/QtPrlHelpers.cmake
@@ -30,9 +30,9 @@ function(qt_internal_walk_libs target out_var dict_name operation)
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
+ if(target STREQUAL "${QT_CMAKE_EXPORT_NAMESPACE}::EntryPoint")
+ # We can't (and don't need to) process EntryPoint because it brings in $<TARGET_PROPERTY:prop>
+ # genexes which get replaced with $<TARGET_PROPERTY:EntryPoint,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.
diff --git a/cmake/QtStartupHelpers.cmake b/cmake/QtStartupHelpers.cmake
deleted file mode 100644
index 15d49e3271..0000000000
--- a/cmake/QtStartupHelpers.cmake
+++ /dev/null
@@ -1,16 +0,0 @@
-# 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 platforms that have a Qt entry-point, find_package(Qt6Core) should call
- # find_package(Qt6EntryPoint) so that we can link against EntryPoint.
- if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
- qt_record_extra_qt_package_dependency("${dependent_target}" EntryPoint "${PROJECT_VERSION}")
- endif()
-endfunction()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index aa4b1b06c4..bf71322b44 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -26,6 +26,8 @@ endfunction()
find_or_build_bootstrap_names()
+add_subdirectory(entrypoint)
+
add_subdirectory(corelib)
if (QT_FEATURE_concurrent)
add_subdirectory(concurrent)
@@ -70,6 +72,4 @@ if(QT_FEATURE_gui AND QT_FEATURE_widgets)
endif()
add_subdirectory(plugins)
-add_subdirectory(entrypoint)
-
add_subdirectory(android)
diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt
index 3516bf54c6..7a33dd430e 100644
--- a/src/corelib/CMakeLists.txt
+++ b/src/corelib/CMakeLists.txt
@@ -1293,12 +1293,26 @@ endif()
qt_internal_apply_gc_binaries_conditional(Core PUBLIC)
-# Run some required internal code before creating the Startup target.
-qt_internal_setup_startup_target()
+# Add entry-point on platforms that need it. A project can opt-out of using the
+# entrypoint by setting the QT_NO_ENTRYPOINT property to TRUE on a target.
+if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
+ # find_package(Qt6Core) should call find_package(Qt6EntryPoint) so that we can
+ # link against EntryPoint. Normally this is handled automatically for deps, but
+ # for some reason it doesn't work for the EntryPoint, so we need to add it manually.
+ qt_record_extra_qt_package_dependency(Core EntryPoint "${PROJECT_VERSION}")
+
+ set(entrypoint_conditions "$<NOT:$<BOOL:$<TARGET_PROPERTY:QT_NO_ENTRYPOINT>>>")
+ list(APPEND entrypoint_conditions "$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>")
+
+ if(WIN32)
+ list(APPEND entrypoint_conditions "$<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>")
+ endif()
+
+ list(JOIN entrypoint_conditions "," entrypoint_conditions)
+ set(entrypoint_conditions "$<AND:${entrypoint_conditions}>")
-# Create the Startup target and set flags on it, so that they are already
-# available at Core build time.
-_qt_internal_setup_startup_target()
+ target_link_libraries(Core INTERFACE "$<${entrypoint_conditions}:${QT_CMAKE_EXPORT_NAMESPACE}::EntryPoint>")
+endif()
# Record darwin minimum deployment target.
if(APPLE AND CMAKE_OSX_DEPLOYMENT_TARGET)
diff --git a/src/corelib/Qt6CoreConfigExtras.cmake.in b/src/corelib/Qt6CoreConfigExtras.cmake.in
index b7c30d52be..5c4468fa10 100644
--- a/src/corelib/Qt6CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt6CoreConfigExtras.cmake.in
@@ -47,8 +47,6 @@ set(QT@PROJECT_VERSION_MAJOR@_IS_SHARED_LIBS_BUILD "@BUILD_SHARED_LIBS@")
get_filename_component(_Qt6CoreConfigDir ${CMAKE_CURRENT_LIST_FILE} PATH)
set(_Qt6CTestMacros "${_Qt6CoreConfigDir}/Qt6CTestMacros.cmake")
-_qt_internal_setup_startup_target()
-
@qtcore_extra_cmake_code@
if(ANDROID_PLATFORM)
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index cc5f58771f..926c63736d 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -1346,102 +1346,3 @@ function(_qt_internal_apply_strict_cpp target)
endif()
endif()
endfunction()
-
-# Sets up auto-linkage of platform-specific entry points.
-#
-# See qt_internal_setup_startup_target() in qtbase/cmake/QtStartupHelpers.cmake for the internal
-# implementation counterpart.
-#
-# A project that uses Qt can opt-out of this auto-linking behavior by either setting the
-# QT_NO_LINK_QTMAIN property to TRUE on a target, or by setting the
-# QT_NO_LINK_QTMAIN variable to TRUE before the find_package(Qt6) call.
-#
-# QT_NO_LINK_QTMAIN replaces the old Qt5_NO_LINK_QTMAIN name for both the property and variable
-#name.
-#
-# This function is called by Qt6CoreConfigExtras.cmake at find_package(Qt6Core) time.
-# The reason the linkage is done at find_package() time instead of Qt build time is to allow
-# opting out via a variable. This ensures compatibility with Qt5 behavior.
-# If it was done at build time, opt-out could only be achieved via the property.
-function(_qt_internal_setup_startup_target)
- set(target "${QT_CMAKE_EXPORT_NAMESPACE}::Startup")
- set(dependent_target "${QT_CMAKE_EXPORT_NAMESPACE}::Core")
-
- # Get actual Core target name.
- get_target_property(dependent_aliased_target "${dependent_target}" ALIASED_TARGET)
- if(dependent_aliased_target)
- set(dependent_target "${dependent_aliased_target}")
- endif()
-
- # Check if Core is being built as part of current CMake invocation.
- # If it is, that means the Core target scope is global and the same scope should be set for the
- # to-be-created Startup target, to avoid creating 100s of local IMPORTED Startup targets
- # when building with -DBUILD_TESTING=ON and -DBUILD_EXAMPLES=ON due to multiple
- # find_package(Qt6Core) calls.
- get_target_property(core_imported "${dependent_target}" IMPORTED)
- set(create_global "")
- if(NOT core_imported)
- set(create_global "GLOBAL")
- endif()
-
- # Create Startup only if it's not available in the current scope.
- # Guards against multiple find_package(Qt6Core) calls.
- if(NOT TARGET "${target}")
- add_library("${target}" INTERFACE IMPORTED ${create_global})
- endif()
-
- # Allow variable opt-out. Has to be after target creation, because Core always links against
- # Startup.
- if(QT_NO_LINK_QTMAIN)
- return()
- endif()
-
- # find_package(Qt6Core) can be called multiple times, but we only want to set the flags once.
- set(initialized_prop "_qt_startup_target_initialized")
- get_target_property(initialized "${target}" "${initialized_prop}")
- if(initialized)
- return()
- else()
- set_target_properties("${target}" PROPERTIES "${initialized_prop}" TRUE)
- endif()
-
- # On Windows this enables automatic linkage to QtEntryPoint.
- # On iOS this enables automatic passing of a linker flag that will change the default
- # entry point of the linked executable.
- set(isExe "$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>")
- set(isNotExcluded "$<NOT:$<BOOL:$<TARGET_PROPERTY:QT_NO_LINK_QTMAIN>>>")
- if(WIN32)
- set(isWin32 "$<BOOL:$<TARGET_PROPERTY:WIN32_EXECUTABLE>>")
- set(isPolicyNEW "$<TARGET_POLICY:CMP0020>")
- set(finalGenex "$<$<AND:${isExe},${isWin32},${isNotExcluded},${isPolicyNEW}>:Qt::EntryPoint>")
-
- # Use set_target_properties instead of target_link_libraries because the latter has some
- # weird additional behavior of checking which project the target belongs to, and might
- # error out when called multiple times from different scopes.
- set_target_properties("${target}" PROPERTIES INTERFACE_LINK_LIBRARIES "${finalGenex}")
- elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS")
- set(finalGenex "$<$<AND:${isExe},${isNotExcluded}>:Qt::EntryPoint>")
-
- set_target_properties("${target}" PROPERTIES INTERFACE_LINK_OPTIONS "${finalGenex}")
- endif()
-
- # Set up the dependency on Startup for the local Core target, if it hasn't been set yet.
- set(initialized_prop "_qt_core_startup_dependency_initialized")
- get_target_property(initialized "${dependent_target}" "${initialized_prop}")
- if(initialized)
- get_target_property(thelibs "${dependent_target}" INTERFACE_LINK_LIBRARIES)
- return()
- else()
- set_target_properties("${dependent_target}" PROPERTIES "${initialized_prop}" TRUE)
-
- # Export the initialized property on Core, to ensure that Core links against Startup
- # only once in a non-qtbase project.
- if(NOT core_imported)
- set_property(TARGET "${dependent_target}" APPEND PROPERTY
- EXPORT_PROPERTIES "${initialized_prop}")
- endif()
- endif()
-
- target_link_libraries("${dependent_target}" INTERFACE "${target}")
- get_target_property(thelibs "${dependent_target}" INTERFACE_LINK_LIBRARIES)
-endfunction()
diff --git a/src/entrypoint/CMakeLists.txt b/src/entrypoint/CMakeLists.txt
index 4445f29940..cc511883c2 100644
--- a/src/entrypoint/CMakeLists.txt
+++ b/src/entrypoint/CMakeLists.txt
@@ -81,19 +81,19 @@ endif()
# ---- Finally, make sure the static library can be consumed by clients -----
if(using_entrypoint_library)
- target_link_libraries(EntryPoint INTERFACE EntryPointImplementation)
+ target_link_libraries(EntryPoint INTERFACE Qt6::EntryPointImplementation)
qt_internal_get_target_property(entrypoint_implementation_ldflags
EntryPointImplementation QT_MODULE_LDFLAGS)
set_target_properties(EntryPoint PROPERTIES
INTERFACE_QT_MODULE_PRI_EXTRA_CONTENT "
- QT.entrypoint_implementation.name = QtEntryPointImplementation
- QT.entrypoint_implementation.module = Qt6EntryPoint
- QT.entrypoint_implementation.ldflags = ${entrypoint_implementation_ldflags}
- QT.entrypoint_implementation.libs = $$QT_MODULE_LIB_BASE
- QT.entrypoint_implementation.module_config = staticlib v2 internal_module
- "
+QT.entrypoint_implementation.name = QtEntryPointImplementation
+QT.entrypoint_implementation.module = Qt6EntryPoint
+QT.entrypoint_implementation.ldflags = ${entrypoint_implementation_ldflags}
+QT.entrypoint_implementation.libs = $$QT_MODULE_LIB_BASE
+QT.entrypoint_implementation.module_config = staticlib v2 internal_module
+"
INTERFACE_QT_MODULE_DEPENDS "entrypoint_implementation"
)