Skip to content

Commit

Permalink
mdbx-cmake: fix/refine --allow-multiple-definition as workaround fo…
Browse files Browse the repository at this point in the history
…r `std::filesystem` and LCC < 1.25.23
  • Loading branch information
erthink committed Apr 22, 2022
1 parent b327caf commit 42f1abd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
13 changes: 13 additions & 0 deletions cmake/compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 42f1abd

Please sign in to comment.