From b4c4393cd8e4d6a29dfe742337e47244adf0d417 Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 29 Jun 2020 23:15:14 +0200 Subject: [PATCH] Add compatibility for GCC-7. In GCC-7 filesystem is in std::experimental. --- src/CMakeLists.txt | 7 ++++++- src/cgi.cpp | 4 +--- src/fs-compat.hpp.in | 2 ++ src/main.cpp | 3 +-- 4 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 src/fs-compat.hpp.in diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 09d6aef..c66aaf2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,7 +3,9 @@ include(GNUInstallDirs) find_package(PkgConfig REQUIRED) pkg_check_modules(cgicc REQUIRED IMPORTED_TARGET cgicc) find_package(nlohmann_json REQUIRED CONFIG) -find_package(Filesystem REQUIRED) +find_package(Filesystem REQUIRED COMPONENTS Final Experimental) + +configure_file(fs-compat.hpp.in fs-compat.hpp @ONLY) add_executable(${PROJECT_NAME} main.cpp) @@ -14,6 +16,9 @@ target_sources(${PROJECT_NAME} unset(sources_src) unset(headers_src) +target_include_directories(${PROJECT_NAME} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) + target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::cgicc nlohmann_json std::filesystem) diff --git a/src/cgi.cpp b/src/cgi.cpp index 0e57a02..8469d15 100644 --- a/src/cgi.cpp +++ b/src/cgi.cpp @@ -15,11 +15,11 @@ */ #include "cgi.hpp" +#include "fs-compat.hpp" #include #include -#include #include #include #include @@ -42,8 +42,6 @@ using std::string_view; using std::stringstream; using std::vector; -namespace fs = std::filesystem; - entry_type parse_formdata() { entry_type entry; diff --git a/src/fs-compat.hpp.in b/src/fs-compat.hpp.in new file mode 100644 index 0000000..ca15c69 --- /dev/null +++ b/src/fs-compat.hpp.in @@ -0,0 +1,2 @@ +#include <@CXX_FILESYSTEM_HEADER@> +namespace fs = @CXX_FILESYSTEM_NAMESPACE@; diff --git a/src/main.cpp b/src/main.cpp index 0052fe8..d3b8972 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,14 +15,13 @@ */ #include "cgi.hpp" +#include "fs-compat.hpp" #include "json.hpp" -#include #include using std::cout; -namespace fs = std::filesystem; using namespace FediBlock; void print_debug(const entry_type &entry)