From f054ceeab8ae78608e807ea559c04811b48e68c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Tue, 5 Apr 2022 17:02:39 +0300 Subject: [PATCH] mdbx-cmake: add linking with `stdc++fs` for LCC < 1.26 --- CMakeLists.txt | 4 ++-- cmake/compiler.cmake | 8 ++++++-- test/CMakeLists.txt | 4 ++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 919eb57f..9673c956 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -612,8 +612,8 @@ macro(libmdbx_setup_libs TARGET MODE) elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Android") target_link_libraries(${TARGET} ${MODE} log) endif() - if(MDBX_CXX_STANDARD GREATER_EQUAL 17 AND LIBCXX_FILESYSTEM AND MDBX_BUILD_CXX) - target_link_libraries(${TARGET} ${MODE} ${LIBCXX_FILESYSTEM}) + if(LIBCXX_FILESYSTEM AND MDBX_BUILD_CXX) + target_link_libraries(${TARGET} PUBLIC ${LIBCXX_FILESYSTEM}) endif() endmacro() diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index 8e310cbb..c00ded41 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -823,9 +823,13 @@ macro(setup_compile_flags) endmacro(setup_compile_flags) if(CMAKE_CXX_COMPILER_LOADED) - # determine library for for std::filesystem + # determine library for std::filesystem set(LIBCXX_FILESYSTEM "") - if(CMAKE_COMPILER_IS_CLANG) + if(CMAKE_COMPILER_IS_ELBRUSCXX) + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 1.26.0) + set(LIBCXX_FILESYSTEM "stdc++fs") + endif() + elseif(CMAKE_COMPILER_IS_CLANG) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) set(LIBCXX_FILESYSTEM "c++experimental") elseif(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 82858066..fe397141 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -45,6 +45,10 @@ set_target_properties(mdbx_test PROPERTIES INTERPROCEDURAL_OPTIMIZATION $) target_setup_options(mdbx_test) +if(NOT MDBX_BUILD_CXX AND LIBCXX_FILESYSTEM) + target_link_libraries(mdbx_test ${LIBCXX_FILESYSTEM}) +endif() + target_link_libraries(mdbx_test ${TOOL_MDBX_LIB} ${LIB_MATH} ${CMAKE_THREAD_LIBS_INIT}) if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") target_link_libraries(mdbx_test winmm.lib)