Detect which file-system-header to include more reliably.

This commit is contained in:
tastytea 2020-10-24 10:55:35 +02:00
parent b8bfbbeccd
commit a0db3380b1
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
3 changed files with 11 additions and 14 deletions

View File

@ -32,6 +32,9 @@ configure_file(
"${PROJECT_SOURCE_DIR}/src/version.hpp.in" "${PROJECT_SOURCE_DIR}/src/version.hpp.in"
"${PROJECT_BINARY_DIR}/version.hpp") "${PROJECT_BINARY_DIR}/version.hpp")
# Include <filesystem> or <experimental/filesystem>.
configure_file(fs-compat.hpp.in fs-compat.hpp @ONLY)
file(GLOB sources src/*.cpp) file(GLOB sources src/*.cpp)
add_executable(${PROJECT_NAME} ${sources}) add_executable(${PROJECT_NAME} ${sources})
target_include_directories(${PROJECT_NAME} target_include_directories(${PROJECT_NAME}

2
src/fs-compat.hpp.in Normal file
View File

@ -0,0 +1,2 @@
#include <@CXX_FILESYSTEM_HEADER@>
namespace fs = @CXX_FILESYSTEM_NAMESPACE@;

View File

@ -1,5 +1,5 @@
/* This file is part of libravatarserv. /* This file is part of libravatarserv.
* Copyright © 2018 tastytea <tastytea@tastytea.de> * Copyright © 2018, 2020 tastytea <tastytea@tastytea.de>
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -17,20 +17,12 @@
#ifndef LIBRAVATARSERV_HPP #ifndef LIBRAVATARSERV_HPP
#define LIBRAVATARSERV_HPP #define LIBRAVATARSERV_HPP
#if __cplusplus >= 201703L #include "fs-compat.hpp"
#include <filesystem>
#else #include <Magick++/Image.h>
#include <experimental/filesystem> #include <map>
#endif #include <string>
#include <string>
#include <map>
#include <Magick++/Image.h>
#if __cplusplus >= 201703L
namespace fs = std::filesystem;
#else
namespace fs = std::experimental::filesystem;
#endif
using std::string; using std::string;
using std::uint16_t; using std::uint16_t;
using std::uint8_t; using std::uint8_t;