mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-05 10:16:01 -04:00
Disable std::filesystem on macOS targetting <10.15
macOS flat out refuses to compile if you touch std::filesystem when targetting macOS < 10.15 (to be able to deploy a binary to older macOS versions). This disables the std::filesystem support when in C++17 mode with such a target.
This commit is contained in:
parent
44bd9c4f38
commit
bfe0221b8c
@ -14,9 +14,24 @@
|
||||
|
||||
// c++17: MinGW GCC version > 8
|
||||
// c++17: Visual Studio 2017 version 15.7
|
||||
#if ((__cplusplus >= 201703L) && ((!defined(__MINGW32__) && !defined(__MINGW64__)) || (__GNUC__ > 8))) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L)) // NOLINT
|
||||
// c++17: macOS unless targetting compatibility with macOS < 10.15
|
||||
#if __cplusplus >= 201703L
|
||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||
#if __GNUC__ > 8 // MinGW requires GCC version > 8 for std::filesystem
|
||||
#define SQLITECPP_HAVE_STD_FILESYSTEM
|
||||
#endif
|
||||
#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
|
||||
// macOS clang won't less us touch std::filesystem if we're targetting earlier than 10.15
|
||||
#else
|
||||
#define SQLITECPP_HAVE_STD_FILESYSTEM
|
||||
#endif
|
||||
#elif defined(_MSVC_LANG) && _MSVC_LANG >= 201703L
|
||||
#define SQLITECPP_HAVE_STD_FILESYSTEM
|
||||
#endif
|
||||
|
||||
#ifdef SQLITECPP_HAVE_STD_FILESYSTEM
|
||||
#include <filesystem>
|
||||
#endif // c++17
|
||||
#endif // c++17 and a suitable compiler
|
||||
|
||||
#include <memory>
|
||||
#include <string.h>
|
||||
@ -167,9 +182,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
// c++17: MinGW GCC version > 8
|
||||
// c++17: Visual Studio 2017 version 15.7
|
||||
#if ((__cplusplus >= 201703L) && ((!defined(__MINGW32__) && !defined(__MINGW64__)) || (__GNUC__ > 8))) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L)) // NOLINT
|
||||
#ifdef SQLITECPP_HAVE_STD_FILESYSTEM
|
||||
|
||||
/**
|
||||
* @brief Open the provided database std::filesystem::path.
|
||||
@ -199,7 +212,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
#endif // c++17
|
||||
#endif // have std::filesystem
|
||||
|
||||
// Database is non-copyable
|
||||
Database(const Database&) = delete;
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#if (__cplusplus >= 201703L) || ( defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L)) // c++17: Visual Studio 2017 version 15.7
|
||||
#ifdef SQLITECPP_HAVE_STD_FILESYSTEM
|
||||
#include <filesystem>
|
||||
#endif // c++17
|
||||
|
||||
@ -50,12 +50,13 @@ TEST(Database, ctorExecCreateDropExist)
|
||||
std::string filename = "test.db3";
|
||||
EXPECT_THROW(SQLite::Database not_found(filename), SQLite::Exception);
|
||||
|
||||
// Create a new database using a string or a std::filesystem::path if using c++17
|
||||
#if (__cplusplus >= 201703L) || ( defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L)) // c++17: Visual Studio 2017 version 15.7
|
||||
// Create a new database using a string or a std::filesystem::path if using c++17 and a
|
||||
// compatible compiler
|
||||
#ifdef SQLITECPP_HAVE_STD_FILESYSTEM
|
||||
SQLite::Database db(std::filesystem::path("test.db3"), SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
#else
|
||||
SQLite::Database db("test.db3", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);
|
||||
#endif // c++17
|
||||
#endif // have std::filesystem
|
||||
|
||||
EXPECT_STREQ("test.db3", db.getFilename().c_str());
|
||||
EXPECT_FALSE(db.tableExists("test"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user