From 0f36eb56027a22502694d3050a0935abb0abdc08 Mon Sep 17 00:00:00 2001 From: TianZerL Date: Thu, 1 Oct 2020 12:00:44 +0800 Subject: [PATCH] Update cmake --- CMakeLists.txt | 3 ++- cmake/Detection.cmake | 16 +++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 204a2ae3..10640be1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,8 @@ if(HAS_FILESYSTEM) option(Use_Boost_filesystem "Use filesystem lib from boost instead of STL" OFF) else() message ( - STATUS "Failed to complie has_filesystem.cpp, will use boost::filesystem instead of std::filesyste\n" + STATUS + "Failed to complie has_filesystem.cpp, will use boost::filesystem instead of std::filesyste\n" "Error message:\n" ${HAS_FILESYSTEM_MSG} ) diff --git a/cmake/Detection.cmake b/cmake/Detection.cmake index 712c2d2e..89165462 100644 --- a/cmake/Detection.cmake +++ b/cmake/Detection.cmake @@ -1,19 +1,21 @@ set(TMP_DIR ${PROJECT_BINARY_DIR}/tmp) set(DetectionSample_DIR ${TOP_DIR}/cmake/DetectionSample) -if(NOT EXISTS ${DetectionSample_DIR}/has_filesystem.cpp) - file(MAKE_DIRECTORY ${DetectionSample_DIR}) - file(TOUCH ${DetectionSample_DIR}/has_filesystem.cpp) - file(WRITE ${DetectionSample_DIR}/has_filesystem.cpp +set(has_filesystem_cpp "#include int main() { - std::filesystem::path hasFS(\"./\"); - return 0; + std::filesystem::path hasFS(\"./\")\; + return 0\; } ") +if(NOT EXISTS ${DetectionSample_DIR}/has_filesystem.cpp) + file(MAKE_DIRECTORY ${DetectionSample_DIR}) + file(TOUCH ${DetectionSample_DIR}/has_filesystem.cpp) + file(WRITE ${DetectionSample_DIR}/has_filesystem.cpp ${has_filesystem_cpp}) + # check std::filesystem if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) try_compile(HAS_FILESYSTEM @@ -32,4 +34,4 @@ int main() ) endif() -endif() \ No newline at end of file +endif()