From 895ab63937778e36809a12f47ce1c81498183c37 Mon Sep 17 00:00:00 2001 From: An Tao Date: Thu, 22 Jul 2021 21:25:25 +0800 Subject: [PATCH] Fix a link error when the version of gcc < 9 (#946) --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index a7692fec..012d4ddb 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,11 +143,16 @@ elseif (DROGON_CXX_STANDARD EQUAL 17) # With C++17, use Boost if std::filesystem::path is missing message(STATUS "use c++17") # Check for partial implementation of c++17 (Windows/OSX only?) + set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) try_compile(check_filesystem_path ${CMAKE_BINARY_DIR}/cmaketest ${PROJECT_SOURCE_DIR}/cmake/tests/check_has_std_filesystem_path.cc CXX_STANDARD 17) + set(CMAKE_TRY_COMPILE_TARGET_TYPE) if (check_filesystem_path) message(STATUS "Using c++17 filesytem::path") + if (CMAKE_CXX_COMPILER_ID MATCHES GNU) + target_link_libraries(${PROJECT_NAME} PUBLIC stdc++fs) + endif() else() find_package(Boost 1.49.0 COMPONENTS filesystem system REQUIRED) message(STATUS "Using Boost filesytem::path")