diff --git a/meson_options.txt b/meson_options.txt index 74f7108..54b5bc8 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1,4 @@ option('base_url', type: 'string', value: 'https://api.originsro.org') option('def_sqlite_db_name', type: 'string', value: 'originsro.db3') option('tests', type: 'feature', value: 'enabled') +option('with_sqlite', type: 'feature', value: 'auto') diff --git a/src/config.hpp.in b/src/config.hpp.in index e46d6b0..0e5c715 100644 --- a/src/config.hpp.in +++ b/src/config.hpp.in @@ -29,4 +29,6 @@ constexpr const unsigned short int g_version_major = @PROJECT_VERSION_MAJOR@; constexpr const unsigned short int g_version_minor = @PROJECT_VERSION_MINOR@; constexpr const unsigned short int g_version_patch = @PROJECT_VERSION_PATCH@; +#mesondefine OROTOOL_WITH_SQLITE + } //namespace duck diff --git a/src/meson.build b/src/meson.build index 61fd5f8..193b9cc 100644 --- a/src/meson.build +++ b/src/meson.build @@ -6,9 +6,14 @@ restc_cpp_dep = dependency('restc-cpp', version: '>=0.1.1', ], ) -sqlitecpp_dep = dependency('sqlitecpp', version: '>=3.0.0', - fallback: ['SQLiteCpp', 'sqlitecpp_dep'], -) +if not get_option('with_sqlite').disabled() + sqlitecpp_dep = dependency('sqlitecpp', version: '>=3.0.0', + fallback: ['SQLiteCpp', 'sqlitecpp_dep'], + required: get_option('with_sqlite'), + ) +else + sqlitecpp_dep = disabler() +endif ev_dep = dependency('libev', version: '>=4.31') threads_dep = dependency('threads') @@ -33,6 +38,7 @@ version_arr = meson.project_version().split('.') conf.set('PROJECT_VERSION_MAJOR', version_arr[0]) conf.set('PROJECT_VERSION_MINOR', version_arr[1]) conf.set('PROJECT_VERSION_PATCH', version_arr[2]) +conf.set('OROTOOL_WITH_SQLITE', sqlitecpp_dep.found()) project_config_file = configure_file( input: 'config.hpp.in', output: meson.project_name() + '_config.hpp', @@ -43,13 +49,24 @@ gnulib_conf = configuration_data() gnulib_conf.set('_GL_ATTRIBUTE_CONST', '__attribute__ ((__const__))') configure_file(output : 'config.h', configuration : gnulib_conf) +backend_libs = [ + sqlitecpp_dep, +] + +backends_selected = false +foreach backend_lib : backend_libs + backends_selected = backends_selected or backend_lib.found() +endforeach +if not backends_selected + error('No backend was enabled or none of the enabled backend dependencies could be located') +endif + lib_deps = [ restc_cpp_dep, - sqlitecpp_dep, ev_dep, threads_dep, boost_dep, -] +] + backend_libs executable(meson.project_name(), 'main.cpp', diff --git a/src/oro/originsdb.cpp b/src/oro/originsdb.cpp index aac5841..5f9234a 100644 --- a/src/oro/originsdb.cpp +++ b/src/oro/originsdb.cpp @@ -15,6 +15,9 @@ * along with Orotool. If not, see . */ +#include "orotool_config.hpp" +#if defined(OROTOOL_WITH_SQLITE) + #include "originsdb.hpp" #include "SQLiteCpp/Database.h" #include "SQLiteCpp/Statement.h" @@ -557,3 +560,5 @@ Timestamp OriginsDB::next_access_time (DBOperation op) const { } } //namespace oro + +#endif