mdbx-cmake: fix/refine --allow-multiple-definition as workaround for std::filesystem and LCC < 1.25.23

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2022-04-22 23:03:58 +03:00
parent b327cafe1a
commit 42f1abd7e9
3 changed files with 15 additions and 2 deletions

View File

@ -621,7 +621,7 @@ macro(libmdbx_setup_libs TARGET MODE)
target_link_libraries(${TARGET} ${MODE} log)
endif()
if(LIBCXX_FILESYSTEM AND MDBX_BUILD_CXX)
if(CMAKE_COMPILER_IS_ELBRUSCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 1.26.0
if(CMAKE_COMPILER_IS_ELBRUSCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 1.25.23
AND NOT CMAKE_VERSION VERSION_LESS 3.13)
target_link_options(${TARGET} PUBLIC "-Wl,--allow-multiple-definition")
endif()

View File

@ -913,6 +913,8 @@ macro(probe_libcxx_filesystem)
include(CheckCXXSourceCompiles)
cmake_push_check_state()
set(stdfs_probe_save_libraries ${CMAKE_REQUIRED_LIBRARIES})
set(stdfs_probe_save_flags ${CMAKE_REQUIRED_FLAGS})
set(stdfs_probe_save_link_options ${CMAKE_REQUIRED_LINK_OPTIONS})
unset(stdfs_probe_clear_cxx_standard)
if(NOT DEFINED CMAKE_CXX_STANDARD)
list(FIND CMAKE_CXX_COMPILE_FEATURES cxx_std_14 HAS_CXX14)
@ -927,6 +929,13 @@ macro(probe_libcxx_filesystem)
endif()
set(stdfs_probe_clear_cxx_standard ON)
endif()
if(CMAKE_COMPILER_IS_ELBRUSCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 1.25.23)
if(CMAKE_VERSION VERSION_LESS 3.14)
set(CMAKE_REQUIRED_FLAGS ${stdfs_probe_save_flags} "-Wl,--allow-multiple-definition")
else()
set(CMAKE_REQUIRED_LINK_OPTIONS ${stdfs_probe_save_link_options} "-Wl,--allow-multiple-definition")
endif()
endif()
set(stdfs_probe_code [[
#if defined(__SIZEOF_INT128__) && !defined(__GLIBCXX_TYPE_INT_N_0) && defined(__clang__) && __clang_major__ < 4
@ -994,11 +1003,15 @@ macro(probe_libcxx_filesystem)
endif()
endif()
set(CMAKE_REQUIRED_LINK_OPTIONS ${stdfs_probe_save_link_options})
set(CMAKE_REQUIRED_FLAGS ${stdfs_probe_save_flags})
set(CMAKE_REQUIRED_LIBRARIES ${stdfs_probe_save_libraries})
if(stdfs_probe_clear_cxx_standard)
unset(CMAKE_CXX_STANDARD)
endif()
unset(stdfs_probe_clear_cxx_standard)
unset(stdfs_probe_save_link_options)
unset(stdfs_probe_save_flags)
unset(stdfs_probe_save_libraries)
unset(stdfs_probe_code)
unset(stdfs_probe_rc)

View File

@ -47,7 +47,7 @@ set_target_properties(mdbx_test PROPERTIES
target_setup_options(mdbx_test)
if(NOT MDBX_BUILD_CXX AND LIBCXX_FILESYSTEM)
if(CMAKE_COMPILER_IS_ELBRUSCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 1.26.0
if(CMAKE_COMPILER_IS_ELBRUSCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 1.25.23
AND NOT CMAKE_VERSION VERSION_LESS 3.13)
target_link_options(mdbx_test PRIVATE "-Wl,--allow-multiple-definition")
endif()