From bfa51b2585710890abc387c668896dc49b77c584 Mon Sep 17 00:00:00 2001 From: Sonja Happ <sonja.happ@eonerc.rwth-aachen.de> Date: Tue, 17 Aug 2021 14:30:56 +0200 Subject: [PATCH] include <filesystem> directly and set minimum required compiler versions for gcc and clang in cmake file --- CMakeLists.txt | 13 +++++++++++++ include/villas/config.hpp | 14 +++----------- lib/config.cpp | 13 ++----------- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81aa99a48..d00ded104 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,6 +48,19 @@ if(APPLE) set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/opt/local/lib/pkgconfig") endif() +# check compiler version +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + # require at least gcc 8 + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8) + message(FATAL_ERROR "GCC version must be at least 8!") + endif() +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + # require at least clang 7 + if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7) + message(FATAL_ERROR "Clang version must be at least 7!") + endif() +endif() + include(FindPkgConfig) include(CheckIncludeFile) include(FeatureSummary) diff --git a/include/villas/config.hpp b/include/villas/config.hpp index 6f68629fa..b1454e3c4 100644 --- a/include/villas/config.hpp +++ b/include/villas/config.hpp @@ -25,23 +25,15 @@ #include <cstdio> #include <unistd.h> - #include <functional> #include <regex> -#if __has_include(<filesystem>) - #include <filesystem> - namespace fs = std::filesystem; -#elif __has_include(<experimental/filesystem>) - #include <experimental/filesystem> - namespace fs = std::experimental::filesystem; -#else - error "Missing the <filesystem> header." -#endif +#include <filesystem> #include <jansson.h> - #include <villas/node/config.h> #include <villas/log.hpp> +namespace fs = std::filesystem; + namespace villas { namespace node { diff --git a/lib/config.cpp b/lib/config.cpp index 94cf483aa..e98174f6f 100644 --- a/lib/config.cpp +++ b/lib/config.cpp @@ -23,21 +23,11 @@ #include <unistd.h> #include <libgen.h> - #include <string> #include <fstream> #include <iostream> #include <iomanip> -#if __has_include(<filesystem>) - #include <filesystem> - namespace fs = std::filesystem; -#elif __has_include(<experimental/filesystem>) - #include <experimental/filesystem> - namespace fs = std::experimental::filesystem; -#else - error "Missing the <filesystem> header." -#endif - +#include <filesystem> #include <villas/utils.hpp> #include <villas/log.hpp> #include <villas/config.hpp> @@ -47,6 +37,7 @@ using namespace villas; using namespace villas::node; +namespace fs = std::filesystem; Config::Config() : logger(logging.get("config")),