diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-08-21 12:59:24 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-08-23 11:04:46 +0200 |
commit | 7e7c9ba45554cd4c2f9a80ad61c3d2a0f9599f9b (patch) | |
tree | 71d327ae2dd10f9280d4a008582bf55b25aa0c58 /cmake | |
parent | 48cf015906e34ea0f8a388fd3a0e53ec082546f2 (diff) |
CMake: Support configure tests of type 'linkerSupportsFlag'
Task-number: QTBUG-86155
Change-Id: I3764d99cd4ad1c432b499ec9ba7c4c48391fa421
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtFeature.cmake | 28 | ||||
-rw-r--r-- | cmake/QtProcessConfigureArgs.cmake | 1 |
2 files changed, 29 insertions, 0 deletions
diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake index 5002a53352..66242548ed 100644 --- a/cmake/QtFeature.cmake +++ b/cmake/QtFeature.cmake @@ -881,6 +881,34 @@ function(qt_config_compiler_supports_flag_test name) set(TEST_${name} "${TEST_${name}}" CACHE INTERNAL "${label}") endfunction() +function(qt_config_linker_supports_flag_test name) + if(DEFINED "TEST_${name}") + return() + endif() + + cmake_parse_arguments(arg "" "LABEL;FLAG" "" ${ARGN}) + set(flags "-Wl,${arg_FLAG}") + + # Select the right linker. + if(GCC OR CLANG) + # TODO: This works for now but is... suboptimal. Once + # QTBUG-86186 is resolved, we should check the *features* + # QT_FEATURE_use_gold_linker etc. instead of trying to + # replicate the feature conditions. + if(QT_FEATURE_use_gold_linker_alias OR INPUT_linker STREQUAL "gold") + list(PREPEND flags "-fuse-ld=gold") + elseif(INPUT_linker STREQUAL "bfd") + list(PREPEND flags "-fuse-ld=bfd") + elseif(INPUT_linker STREQUAL "lld") + list(PREPEND flags "-fuse-ld=lld") + endif() + endif() + + set(CMAKE_REQUIRED_LINK_OPTIONS ${flags}) + check_cxx_source_compiles("int main() { return 0; }" TEST_${name}) + set(TEST_${name} "${TEST_${name}}" CACHE INTERNAL "${label}") +endfunction() + function(qt_make_features_available target) if(NOT "${target}" MATCHES "^${QT_CMAKE_EXPORT_NAMESPACE}::[a-zA-Z0-9_-]*$") message(FATAL_ERROR "${target} does not match ${QT_CMAKE_EXPORT_NAMESPACE}::[a-zA-Z0-9_-]*. INVALID NAME.") diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index 7e3f789a7c..5e8e2677e7 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -97,6 +97,7 @@ defstub(qt_config_compile_test) defstub(qt_config_compile_test_machine_tuple) defstub(qt_config_compile_test_x86simd) defstub(qt_config_compiler_supports_flag_test) +defstub(qt_config_linker_supports_flag_test) defstub(qt_configure_add_report_entry) defstub(qt_configure_add_summary_build_mode) defstub(qt_configure_add_summary_build_parts) |