mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-07 19:26:10 -04:00
[macOS] do not check for load_extension if using internal sqlite3
This commit is contained in:
parent
c31eae9887
commit
69076e87cb
584
meson.build
584
meson.build
@ -1,290 +1,294 @@
|
|||||||
project(
|
project(
|
||||||
'SQLiteCpp', 'cpp',
|
'SQLiteCpp', 'cpp',
|
||||||
# SQLiteCpp requires C++11 support
|
# SQLiteCpp requires C++11 support
|
||||||
default_options: ['cpp_std=c++11', 'warning_level=3'],
|
default_options: ['cpp_std=c++11', 'warning_level=3'],
|
||||||
license: 'MIT',
|
license: 'MIT',
|
||||||
version: '3.2.1',
|
version: '3.2.1',
|
||||||
)
|
)
|
||||||
|
|
||||||
cxx = meson.get_compiler('cpp')
|
cxx = meson.get_compiler('cpp')
|
||||||
|
|
||||||
## at best we might try to test if this code compiles
|
## at best we might try to test if this code compiles
|
||||||
## testing for compilers or platforms is not reliable enough
|
## testing for compilers or platforms is not reliable enough
|
||||||
## example: native clang on windows or mingw in windows
|
## example: native clang on windows or mingw in windows
|
||||||
unix_like_code = '''
|
unix_like_code = '''
|
||||||
#if defined(unix) || defined(__unix__) || defined(__unix)
|
#if defined(unix) || defined(__unix__) || defined(__unix)
|
||||||
// do nothing
|
// do nothing
|
||||||
#else
|
#else
|
||||||
# error "Non Unix-like OS"
|
# error "Non Unix-like OS"
|
||||||
#endif
|
#endif
|
||||||
'''
|
'''
|
||||||
unix_like = cxx.compiles(unix_like_code, name : 'unix like environment')
|
unix_like = cxx.compiles(unix_like_code, name : 'unix like environment')
|
||||||
|
|
||||||
mingw_64_env_code = '''
|
mingw_64_env_code = '''
|
||||||
#if defined(__MINGW64__)
|
#if defined(__MINGW64__)
|
||||||
// do nothing
|
// do nothing
|
||||||
#else
|
#else
|
||||||
# error "Non MinGW-W64 environment"
|
# error "Non MinGW-W64 environment"
|
||||||
#endif
|
#endif
|
||||||
'''
|
'''
|
||||||
mingw_64_env = cxx.compiles(mingw_64_env_code, name : 'MinGW-W64 environment')
|
mingw_64_env = cxx.compiles(mingw_64_env_code, name : 'MinGW-W64 environment')
|
||||||
|
|
||||||
thread_dep = dependency('threads')
|
thread_dep = dependency('threads')
|
||||||
# sqlite3 support
|
# sqlite3 support
|
||||||
sqlite3_dep = dependency(
|
sqlite3_dep = dependency(
|
||||||
'sqlite3',
|
'sqlite3',
|
||||||
fallback: ['sqlite3', 'sqlite3_dep']
|
fallback: ['sqlite3', 'sqlite3_dep']
|
||||||
)
|
)
|
||||||
|
|
||||||
sqlitecpp_incl = [
|
sqlitecpp_incl = [
|
||||||
include_directories('include')
|
include_directories('include')
|
||||||
]
|
]
|
||||||
sqlitecpp_srcs = files(
|
sqlitecpp_srcs = files(
|
||||||
'src/Backup.cpp',
|
'src/Backup.cpp',
|
||||||
'src/Column.cpp',
|
'src/Column.cpp',
|
||||||
'src/Database.cpp',
|
'src/Database.cpp',
|
||||||
'src/Exception.cpp',
|
'src/Exception.cpp',
|
||||||
'src/Savepoint.cpp',
|
'src/Savepoint.cpp',
|
||||||
'src/Statement.cpp',
|
'src/Statement.cpp',
|
||||||
'src/Transaction.cpp',
|
'src/Transaction.cpp',
|
||||||
)
|
)
|
||||||
sqlitecpp_args = cxx.get_supported_arguments(
|
sqlitecpp_args = cxx.get_supported_arguments(
|
||||||
# included in meson by default
|
# included in meson by default
|
||||||
# -Wall
|
# -Wall
|
||||||
# included when warning_level=3
|
# included when warning_level=3
|
||||||
#'-Wextra',
|
#'-Wextra',
|
||||||
#'-Wpedantic',
|
#'-Wpedantic',
|
||||||
'-Wswitch-enum',
|
'-Wswitch-enum',
|
||||||
'-Wshadow',
|
'-Wshadow',
|
||||||
'-Wno-long-long',
|
'-Wno-long-long',
|
||||||
)
|
)
|
||||||
sqlitecpp_link = []
|
sqlitecpp_link = []
|
||||||
sqlitecpp_deps = [
|
sqlitecpp_deps = [
|
||||||
sqlite3_dep,
|
sqlite3_dep,
|
||||||
thread_dep,
|
thread_dep,
|
||||||
]
|
]
|
||||||
## used to override the default sqlitecpp options like cpp standard
|
## used to override the default sqlitecpp options like cpp standard
|
||||||
sqlitecpp_opts = []
|
sqlitecpp_opts = []
|
||||||
|
|
||||||
## tests
|
## tests
|
||||||
|
|
||||||
sqlitecpp_test_srcs = files(
|
sqlitecpp_test_srcs = files(
|
||||||
'tests/Column_test.cpp',
|
'tests/Column_test.cpp',
|
||||||
'tests/Database_test.cpp',
|
'tests/Database_test.cpp',
|
||||||
'tests/Savepoint_test.cpp',
|
'tests/Savepoint_test.cpp',
|
||||||
'tests/Statement_test.cpp',
|
'tests/Statement_test.cpp',
|
||||||
'tests/Backup_test.cpp',
|
'tests/Backup_test.cpp',
|
||||||
'tests/Transaction_test.cpp',
|
'tests/Transaction_test.cpp',
|
||||||
'tests/VariadicBind_test.cpp',
|
'tests/VariadicBind_test.cpp',
|
||||||
'tests/Exception_test.cpp',
|
'tests/Exception_test.cpp',
|
||||||
'tests/ExecuteMany_test.cpp',
|
'tests/ExecuteMany_test.cpp',
|
||||||
)
|
)
|
||||||
sqlitecpp_test_args = []
|
sqlitecpp_test_args = []
|
||||||
|
|
||||||
## samples
|
## samples
|
||||||
|
|
||||||
sqlitecpp_sample1_srcs = files(
|
sqlitecpp_sample1_srcs = files(
|
||||||
'examples/example1/main.cpp',
|
'examples/example1/main.cpp',
|
||||||
)
|
)
|
||||||
sqlitecpp_sample2_srcs = files(
|
sqlitecpp_sample2_srcs = files(
|
||||||
'examples/example2/src/main.cpp',
|
'examples/example2/src/main.cpp',
|
||||||
)
|
)
|
||||||
|
|
||||||
## using MSVC headers requires c++14, if not will show an error on xstddef as:
|
## using MSVC headers requires c++14, if not will show an error on xstddef as:
|
||||||
## 'auto' return without trailing return type; deduced return types are a C++14 extension
|
## 'auto' return without trailing return type; deduced return types are a C++14 extension
|
||||||
if host_machine.system() == 'windows'
|
if host_machine.system() == 'windows'
|
||||||
message('[WINDOWS] using c++14 standard')
|
message('[WINDOWS] using c++14 standard')
|
||||||
sqlitecpp_opts += [
|
sqlitecpp_opts += [
|
||||||
'cpp_std=c++14',
|
'cpp_std=c++14',
|
||||||
]
|
]
|
||||||
# check that we are not trying to build as dynamic library
|
# check that we are not trying to build as dynamic library
|
||||||
if get_option('default_library') != 'shared'
|
if get_option('default_library') != 'shared'
|
||||||
message('warning: SQLiteCpp does not support shared library on Windows, the library will be built as static')
|
message('warning: SQLiteCpp does not support shared library on Windows, the library will be built as static')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
endif
|
endif
|
||||||
# Options relative to SQLite and SQLiteC++ functions
|
# Options relative to SQLite and SQLiteC++ functions
|
||||||
|
|
||||||
if get_option('SQLITE_ENABLE_COLUMN_METADATA')
|
if get_option('SQLITE_ENABLE_COLUMN_METADATA')
|
||||||
sqlitecpp_args += [
|
sqlitecpp_args += [
|
||||||
'-DSQLITE_ENABLE_COLUMN_METADATA',
|
'-DSQLITE_ENABLE_COLUMN_METADATA',
|
||||||
]
|
]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if get_option('SQLITE_ENABLE_ASSERT_HANDLER')
|
if get_option('SQLITE_ENABLE_ASSERT_HANDLER')
|
||||||
sqlitecpp_args += [
|
sqlitecpp_args += [
|
||||||
'-DSQLITE_ENABLE_ASSERT_HANDLER',
|
'-DSQLITE_ENABLE_ASSERT_HANDLER',
|
||||||
]
|
]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if get_option('SQLITE_HAS_CODEC')
|
if get_option('SQLITE_HAS_CODEC')
|
||||||
sqlitecpp_args += [
|
sqlitecpp_args += [
|
||||||
'-DSQLITE_HAS_CODEC',
|
'-DSQLITE_HAS_CODEC',
|
||||||
]
|
]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if get_option('SQLITE_USE_LEGACY_STRUCT')
|
if get_option('SQLITE_USE_LEGACY_STRUCT')
|
||||||
sqlitecpp_args += [
|
sqlitecpp_args += [
|
||||||
'-DSQLITE_USE_LEGACY_STRUCT',
|
'-DSQLITE_USE_LEGACY_STRUCT',
|
||||||
]
|
]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
## C++17 disable the support for std::filesystem (by default off)
|
## C++17 disable the support for std::filesystem (by default off)
|
||||||
if get_option('SQLITECPP_DISABLE_STD_FILESYSTEM')
|
if get_option('SQLITECPP_DISABLE_STD_FILESYSTEM')
|
||||||
sqlitecpp_cxx_flags += ['-DSQLITECPP_DISABLE_STD_FILESYSTEM']
|
sqlitecpp_cxx_flags += ['-DSQLITECPP_DISABLE_STD_FILESYSTEM']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
## get the user option for the SQLITECPP_DISABLE_SQLITE3_EXPANDED_SQL
|
## get the user option for the SQLITECPP_DISABLE_SQLITE3_EXPANDED_SQL
|
||||||
disable_sqlitecpp_expanded_sql = get_option('SQLITECPP_DISABLE_SQLITE3_EXPANDED_SQL')
|
disable_sqlitecpp_expanded_sql = get_option('SQLITECPP_DISABLE_SQLITE3_EXPANDED_SQL')
|
||||||
|
|
||||||
## Disable the use of sqlite3_expanded_sql (from sqlite3 3.14.0)
|
## Disable the use of sqlite3_expanded_sql (from sqlite3 3.14.0)
|
||||||
if disable_sqlitecpp_expanded_sql
|
if disable_sqlitecpp_expanded_sql
|
||||||
sqlitecpp_args += ['-DSQLITECPP_DISABLE_SQLITE3_EXPANDED_SQL']
|
sqlitecpp_args += ['-DSQLITECPP_DISABLE_SQLITE3_EXPANDED_SQL']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
## stack protection hardening
|
## stack protection hardening
|
||||||
if get_option('SQLITECPP_USE_STACK_PROTECTION')
|
if get_option('SQLITECPP_USE_STACK_PROTECTION')
|
||||||
## if is on MinGW-W64 give a warning that is not supported
|
## if is on MinGW-W64 give a warning that is not supported
|
||||||
if mingw_64_env
|
if mingw_64_env
|
||||||
message('warning: SQLiteCpp does not support stack protection on MinGW-W64')
|
message('warning: SQLiteCpp does not support stack protection on MinGW-W64')
|
||||||
message('warning: this could lead to a crash on the application')
|
message('warning: this could lead to a crash on the application')
|
||||||
message('warning: you can disable this warning by setting SQLITECPP_USE_STACK_PROTECTOR to false')
|
message('warning: you can disable this warning by setting SQLITECPP_USE_STACK_PROTECTOR to false')
|
||||||
else
|
else
|
||||||
sqlitecpp_args += ['-fstack-protector']
|
sqlitecpp_args += ['-fstack-protector']
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
## enable ommit load extension
|
## enable ommit load extension
|
||||||
if get_option('SQLITE_OMIT_LOAD_EXTENSION')
|
if get_option('SQLITE_OMIT_LOAD_EXTENSION')
|
||||||
sqlitecpp_args += ['-DSQLITE_OMIT_LOAD_EXTENSION']
|
sqlitecpp_args += ['-DSQLITE_OMIT_LOAD_EXTENSION']
|
||||||
## check if running on OSX
|
## check if running on OSX
|
||||||
elif host_machine.system() == 'darwin' and sqlite3_dep.found()
|
elif host_machine.system() == 'darwin' and sqlite3_dep.found()
|
||||||
sqlite3_load_extension_support = cxx.links(
|
## check if sqlite3 is the one bundled with OSX
|
||||||
'''
|
if sqlite3_dep.type_name() != 'internal'
|
||||||
#include <sqlite3.h>
|
message('warning: Detected non-internal SQLite3 in OSX, check if it supports load extension')
|
||||||
int main() {
|
sqlite3_load_extension_support = cxx.links(
|
||||||
sqlite3_enable_load_extension(0, 0);
|
'''
|
||||||
return 0;
|
#include <sqlite3.h>
|
||||||
}
|
int main() {
|
||||||
''',
|
sqlite3_enable_load_extension(0, 0);
|
||||||
name: 'sqlite3_load_extension',
|
return 0;
|
||||||
dependencies: [sqlite3_dep])
|
}
|
||||||
if not sqlite3_load_extension_support
|
''',
|
||||||
message('warning: Detected bundled SQLite3 in OSX, but it does not support load extension')
|
name: 'sqlite3_load_extension',
|
||||||
message('warning: SQLiteCpp will be built without load extension support')
|
dependencies: [sqlite3_dep])
|
||||||
message('warning: You can disable this warning by setting SQLITE_OMIT_LOAD_EXTENSION to false')
|
if not sqlite3_load_extension_support
|
||||||
sqlitecpp_args += ['-DSQLITE_OMIT_LOAD_EXTENSION']
|
message('warning: Detected bundled SQLite3 in OSX, but it does not support load extension')
|
||||||
endif
|
message('warning: SQLiteCpp will be built without load extension support')
|
||||||
endif
|
message('warning: You can disable this warning by setting SQLITE_OMIT_LOAD_EXTENSION to false')
|
||||||
|
sqlitecpp_args += ['-DSQLITE_OMIT_LOAD_EXTENSION']
|
||||||
|
endif
|
||||||
|
endif
|
||||||
if unix_like
|
endif
|
||||||
sqlitecpp_args += [
|
|
||||||
# -fPIC is included by default in meson
|
|
||||||
# 'fPIC',
|
|
||||||
]
|
if unix_like
|
||||||
# add dl dependency
|
sqlitecpp_args += [
|
||||||
libdl_dep = cxx.find_library('dl')
|
# -fPIC is included by default in meson
|
||||||
sqlitecpp_deps += [
|
# 'fPIC',
|
||||||
libdl_dep,
|
]
|
||||||
]
|
# add dl dependency
|
||||||
endif
|
libdl_dep = cxx.find_library('dl')
|
||||||
|
sqlitecpp_deps += [
|
||||||
if get_option('b_coverage')
|
libdl_dep,
|
||||||
# Prevent the compiler from removing the unused inline functions so that they get tracked as "non-covered"
|
]
|
||||||
sqlitecpp_args += [
|
endif
|
||||||
'-fkeep-inline-functions',
|
|
||||||
'-fkeep-static-functions',
|
if get_option('b_coverage')
|
||||||
]
|
# Prevent the compiler from removing the unused inline functions so that they get tracked as "non-covered"
|
||||||
endif
|
sqlitecpp_args += [
|
||||||
|
'-fkeep-inline-functions',
|
||||||
## Workarround for windows: if building on windows we will build the library as static
|
'-fkeep-static-functions',
|
||||||
if host_machine.system() == 'windows'
|
]
|
||||||
libsqlitecpp = static_library(
|
endif
|
||||||
'sqlitecpp',
|
|
||||||
sqlitecpp_srcs,
|
## Workarround for windows: if building on windows we will build the library as static
|
||||||
include_directories: sqlitecpp_incl,
|
if host_machine.system() == 'windows'
|
||||||
cpp_args: sqlitecpp_args,
|
libsqlitecpp = static_library(
|
||||||
dependencies: sqlitecpp_deps,
|
'sqlitecpp',
|
||||||
# override the default options
|
sqlitecpp_srcs,
|
||||||
override_options: sqlitecpp_opts,)
|
include_directories: sqlitecpp_incl,
|
||||||
else
|
cpp_args: sqlitecpp_args,
|
||||||
libsqlitecpp = library(
|
dependencies: sqlitecpp_deps,
|
||||||
'sqlitecpp',
|
# override the default options
|
||||||
sqlitecpp_srcs,
|
override_options: sqlitecpp_opts,)
|
||||||
include_directories: sqlitecpp_incl,
|
else
|
||||||
cpp_args: sqlitecpp_args,
|
libsqlitecpp = library(
|
||||||
dependencies: sqlitecpp_deps,
|
'sqlitecpp',
|
||||||
# override the default options
|
sqlitecpp_srcs,
|
||||||
override_options: sqlitecpp_opts,
|
include_directories: sqlitecpp_incl,
|
||||||
install: true,
|
cpp_args: sqlitecpp_args,
|
||||||
# API version for SQLiteCpp shared library.
|
dependencies: sqlitecpp_deps,
|
||||||
version: '0',)
|
# override the default options
|
||||||
endif
|
override_options: sqlitecpp_opts,
|
||||||
|
install: true,
|
||||||
if get_option('SQLITECPP_BUILD_TESTS')
|
# API version for SQLiteCpp shared library.
|
||||||
# for the unit tests we need to link against a static version of SQLiteCpp
|
version: '0',)
|
||||||
if host_machine.system() == 'windows' or get_option('default_library') == 'static'
|
endif
|
||||||
# we do not need to recomplile the library
|
|
||||||
libsqlitecpp_static = libsqlitecpp
|
if get_option('SQLITECPP_BUILD_TESTS')
|
||||||
else
|
# for the unit tests we need to link against a static version of SQLiteCpp
|
||||||
libsqlitecpp_static = static_library(
|
if host_machine.system() == 'windows' or get_option('default_library') == 'static'
|
||||||
'sqlitecpp_static',
|
# we do not need to recomplile the library
|
||||||
sqlitecpp_srcs,
|
libsqlitecpp_static = libsqlitecpp
|
||||||
include_directories: sqlitecpp_incl,
|
else
|
||||||
cpp_args: sqlitecpp_args,
|
libsqlitecpp_static = static_library(
|
||||||
dependencies: sqlitecpp_deps,
|
'sqlitecpp_static',
|
||||||
# override the default options
|
sqlitecpp_srcs,
|
||||||
override_options: sqlitecpp_opts,)
|
include_directories: sqlitecpp_incl,
|
||||||
endif
|
cpp_args: sqlitecpp_args,
|
||||||
endif
|
dependencies: sqlitecpp_deps,
|
||||||
|
# override the default options
|
||||||
install_subdir(
|
override_options: sqlitecpp_opts,)
|
||||||
'include/SQLiteCpp',
|
endif
|
||||||
install_dir: get_option('includedir'))
|
endif
|
||||||
|
|
||||||
sqlitecpp_dep = declare_dependency(
|
install_subdir(
|
||||||
include_directories: sqlitecpp_incl,
|
'include/SQLiteCpp',
|
||||||
link_with: libsqlitecpp,
|
install_dir: get_option('includedir'))
|
||||||
)
|
|
||||||
if get_option('SQLITECPP_BUILD_TESTS')
|
sqlitecpp_dep = declare_dependency(
|
||||||
## make the dependency static so the unit tests can link against it
|
include_directories: sqlitecpp_incl,
|
||||||
## (mainly for windows as the symbols are not exported by default)
|
link_with: libsqlitecpp,
|
||||||
sqlitecpp_static_dep = declare_dependency(
|
)
|
||||||
include_directories: sqlitecpp_incl,
|
if get_option('SQLITECPP_BUILD_TESTS')
|
||||||
link_with: libsqlitecpp_static,
|
## make the dependency static so the unit tests can link against it
|
||||||
)
|
## (mainly for windows as the symbols are not exported by default)
|
||||||
endif
|
sqlitecpp_static_dep = declare_dependency(
|
||||||
|
include_directories: sqlitecpp_incl,
|
||||||
if get_option('SQLITECPP_BUILD_TESTS')
|
link_with: libsqlitecpp_static,
|
||||||
gtest_dep = dependency(
|
)
|
||||||
'gtest',
|
endif
|
||||||
main : true,
|
|
||||||
fallback: ['gtest', 'gtest_main_dep'])
|
if get_option('SQLITECPP_BUILD_TESTS')
|
||||||
sqlitecpp_test_dependencies = [
|
gtest_dep = dependency(
|
||||||
gtest_dep,
|
'gtest',
|
||||||
sqlitecpp_static_dep,
|
main : true,
|
||||||
sqlite3_dep,
|
fallback: ['gtest', 'gtest_main_dep'])
|
||||||
]
|
sqlitecpp_test_dependencies = [
|
||||||
|
gtest_dep,
|
||||||
testexe = executable('testexe', sqlitecpp_test_srcs,
|
sqlitecpp_static_dep,
|
||||||
dependencies: sqlitecpp_test_dependencies,
|
sqlite3_dep,
|
||||||
cpp_args: sqlitecpp_test_args,
|
]
|
||||||
# override the default options
|
|
||||||
override_options: sqlitecpp_opts,)
|
testexe = executable('testexe', sqlitecpp_test_srcs,
|
||||||
|
dependencies: sqlitecpp_test_dependencies,
|
||||||
test_args = []
|
cpp_args: sqlitecpp_test_args,
|
||||||
|
# override the default options
|
||||||
test('sqlitecpp unit tests', testexe, args: test_args)
|
override_options: sqlitecpp_opts,)
|
||||||
endif
|
|
||||||
if get_option('SQLITECPP_BUILD_EXAMPLES')
|
test_args = []
|
||||||
subdir('examples')
|
|
||||||
endif
|
test('sqlitecpp unit tests', testexe, args: test_args)
|
||||||
|
endif
|
||||||
pkgconfig = import('pkgconfig')
|
if get_option('SQLITECPP_BUILD_EXAMPLES')
|
||||||
pkgconfig.generate(
|
subdir('examples')
|
||||||
libsqlitecpp,
|
endif
|
||||||
description: 'a smart and easy to use C++ SQLite3 wrapper.',
|
|
||||||
version: meson.project_version(),
|
pkgconfig = import('pkgconfig')
|
||||||
)
|
pkgconfig.generate(
|
||||||
|
libsqlitecpp,
|
||||||
|
description: 'a smart and easy to use C++ SQLite3 wrapper.',
|
||||||
|
version: meson.project_version(),
|
||||||
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user