Skip to content

Commit

Permalink
Update cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
TianZerL committed Oct 1, 2020
1 parent 38a0ea4 commit 0f36eb5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
Expand Down
16 changes: 9 additions & 7 deletions cmake/Detection.cmake
Original file line number Diff line number Diff line change
@@ -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 <filesystem>
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
Expand All @@ -32,4 +34,4 @@ int main()
)
endif()

endif()
endif()

0 comments on commit 0f36eb5

Please sign in to comment.