diff options
author | Alexey Rochev <equeim@gmail.com> | 2023-05-20 22:57:02 +0300 |
---|---|---|
committer | Alexey Rochev <equeim@gmail.com> | 2023-05-23 01:44:27 +0300 |
commit | bc85390dccd08ec99682106b835b97928b61894f (patch) | |
tree | 6e004d9e6391b41c3c676562a1b27de9279b06b9 /cmake | |
parent | 313bb32364e106e111b8518b786c4364770aaaac (diff) |
Don't run version script test when its result won't be used
Pick-to: 6.2 6.5
Task-number: QTBUG-111514
Change-Id: Ibcac8cd591125f173e906e256d08593764a1cf66
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtBaseConfigureTests.cmake | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/cmake/QtBaseConfigureTests.cmake b/cmake/QtBaseConfigureTests.cmake index b79294261c..20122d28f2 100644 --- a/cmake/QtBaseConfigureTests.cmake +++ b/cmake/QtBaseConfigureTests.cmake @@ -115,37 +115,34 @@ endfunction() function(qt_run_linker_version_script_support) - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/version_flag.map" "VERS_1 { global: sym; }; + # For some reason the linker command line written by the XCode generator, which is + # subsequently executed by xcodebuild, ignores the linker flag, and thus the test + # seemingly succeeds. Explicitly disable the version script test on darwin platforms. + # Also makes no sense with MSVC-style command-line + if(NOT APPLE AND NOT MSVC) + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/version_flag.map" "VERS_1 { global: sym; }; VERS_2 { global: sym; } VERS_1; ") - if(DEFINED CMAKE_REQUIRED_FLAGS) - set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) - else() - set(CMAKE_REQUIRED_FLAGS "") - endif() - set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=\"${CMAKE_CURRENT_BINARY_DIR}/version_flag.map\"") - - # Pass the linker that the main project uses to the version script compile test. - qt_internal_get_active_linker_flags(linker_flags) - if(linker_flags) - set(CMAKE_REQUIRED_LINK_OPTIONS ${linker_flags}) - endif() + if(DEFINED CMAKE_REQUIRED_FLAGS) + set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) + else() + set(CMAKE_REQUIRED_FLAGS "") + endif() + set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=\"${CMAKE_CURRENT_BINARY_DIR}/version_flag.map\"") - check_cxx_source_compiles("int main(void){return 0;}" HAVE_LD_VERSION_SCRIPT) - if(DEFINED CMAKE_REQUIRED_FLAGS_SAVE) - set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) - endif() - file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map") + # Pass the linker that the main project uses to the version script compile test. + qt_internal_get_active_linker_flags(linker_flags) + if(linker_flags) + set(CMAKE_REQUIRED_LINK_OPTIONS ${linker_flags}) + endif() - # For some reason the linker command line written by the XCode generator, which is - # subsequently executed by xcodebuild, ignores the linker flag, and thus the test - # seemingly succeeds. Explicitly disable the version script test on darwin platforms. - if(APPLE) - set(HAVE_LD_VERSION_SCRIPT OFF) - endif() - # Also makes no sense with MSVC-style command-line - if(MSVC) + check_cxx_source_compiles("int main(void){return 0;}" HAVE_LD_VERSION_SCRIPT) + if(DEFINED CMAKE_REQUIRED_FLAGS_SAVE) + set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) + endif() + file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map") + else() set(HAVE_LD_VERSION_SCRIPT OFF) endif() |