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()