diff options
author | Alexey Edelev <alexey.edelev@qt.io> | 2021-06-16 19:24:59 +0200 |
---|---|---|
committer | Alexey Edelev <alexey.edelev@qt.io> | 2021-06-16 21:56:09 +0200 |
commit | 13a4de6bf65d29a808ecd94b382ac0c1add9e0b3 (patch) | |
tree | 0d8ee56585893ada9a6c3387ed8901e2611628e0 /cmake | |
parent | 335123f240c0b59cc62ad151dcf185160ef33696 (diff) |
Remove target specific flags from the linker capabilities check
Remove target specific flags from static_link_order.
Move the check to the common config.tests folder.
Amends 5fb99e3860eb43f4bacacec7f4a4626cb0159b14
Pick-to: 6.2
Task-number: QTBUG-93002
Task-number: QTBUG-94528
Change-Id: I1368075ec6bd1e743b2b89fd93143df38a278ec2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtBaseGlobalTargets.cmake | 4 | ||||
-rw-r--r-- | cmake/QtBuildInternals/QtBuildInternalsConfig.cmake | 2 | ||||
-rw-r--r-- | cmake/QtConfig.cmake.in | 2 | ||||
-rw-r--r-- | cmake/QtPublicTargetHelpers.cmake | 47 | ||||
-rw-r--r-- | cmake/config.tests/static_link_order/CMakeLists.txt | 22 | ||||
-rw-r--r-- | cmake/config.tests/static_link_order/main.cpp | 33 | ||||
-rw-r--r-- | cmake/config.tests/static_link_order/objlib.cpp | 33 | ||||
-rw-r--r-- | cmake/config.tests/static_link_order/staticlib1.cpp | 33 | ||||
-rw-r--r-- | cmake/config.tests/static_link_order/staticlib2.cpp | 30 |
9 files changed, 20 insertions, 186 deletions
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake index 2d858d657f..37a024ed3c 100644 --- a/cmake/QtBaseGlobalTargets.cmake +++ b/cmake/QtBaseGlobalTargets.cmake @@ -240,8 +240,8 @@ qt_copy_or_install(FILES # Install public config.tests files. qt_copy_or_install(DIRECTORY - "cmake/config.tests" - DESTINATION "${__GlobalConfig_install_dir}" + "config.tests/static_link_order" + DESTINATION "${__GlobalConfig_install_dir}/config.tests" ) # Install public CMake files. diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake index b4acfde3ac..2547282dca 100644 --- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake +++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake @@ -962,7 +962,7 @@ function(qt_internal_static_link_order_test) # TODO: This check is added before the actual release of CMake 3.21. So need to check if the # target version meets the expectations. if(CMAKE_VERSION VERSION_LESS 3.21) - __qt_internal_check_link_order_matters(${QT_CMAKE_EXPORT_NAMESPACE}::Platform) + __qt_internal_check_link_order_matters(link_order_matters) if(link_order_matters) set(summary_message "no") else() diff --git a/cmake/QtConfig.cmake.in b/cmake/QtConfig.cmake.in index 35cd3f77ca..8e080a7ea0 100644 --- a/cmake/QtConfig.cmake.in +++ b/cmake/QtConfig.cmake.in @@ -111,4 +111,4 @@ if (_Qt_NOTFOUND_MESSAGE) endif() __qt_internal_defer_promote_targets_in_dir_scope_to_global() -__qt_internal_check_link_order_matters(@INSTALL_CMAKE_NAMESPACE@::Platform) +__qt_internal_check_link_order_matters() diff --git a/cmake/QtPublicTargetHelpers.cmake b/cmake/QtPublicTargetHelpers.cmake index c5e9ce7b63..be76efd835 100644 --- a/cmake/QtPublicTargetHelpers.cmake +++ b/cmake/QtPublicTargetHelpers.cmake @@ -16,49 +16,30 @@ function(__qt_internal_strip_target_directory_scope_token target out_var) endfunction() # Tests if linker could resolve circular dependencies between object files and static libraries. -function(__qt_internal_static_link_order_public_test target result) +function(__qt_internal_static_link_order_public_test result) # We could trust iOS linker if(IOS) - set(QT_HAVE_LINK_ORDER_MATTERS_${target} "FALSE" CACHE BOOL "Link order matters") + set(QT_HAVE_LINK_ORDER_MATTERS "FALSE" CACHE BOOL "Link order matters") endif() - if(DEFINED QT_HAVE_LINK_ORDER_MATTERS_${target}) - set(${result} "${QT_HAVE_LINK_ORDER_MATTERS_${target}}" PARENT_SCOPE) + if(DEFINED QT_HAVE_LINK_ORDER_MATTERS) + set(${result} "${QT_HAVE_LINK_ORDER_MATTERS}" PARENT_SCOPE) return() endif() - set(link_options_property LINK_OPTIONS) - set(compile_definitions_property COMPILE_DEFINITIONS) - get_target_property(type ${target} TYPE) - if(type STREQUAL "INTERFACE_LIBRARY") - set(link_options_property INTERFACE_LINK_OPTIONS) - set(compile_definitions_property INTERFACE_COMPILE_DEFINITIONS) - endif() - - get_target_property(linker_options ${target} ${link_options_property}) - get_target_property(compile_definitions ${target} ${compile_definitions_property}) - set(linker_options "${CMAKE_EXE_LINKER_FLAGS} ${linker_options}") - set(compile_definitions "${CMAKE_CXX_FLAGS} ${compile_definitions}") - if(EXISTS "${QT_CMAKE_DIR}") - set(test_source_basedir "${QT_CMAKE_DIR}") + set(test_source_basedir "${QT_CMAKE_DIR}/..") else() set(test_source_basedir "${_qt_cmake_dir}/${QT_CMAKE_EXPORT_NAMESPACE}") endif() - set(test_subdir "${target}") - string(TOLOWER "${test_subdir}" test_subdir) - string(MAKE_C_IDENTIFIER "${test_subdir}" test_subdir) try_compile(${result} - "${CMAKE_CURRENT_BINARY_DIR}/${test_subdir}/config.tests/static_link_order" + "${CMAKE_CURRENT_BINARY_DIR}/config.tests/static_link_order" "${test_source_basedir}/config.tests/static_link_order" static_link_order_test static_link_order_test - CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${linker_options}" - "-DCMAKE_CXX_FLAGS:STRING=${compile_definitions}" ) - message(STATUS "Check if linker can resolve circular dependencies for target ${target} \ -- ${${result}}") + message(STATUS "Check if linker can resolve circular dependencies - ${${result}}") # Invert the result if(${result}) @@ -67,7 +48,7 @@ function(__qt_internal_static_link_order_public_test target result) set(${result} TRUE) endif() - set(QT_HAVE_LINK_ORDER_MATTERS_${target} "${${result}}" CACHE BOOL "Link order matters") + set(QT_HAVE_LINK_ORDER_MATTERS "${${result}}" CACHE BOOL "Link order matters") set(${result} "${${result}}" PARENT_SCOPE) endfunction() @@ -92,14 +73,18 @@ function(__qt_internal_set_link_order_matters target link_order_matters) endfunction() # Function combines __qt_internal_static_link_order_public_test and -# __qt_internal_set_link_order_matters calls for the target. -function(__qt_internal_check_link_order_matters target) +# __qt_internal_set_link_order_matters calls on Qt::Platform target. +function(__qt_internal_check_link_order_matters) __qt_internal_static_link_order_public_test( - ${target} link_order_matters + link_order_matters ) __qt_internal_set_link_order_matters( - ${target} "${link_order_matters}" + ${QT_CMAKE_EXPORT_NAMESPACE}::Platform "${link_order_matters}" ) + + if("${ARGC}" GREATER "0" AND NOT ARGV0 STREQUAL "") + set(${ARGV0} ${link_order_matters} PARENT_SCOPE) + endif() endfunction() function(__qt_internal_process_dependency_resource_objects target) diff --git a/cmake/config.tests/static_link_order/CMakeLists.txt b/cmake/config.tests/static_link_order/CMakeLists.txt deleted file mode 100644 index 36ce10e87c..0000000000 --- a/cmake/config.tests/static_link_order/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# The test represents the order-related issue that we have with the ld linker. -# -# CMake versions < 3.21.0 produce the following linker line: -# <binary_name> main.cpp -o static_link_order_test libstaticLib.a objlib.cpp.o -# Since 'static_link_order_test' doesn't have direct use of 'staticlib2.cpp.o' symbols -# the translation unit is not linked. When we link objlib.cpp.o it cannot resolve symbols from -# staticlib2.cpp.o. -# -# For now it's only applicable for ld-like linkers. 'lld' has no such issue. -cmake_minimum_required(VERSION 3.14) - -project(static_link_order_test LANGUAGES CXX) - -add_library(objLib OBJECT objlib.cpp) -add_library(staticLib STATIC staticlib1.cpp staticlib2.cpp) - -target_link_libraries(staticLib - INTERFACE objLib "$<TARGET_OBJECTS:objLib>" -) - -add_executable(static_link_order_test main.cpp) -target_link_libraries(static_link_order_test PRIVATE staticLib) diff --git a/cmake/config.tests/static_link_order/main.cpp b/cmake/config.tests/static_link_order/main.cpp deleted file mode 100644 index 02f10d1620..0000000000 --- a/cmake/config.tests/static_link_order/main.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the utils of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -void staticLibFunc1(); - -int main() { - staticLibFunc1(); -} diff --git a/cmake/config.tests/static_link_order/objlib.cpp b/cmake/config.tests/static_link_order/objlib.cpp deleted file mode 100644 index c3889e04d7..0000000000 --- a/cmake/config.tests/static_link_order/objlib.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the utils of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -void staticLibFunc2(); - -void objLibFunc() { - staticLibFunc2(); -} diff --git a/cmake/config.tests/static_link_order/staticlib1.cpp b/cmake/config.tests/static_link_order/staticlib1.cpp deleted file mode 100644 index b2e933e510..0000000000 --- a/cmake/config.tests/static_link_order/staticlib1.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the utils of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -void objLibFunc(); - -void staticLibFunc1() { - objLibFunc(); -} diff --git a/cmake/config.tests/static_link_order/staticlib2.cpp b/cmake/config.tests/static_link_order/staticlib2.cpp deleted file mode 100644 index 7e84289797..0000000000 --- a/cmake/config.tests/static_link_order/staticlib2.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the utils of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -void staticLibFunc2() { -} |