summaryrefslogtreecommitdiffstats
path: root/cmake/QtBaseConfigureTests.cmake
diff options
context:
space:
mode:
authorAlexey Rochev <equeim@gmail.com>2023-05-13 23:08:35 +0300
committerAlexey Rochev <equeim@gmail.com>2023-05-30 23:25:57 +0300
commitd68dbd8b7d018f0a4f0eddf558b5524f608f949a (patch)
tree46a4a962b308d45938669fa2002cad08c2b2c4e6 /cmake/QtBaseConfigureTests.cmake
parent07d6d31a4c0c17d8c897d783a9b0841df6834b02 (diff)
Fix version script test
1. Don't reassign different versions to same symbol 2. Define symbols used This fixes warnings with LLD linker (or errors if -Wl,--fatal-warnings is added by toolchain e.g. with Android NDK) 3. Add -Wl,--version-script to CMAKE_REQUIRED_LINK_OPTIONS instead of CMAKE_REQUIRED_FLAGS to prevent unused argument warning in compilation phase (there is no need for _SAVE variable because we are inside a function and our CMAKE_REQUIRED_LINK_OPTIONS won't escase its scope) 4. Fix removal of version script file (incorrect file name was used) Pick-to: 6.2 6.5 Task-number: QTBUG-111514 Change-Id: I0a1548c4268ad511760a0d4aa69ba7a0bdcbb0bc Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake/QtBaseConfigureTests.cmake')
-rw-r--r--cmake/QtBaseConfigureTests.cmake38
1 files changed, 18 insertions, 20 deletions
diff --git a/cmake/QtBaseConfigureTests.cmake b/cmake/QtBaseConfigureTests.cmake
index 20122d28f2..b62eec8410 100644
--- a/cmake/QtBaseConfigureTests.cmake
+++ b/cmake/QtBaseConfigureTests.cmake
@@ -120,35 +120,33 @@ function(qt_run_linker_version_script_support)
# 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\"")
-
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/version_flag.map" [=[
+ VERS_1 { global: sym1; };
+ VERS_2 { global: sym2; } VERS_1;
+ ]=])
+ set(CMAKE_REQUIRED_LINK_OPTIONS "")
+ list(APPEND CMAKE_REQUIRED_LINK_OPTIONS
+ "-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})
+ list(APPEND CMAKE_REQUIRED_LINK_OPTIONS ${linker_flags})
endif()
-
- 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")
+ check_cxx_source_compiles([=[
+ int sym1;
+ int sym2;
+ int main(void) { return 0; }
+ ]=] HAVE_LD_VERSION_SCRIPT)
+ file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/version_flag.map")
else()
set(HAVE_LD_VERSION_SCRIPT OFF)
endif()
- set(TEST_ld_version_script "${HAVE_LD_VERSION_SCRIPT}" CACHE INTERNAL "linker version script support")
+ set(TEST_ld_version_script "${HAVE_LD_VERSION_SCRIPT}"
+ CACHE INTERNAL "linker version script support")
list(APPEND QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT TEST_ld_version_script)
- set(QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT ${QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT} CACHE INTERNAL "Test variables that should be exported")
+ set(QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT ${QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT}
+ CACHE INTERNAL "Test variables that should be exported")
endfunction()
function(qt_internal_ensure_latest_win_nt_api)