Skip to content

Commit 8e00fef

Browse files
authored
Merge pull request #388 make std::filesystem optional from ninjaoflight/std-filesystem-optional
2 parents 55b30a2 + 8d36ab8 commit 8e00fef

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,13 @@ else (SQLITECPP_INTERNAL_SQLITE)
297297
endif()
298298
endif (SQLITECPP_INTERNAL_SQLITE)
299299

300+
## disable the optional support for std::filesystem (C++17)
301+
option(SQLITECPP_DISABLE_STD_FILESYSTEM "Disable the use of std::filesystem in SQLiteCpp." OFF)
302+
if (SQLITECPP_DISABLE_STD_FILESYSTEM)
303+
message (STATUS "Disabling std::filesystem support")
304+
add_definitions(-DSQLITECPP_DISABLE_STD_FILESYSTEM)
305+
endif (SQLITECPP_DISABLE_STD_FILESYSTEM)
306+
300307
# Link target with pthread and dl for Unix
301308
if (UNIX)
302309
set(THREADS_PREFER_PTHREAD_FLAG ON)

include/SQLiteCpp/Database.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0
3333
#define SQLITECPP_HAVE_STD_FILESYSTEM
3434
#endif
3535

36+
// disable the support if the required header is not available
37+
#ifdef __has_include
38+
#ifndef __has_include(<filesystem>)
39+
#undef SQLITECPP_HAVE_STD_FILESYSTEM
40+
#endif
41+
#ifndef __has_include(<experimental/filesystem>)
42+
#undef SQLITECPP_HAVE_EXPERIMENTAL_FILESYSTEM
43+
#endif
44+
#endif
45+
46+
// C++17 allow to disable std::filesystem support
47+
#ifdef SQLITECPP_DISABLE_STD_FILESYSTEM
48+
#undef SQLITECPP_HAVE_STD_FILESYSTEM
49+
#undef SQLITECPP_HAVE_STD_EXPERIMENTAL_FILESYSTEM
50+
#endif
51+
3652
#ifdef SQLITECPP_HAVE_STD_FILESYSTEM
3753
#include <filesystem>
3854
#endif // c++17 and a suitable compiler

meson.build

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ unix_like_code = '''
2020
'''
2121
unix_like = cxx.compiles(unix_like_code, name : 'unix like environment')
2222

23+
## C++17 disable the support for std::filesystem (by default off)
24+
if get_option('SQLITECPP_DISABLE_STD_FILESYSTEM')
25+
sqlitecpp_cxx_flags += ['-DSQLITECPP_DISABLE_STD_FILESYSTEM']
26+
endif
27+
2328
thread_dep = dependency('threads')
2429
# sqlite3 support
2530
sqlite3_dep = dependency(

meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ option('SQLITE_ENABLE_ASSERT_HANDLER', type: 'boolean', value: false, descriptio
99
option('SQLITE_HAS_CODEC', type: 'boolean', value: false, description: 'Enable database encryption API. Not available in the public release of SQLite.')
1010
## Force forward declaration of legacy struct sqlite3_value (pre SQLite 3.19)
1111
option('SQLITE_USE_LEGACY_STRUCT', type: 'boolean', value: false, description: 'Fallback to forward declaration of legacy struct sqlite3_value (pre SQLite 3.19)')
12+
## Disable the support for std::filesystem (C++17)
13+
option('SQLITECPP_DISABLE_STD_FILESYSTEM', type: 'boolean', value: false, description: 'Disable the support for std::filesystem (C++17)')
1214
## Enable build for the tests of SQLiteC++
1315
option('SQLITECPP_BUILD_TESTS', type: 'boolean', value: false, description: 'Build SQLiteC++ unit tests.')
1416
## Build the examples of SQLiteC++

0 commit comments

Comments
 (0)