diff --git a/CMakeLists.txt b/CMakeLists.txt index e74164f..407a830 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,14 @@ project("clutchlog" enable_language(CXX) # C++ set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_LIBRARIES -lstdc++fs) +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -std=c++17 -lstdc++fs") + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0) + link_libraries(stdc++fs) + add_compile_definitions(FSEXPERIMENTAL) + endif() +endif() + ###################################################################################### # Configurable user settings diff --git a/clutchlog/clutchlog.h b/clutchlog/clutchlog.h index 59a192c..f1469f6 100644 --- a/clutchlog/clutchlog.h +++ b/clutchlog/clutchlog.h @@ -3,8 +3,15 @@ #pragma once /** @file */ - +#include +#ifdef FSEXPERIMENTAL +#include +namespace fs = std::experimental::filesystem; +#else #include +namespace fs = std::filesystem; +#endif + #include #include #include @@ -715,7 +722,7 @@ class clutchlog do { outfile = replace(filename_template, tag, n); n++; - } while( std::filesystem::exists( outfile ) ); + } while( fs::exists( outfile ) ); } else { // Use the parameter as is.