Add an option to enable/disable sqlite backend
Currently you can't disable it since sqlite is the only supported backend and you must have at least one enabled and available on the system. This will be needed for later.
This commit is contained in:
parent
4b641e7976
commit
2a407294e1
4 changed files with 30 additions and 5 deletions
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
* along with Orotool. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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
|
||||
|
|
Loading…
Reference in a new issue