"Simplify" versionless targets
Versionless targets in Qt6 are interface libraries that link the versioned libraries using the INTERFACE link type. This makes the linking chain more complicated than it can be. Also we miss some significant interface properties in the versionless targets comparing to the versioned targets. The new approach manually generates the versionless targets, instead of using CMake exports. For CMake versions < 3.18 we now create a copy of the versioned targets. The copy includes all the relevant INTERFACE properties from the versioned targets and imported locations for all configs. For CMake versions >= 3.18 we now create the versionless target ALIASes which should behave give the transparent access to the versioned targets. Using the QT_USE_OLD_VERSION_LESS_TARGETS flag you may force the behavor of the CMake versions <= 3.18 The change is partial workaround for QTBUG-86533. Task-number: QTBUG-114706 Change-Id: Iafadf6154eb4912df0697648c031fcc1cbde04e0 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
a1d18276a8
commit
173164cd47
@ -23,7 +23,11 @@ if (NOT QT_NO_CREATE_TARGETS)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@AdditionalTargetInfo.cmake")
|
||||
if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@VersionlessTargets.cmake")
|
||||
if(CMAKE_VERSION VERSION_LESS 3.18 OR QT_USE_OLD_VERSION_LESS_TARGETS)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@VersionlessTargets.cmake")
|
||||
else()
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@VersionlessAliasTargets.cmake")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -310,6 +310,7 @@ function(qt_internal_add_3rdparty_library target)
|
||||
qt_internal_export_modern_cmake_config_targets_file(
|
||||
TARGETS ${target}
|
||||
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
|
||||
CONFIG_BUILD_DIR "${config_build_dir}"
|
||||
CONFIG_INSTALL_DIR "${config_install_dir}"
|
||||
)
|
||||
|
||||
|
@ -159,9 +159,10 @@ qt_install(EXPORT ${__export_name}
|
||||
DESTINATION "${__GlobalConfig_install_dir}")
|
||||
|
||||
qt_internal_export_modern_cmake_config_targets_file(TARGETS ${__export_targets}
|
||||
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}
|
||||
CONFIG_INSTALL_DIR
|
||||
${__GlobalConfig_install_dir})
|
||||
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}
|
||||
CONFIG_BUILD_DIR "${__GlobalConfig_build_dir}"
|
||||
CONFIG_INSTALL_DIR "${__GlobalConfig_install_dir}"
|
||||
)
|
||||
|
||||
# Save minimum required CMake version to use Qt.
|
||||
qt_internal_get_supported_min_cmake_version_for_using_qt(supported_min_version_for_using_qt)
|
||||
|
@ -253,6 +253,8 @@ function(qt_internal_get_qt_build_private_files_to_install out_var)
|
||||
QtSeparateDebugInfo.Info.plist.in
|
||||
QtSetup.cmake
|
||||
QtStandaloneTestsConfig.cmake.in
|
||||
QtVersionlessAliasTargets.cmake.in
|
||||
QtVersionlessTargets.cmake.in
|
||||
QtWriteArgsFile.cmake
|
||||
modulecppexports.h.in
|
||||
qbatchedtestrunner.in.cpp
|
||||
|
@ -7,6 +7,7 @@ cmake_minimum_required(VERSION @min_new_policy_version@...@max_new_policy_versio
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@ConfigExtras.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicCMakeVersionHelpers.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicCMakeHelpers.cmake")
|
||||
__qt_internal_require_suitable_cmake_version_for_using_qt()
|
||||
|
||||
get_filename_component(_qt_cmake_dir "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
|
||||
@ -15,7 +16,11 @@ set(_qt_@PROJECT_VERSION_MAJOR@_config_cmake_dir "${CMAKE_CURRENT_LIST_DIR}")
|
||||
if (NOT QT_NO_CREATE_TARGETS)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Targets.cmake")
|
||||
if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@VersionlessTargets.cmake")
|
||||
if(CMAKE_VERSION VERSION_LESS 3.18 OR QT_USE_OLD_VERSION_LESS_TARGETS)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@VersionlessTargets.cmake")
|
||||
else()
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@VersionlessAliasTargets.cmake")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
# For examples using `find_package(...)` inside their CMakeLists.txt files:
|
||||
|
@ -32,9 +32,6 @@ if (NOT QT_NO_CREATE_TARGETS AND @INSTALL_CMAKE_NAMESPACE@@target@_FOUND)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@AdditionalTargetInfo.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@ExtraProperties.cmake"
|
||||
OPTIONAL)
|
||||
if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@VersionlessTargets.cmake")
|
||||
endif()
|
||||
|
||||
# DEPRECATED
|
||||
# Provide old style variables for includes, compile definitions, etc.
|
||||
@ -131,6 +128,14 @@ if (TARGET @QT_CMAKE_EXPORT_NAMESPACE@::@target@)
|
||||
EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@BuildInternals.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@BuildInternals.cmake")
|
||||
endif()
|
||||
|
||||
if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS)
|
||||
if(CMAKE_VERSION VERSION_LESS 3.18 OR QT_USE_OLD_VERSION_LESS_TARGETS)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@VersionlessTargets.cmake")
|
||||
else()
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@VersionlessAliasTargets.cmake")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
|
||||
set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
|
||||
|
@ -834,7 +834,9 @@ set(QT_ALLOW_MISSING_TOOLS_PACKAGES TRUE)")
|
||||
qt_internal_export_modern_cmake_config_targets_file(
|
||||
TARGETS ${exported_targets}
|
||||
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
|
||||
CONFIG_INSTALL_DIR "${config_install_dir}")
|
||||
CONFIG_BUILD_DIR "${config_build_dir}"
|
||||
CONFIG_INSTALL_DIR "${config_install_dir}"
|
||||
)
|
||||
|
||||
qt_internal_export_genex_properties(TARGETS ${target}
|
||||
EXPORT_NAME_PREFIX ${INSTALL_CMAKE_NAMESPACE}${target}
|
||||
|
@ -153,6 +153,12 @@ function(qt_get_direct_module_dependencies target out_var)
|
||||
list(PREPEND libs ${ifacelibs})
|
||||
continue()
|
||||
endif()
|
||||
get_target_property(aliased_target ${lib} ALIASED_TARGET)
|
||||
if(TARGET "${aliased_target}")
|
||||
# If versionless target is alias, use what the alias points to.
|
||||
list(PREPEND libs "${aliased_target}")
|
||||
continue()
|
||||
endif()
|
||||
if(lib_type STREQUAL "OBJECT_LIBRARY")
|
||||
# Skip object libraries, because they're already part of ${target}.
|
||||
continue()
|
||||
|
@ -266,3 +266,152 @@ function(_qt_internal_add_phony_target_deferred target)
|
||||
cmake_language(CALL ${creation_hook} ${target})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# The helper function that checks if module was included multiple times, and has the inconsistent
|
||||
# set of targets that belong to the module. It's expected that either all 'targets' or none of them
|
||||
# will be written to the 'targets_not_defined' variable, if the module was not or was
|
||||
# searched before accordingly.
|
||||
function(_qt_internal_check_multiple_inclusion targets_not_defined targets)
|
||||
set(targets_defined "")
|
||||
set(${targets_not_defined} "")
|
||||
set(expected_targets "")
|
||||
foreach(expected_target ${targets})
|
||||
list(APPEND expected_targets ${expected_target})
|
||||
if(NOT TARGET Qt::${expected_target})
|
||||
list(APPEND ${targets_not_defined} ${expected_target})
|
||||
endif()
|
||||
if(TARGET Qt::${expected_target})
|
||||
list(APPEND targets_defined ${expected_target})
|
||||
endif()
|
||||
endforeach()
|
||||
if("${targets_defined}" STREQUAL "${expected_targets}")
|
||||
set(${targets_not_defined} "" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
if(NOT "${targets_defined}" STREQUAL "")
|
||||
message(FATAL_ERROR "Some (but not all) targets in this export set were already defined."
|
||||
"\nTargets Defined: ${targets_defined}\nTargets not yet defined: "
|
||||
"${${targets_not_defined}}\n"
|
||||
)
|
||||
endif()
|
||||
set(${targets_not_defined} "${${targets_not_defined}}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# The function is used when creating version less targets using ALIASes.
|
||||
function(_qt_internal_create_versionless_alias_targets targets install_namespace)
|
||||
foreach(target IN LISTS targets)
|
||||
add_library(Qt::${target} ALIAS ${install_namespace}::${target})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
# The function is used when creating version less targets from scratch but not using ALIASes.
|
||||
# It assigns the known properties from the versioned targets to the versionless created in this
|
||||
# function. This allows versionless targets mimic the versioned.
|
||||
function(_qt_internal_create_versionless_targets targets install_namespace)
|
||||
set(known_interface_properties
|
||||
QT_MAJOR_VERSION
|
||||
AUTOMOC_MACRO_NAMES
|
||||
AUTOUIC_OPTIONS
|
||||
COMPILE_DEFINITIONS
|
||||
COMPILE_FEATURES
|
||||
COMPILE_OPTIONS
|
||||
CXX_MODULE_SETS
|
||||
HEADER_SETS
|
||||
HEADER_SETS_TO_VERIFY
|
||||
INCLUDE_DIRECTORIES
|
||||
LINK_DEPENDS
|
||||
LINK_DIRECTORIES
|
||||
LINK_LIBRARIES
|
||||
LINK_LIBRARIES_DIRECT
|
||||
LINK_LIBRARIES_DIRECT_EXCLUDE
|
||||
LINK_OPTIONS
|
||||
POSITION_INDEPENDENT_CODE
|
||||
PRECOMPILE_HEADERS
|
||||
SOURCES
|
||||
SYSTEM_INCLUDE_DIRECTORIES
|
||||
)
|
||||
|
||||
set(known_qt_exported_properties
|
||||
MODULE_PLUGIN_TYPES
|
||||
QT_DISABLED_PRIVATE_FEATURES
|
||||
QT_DISABLED_PUBLIC_FEATURES
|
||||
QT_ENABLED_PRIVATE_FEATURES
|
||||
QT_ENABLED_PUBLIC_FEATURES
|
||||
QT_QMAKE_PRIVATE_CONFIG
|
||||
QT_QMAKE_PUBLIC_CONFIG
|
||||
QT_QMAKE_PUBLIC_QT_CONFIG
|
||||
_qt_config_module_name
|
||||
_qt_is_public_module
|
||||
_qt_module_has_headers
|
||||
_qt_module_has_private_headers
|
||||
_qt_module_has_public_headers
|
||||
_qt_module_has_qpa_headers
|
||||
_qt_module_has_rhi_headers
|
||||
_qt_module_include_name
|
||||
_qt_module_interface_name
|
||||
_qt_package_name
|
||||
_qt_package_version
|
||||
_qt_private_module_target_name
|
||||
)
|
||||
|
||||
set(supported_target_types STATIC_LIBRARY MODULE_LIBRARY SHARED_LIBRARY OBJECT_LIBRARY
|
||||
INTERFACE_LIBRARY)
|
||||
|
||||
foreach(target IN LISTS targets)
|
||||
if(NOT TARGET ${install_namespace}::${target})
|
||||
message(FATAL_ERROR "${install_namespace}::${target} is not a target, can not extend"
|
||||
" an alias target")
|
||||
endif()
|
||||
|
||||
get_target_property(type ${install_namespace}::${target} TYPE)
|
||||
if(NOT type)
|
||||
message(FATAL_ERROR "Cannot get the ${install_namespace}::${target} target type.")
|
||||
endif()
|
||||
|
||||
if(NOT "${type}" IN_LIST supported_target_types)
|
||||
message(AUTHOR_WARNING "${install_namespace}::${target} requires the versionless"
|
||||
" target creation, but it has incompatible type ${type}.")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
string(REPLACE "_LIBRARY" "" creation_type "${type}")
|
||||
add_library(Qt::${target} ${creation_type} IMPORTED)
|
||||
|
||||
if(NOT "${type}" STREQUAL "INTERFACE_LIBRARY")
|
||||
foreach(config "" _RELEASE _DEBUG _RELWITHDEBINFO _MINSIZEREL)
|
||||
get_target_property(target_imported_location
|
||||
${install_namespace}::${target} IMPORTED_LOCATION${config})
|
||||
if(NOT target_imported_location)
|
||||
if("${config}" STREQUAL "")
|
||||
message(FATAL_ERROR "Cannot create versionless target for"
|
||||
" ${install_namespace}::${target}. IMPORTED_LOCATION property is "
|
||||
"missing."
|
||||
)
|
||||
else()
|
||||
continue()
|
||||
endif()
|
||||
endif()
|
||||
set_property(TARGET Qt::${target} PROPERTY
|
||||
IMPORTED_LOCATION${config} "${target_imported_location}")
|
||||
endforeach()
|
||||
|
||||
foreach(property IN LISTS known_qt_exported_properties)
|
||||
get_target_property(exported_property_value
|
||||
${install_namespace}::${target} ${property})
|
||||
if(exported_property_value)
|
||||
set_property(TARGET Qt::${target} APPEND PROPERTY
|
||||
${property} "${exported_property_value}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
foreach(property IN LISTS known_interface_properties)
|
||||
get_target_property(interface_property_value
|
||||
${install_namespace}::${target} INTERFACE_${property})
|
||||
if(interface_property_value)
|
||||
set_property(TARGET Qt::${target} APPEND PROPERTY
|
||||
INTERFACE_${property} "${interface_property_value}")
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
@ -1004,25 +1004,51 @@ unset(_qt_imported_configs)")
|
||||
endfunction()
|
||||
|
||||
function(qt_internal_export_modern_cmake_config_targets_file)
|
||||
cmake_parse_arguments(__arg "" "EXPORT_NAME_PREFIX;CONFIG_INSTALL_DIR" "TARGETS" ${ARGN})
|
||||
cmake_parse_arguments(arg
|
||||
""
|
||||
"EXPORT_NAME_PREFIX;CONFIG_BUILD_DIR;CONFIG_INSTALL_DIR"
|
||||
"TARGETS"
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
set(export_name "${__arg_EXPORT_NAME_PREFIX}VersionlessTargets")
|
||||
foreach(target ${__arg_TARGETS})
|
||||
if (TARGET "${target}Versionless")
|
||||
continue()
|
||||
endif()
|
||||
if("${arg_TARGETS}" STREQUAL "")
|
||||
message(FATAL_ERROR "Target list is empty")
|
||||
endif()
|
||||
|
||||
add_library("${target}Versionless" INTERFACE)
|
||||
target_link_libraries("${target}Versionless" INTERFACE "${target}")
|
||||
set_target_properties("${target}Versionless" PROPERTIES
|
||||
EXPORT_NAME "${target}"
|
||||
_qt_is_versionless_target "TRUE")
|
||||
set_property(TARGET "${target}Versionless"
|
||||
APPEND PROPERTY EXPORT_PROPERTIES _qt_is_versionless_target)
|
||||
if("${arg_CONFIG_BUILD_DIR}" STREQUAL "")
|
||||
message(FATAL_ERROR "CONFIG_BUILD_DIR is not specified")
|
||||
endif()
|
||||
|
||||
qt_install(TARGETS "${target}Versionless" EXPORT ${export_name})
|
||||
endforeach()
|
||||
qt_install(EXPORT ${export_name} NAMESPACE Qt:: DESTINATION "${__arg_CONFIG_INSTALL_DIR}")
|
||||
if("${arg_CONFIG_INSTALL_DIR}" STREQUAL "")
|
||||
message(FATAL_ERROR "CONFIG_INSTALL_DIR is not specified")
|
||||
endif()
|
||||
|
||||
if("${arg_EXPORT_NAME_PREFIX}" STREQUAL "")
|
||||
message(FATAL_ERROR "EXPORT_NAME_PREFIX is not specified")
|
||||
endif()
|
||||
|
||||
set(versionless_targets ${arg_TARGETS})
|
||||
|
||||
# CMake versions < 3.18 compatibility code. Creates the mimics of the versioned libraries.
|
||||
set(versionless_targets_export "${arg_CONFIG_BUILD_DIR}/${arg_EXPORT_NAME_PREFIX}VersionlessTargets.cmake")
|
||||
configure_file("${QT_CMAKE_DIR}/QtVersionlessTargets.cmake.in"
|
||||
"${versionless_targets_export}"
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# CMake versions >= 3.18 code. Create the versionless ALIAS targets.
|
||||
set(alias_export "${arg_CONFIG_BUILD_DIR}/${arg_EXPORT_NAME_PREFIX}VersionlessAliasTargets.cmake")
|
||||
configure_file("${QT_CMAKE_DIR}/QtVersionlessAliasTargets.cmake.in"
|
||||
"${alias_export}"
|
||||
@ONLY
|
||||
)
|
||||
|
||||
qt_install(FILES
|
||||
"${alias_export}"
|
||||
"${versionless_targets_export}"
|
||||
DESTINATION "${arg_CONFIG_INSTALL_DIR}"
|
||||
COMPONENT Devel
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(qt_internal_create_tracepoints name tracepoints_file)
|
||||
|
7
cmake/QtVersionlessAliasTargets.cmake.in
Normal file
7
cmake/QtVersionlessAliasTargets.cmake.in
Normal file
@ -0,0 +1,7 @@
|
||||
# Protect against multiple inclusion, which would fail when already imported targets are
|
||||
# added once more.
|
||||
_qt_internal_check_multiple_inclusion(_targets_not_defined "@versionless_targets@")
|
||||
|
||||
_qt_internal_create_versionless_alias_targets("${_targets_not_defined}" @INSTALL_CMAKE_NAMESPACE@)
|
||||
|
||||
unset(_targets_not_defined)
|
7
cmake/QtVersionlessTargets.cmake.in
Normal file
7
cmake/QtVersionlessTargets.cmake.in
Normal file
@ -0,0 +1,7 @@
|
||||
# Protect against multiple inclusion, which would fail when already imported targets are
|
||||
# added once more.
|
||||
_qt_internal_check_multiple_inclusion(_targets_not_defined "@versionless_targets@")
|
||||
|
||||
_qt_internal_create_versionless_targets("${_targets_not_defined}" @INSTALL_CMAKE_NAMESPACE@)
|
||||
|
||||
unset(_targets_not_defined)
|
@ -5,22 +5,99 @@ cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(versionless_targets)
|
||||
|
||||
set(QT_NO_CREATE_VERSIONLESS_TARGETS ON)
|
||||
function(check_versionless_targets)
|
||||
set(known_interface_properties
|
||||
QT_MAJOR_VERSION
|
||||
AUTOMOC_MACRO_NAMES
|
||||
AUTOUIC_OPTIONS
|
||||
COMPILE_DEFINITIONS
|
||||
COMPILE_FEATURES
|
||||
COMPILE_OPTIONS
|
||||
CXX_MODULE_SETS
|
||||
HEADER_SETS
|
||||
HEADER_SETS_TO_VERIFY
|
||||
INCLUDE_DIRECTORIES
|
||||
LINK_DEPENDS
|
||||
LINK_DIRECTORIES
|
||||
LINK_LIBRARIES
|
||||
LINK_LIBRARIES_DIRECT
|
||||
LINK_LIBRARIES_DIRECT_EXCLUDE
|
||||
LINK_OPTIONS
|
||||
POSITION_INDEPENDENT_CODE
|
||||
PRECOMPILE_HEADERS
|
||||
SOURCES
|
||||
SYSTEM_INCLUDE_DIRECTORIES
|
||||
)
|
||||
|
||||
find_package(Qt6Core REQUIRED)
|
||||
set(known_qt_exported_properties
|
||||
MODULE_PLUGIN_TYPES
|
||||
QT_DISABLED_PRIVATE_FEATURES
|
||||
QT_DISABLED_PUBLIC_FEATURES
|
||||
QT_ENABLED_PRIVATE_FEATURES
|
||||
QT_ENABLED_PUBLIC_FEATURES
|
||||
QT_QMAKE_PRIVATE_CONFIG
|
||||
QT_QMAKE_PUBLIC_CONFIG
|
||||
QT_QMAKE_PUBLIC_QT_CONFIG
|
||||
_qt_config_module_name
|
||||
_qt_is_public_module
|
||||
_qt_module_has_headers
|
||||
_qt_module_has_private_headers
|
||||
_qt_module_has_public_headers
|
||||
_qt_module_has_qpa_headers
|
||||
_qt_module_has_rhi_headers
|
||||
_qt_module_include_name
|
||||
_qt_module_interface_name
|
||||
_qt_package_name
|
||||
_qt_package_version
|
||||
_qt_private_module_target_name
|
||||
)
|
||||
|
||||
if (NOT TARGET Qt6::Core)
|
||||
message(SEND_ERROR "Qt6::Core target not defined!")
|
||||
endif()
|
||||
foreach(prop ${known_interface_properties})
|
||||
set(versionless_prop "")
|
||||
set(versioned_prop "")
|
||||
get_target_property(versionless_prop Qt::Core INTERFACE_${prop})
|
||||
get_target_property(versioned_prop Qt6::Core INTERFACE_${prop})
|
||||
if(NOT versionless_prop AND NOT versioned_prop)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
if (TARGET Qt::Core)
|
||||
message(SEND_ERROR "Qt::Core target defined despite QT_NO_CREATE_VERSIONLESS_TARGETS!")
|
||||
endif()
|
||||
if(NOT "${versionless_prop}" STREQUAL "${versioned_prop}")
|
||||
message(SEND_ERROR "INTERFACE_${prop} doesn't match versionless ${versionless_prop}"
|
||||
" versioned ${versioned_prop}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(QT_NO_CREATE_VERSIONLESS_TARGETS OFF)
|
||||
foreach(prop ${known_qt_exported_properties})
|
||||
set(versionless_prop "")
|
||||
set(versioned_prop "")
|
||||
get_target_property(versionless_prop Qt::Core ${prop})
|
||||
get_target_property(versioned_prop Qt6::Core ${prop})
|
||||
if(NOT versionless_prop AND NOT versioned_prop)
|
||||
continue()
|
||||
endif()
|
||||
|
||||
find_package(Qt6Core REQUIRED)
|
||||
if(NOT "${versionless_prop}" STREQUAL "${versioned_prop}")
|
||||
message(SEND_ERROR "${prop} doesn't match versionless ${versionless_prop}"
|
||||
" versioned ${versioned_prop}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if (NOT TARGET Qt::Core)
|
||||
message(SEND_ERROR "Qt::Core target not defined!")
|
||||
endif()
|
||||
foreach(conf "" _RELEASE _DEBUG _RELWITHDEBINFO _MINSIZEREL)
|
||||
set(versionless_prop "")
|
||||
set(versioned_prop "")
|
||||
get_target_property(versionless_prop Qt::Core IMPORTED_LOCATION${conf})
|
||||
get_target_property(versioned_prop Qt6::Core IMPORTED_LOCATION${conf})
|
||||
if(NOT versionless_prop AND NOT versioned_prop)
|
||||
continue()
|
||||
endif()
|
||||
if(NOT "${versionless_prop}" STREQUAL "${versioned_prop}")
|
||||
message(SEND_ERROR "IMPORTED_LOCATION${conf} doesn't match versionless ${versionless_prop}"
|
||||
" versioned ${versioned_prop}")
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
add_subdirectory(default)
|
||||
add_subdirectory(force_off)
|
||||
add_subdirectory(force_on)
|
||||
add_subdirectory(force_old)
|
||||
|
@ -0,0 +1,17 @@
|
||||
# Copyright (C) 2024 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
message("Test default creating of versionless targets")
|
||||
find_package(Qt6Core REQUIRED)
|
||||
|
||||
if(NOT TARGET Qt6::Core)
|
||||
message(SEND_ERROR "Qt6::Core target not defined!")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET Qt::Core)
|
||||
message(SEND_ERROR "Qt::Core target not defined!")
|
||||
endif()
|
||||
|
||||
check_versionless_targets()
|
@ -0,0 +1,18 @@
|
||||
# Copyright (C) 2024 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
message("Test disabled versionless targets")
|
||||
|
||||
set(QT_NO_CREATE_VERSIONLESS_TARGETS ON)
|
||||
|
||||
find_package(Qt6Core REQUIRED)
|
||||
|
||||
if(NOT TARGET Qt6::Core)
|
||||
message(SEND_ERROR "Qt6::Core target not defined!")
|
||||
endif()
|
||||
|
||||
if(TARGET Qt::Core)
|
||||
message(SEND_ERROR "Qt::Core target defined despite QT_NO_CREATE_VERSIONLESS_TARGETS!")
|
||||
endif()
|
@ -0,0 +1,21 @@
|
||||
# Copyright (C) 2024 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
message("Test force old versionless targets")
|
||||
|
||||
set(QT_USE_OLD_VERSION_LESS_TARGETS ON)
|
||||
|
||||
find_package(Qt6Core REQUIRED)
|
||||
|
||||
if(NOT TARGET Qt6::Core)
|
||||
message(SEND_ERROR "Qt6::Core target not defined!")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET Qt::Core)
|
||||
message(SEND_ERROR "Qt::Core target not defined!")
|
||||
endif()
|
||||
|
||||
check_versionless_targets()
|
||||
|
@ -0,0 +1,20 @@
|
||||
# Copyright (C) 2024 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
message("Test enabled versionless targets")
|
||||
|
||||
set(QT_NO_CREATE_VERSIONLESS_TARGETS OFF)
|
||||
|
||||
find_package(Qt6Core REQUIRED)
|
||||
|
||||
if(NOT TARGET Qt6::Core)
|
||||
message(SEND_ERROR "Qt6::Core target not defined!")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET Qt::Core)
|
||||
message(SEND_ERROR "Qt::Core target not defined!")
|
||||
endif()
|
||||
|
||||
check_versionless_targets()
|
Loading…
x
Reference in New Issue
Block a user