Fix restc-cpp unit test's build

This commit is contained in:
King_DuckZ 2020-08-22 00:50:56 +01:00
parent 6dc4c3133f
commit 4b641e7976
5 changed files with 19 additions and 7 deletions

View file

@ -1,2 +1,3 @@
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')

View file

@ -1,7 +1,7 @@
conf = configuration_data()
cpp = meson.get_compiler('cpp')
conf.set('RESTC_CPP_WITH_UNIT_TESTS', get_option('restc_cpp_with_unit_tests') ? 1 : false)
conf.set('RESTC_CPP_WITH_UNIT_TESTS', unit_tests_enabled)
conf.set('RESTC_CPP_WITH_TLS', get_option('restc_cpp_with_tls') ? 1 : false)
conf.set('RESTC_CPP_LOG_WITH_BOOST_LOG', get_option('restc_cpp_log_with_boost_log') ? 1 : false)
conf.set('RESTC_CPP_WITH_ZLIB', get_option('restc_cpp_with_zlib') ? 1 : false)

View file

@ -34,6 +34,15 @@ endif
pvt_incdir = include_directories('restc-cpp/src')
pub_incdir = include_directories('restc-cpp/include', 'include')
if not get_option('tests').disabled()
#libs required by unit tests only here
boost_test_dep = dependency('boost', modules: ['log'], required: get_option('tests'))
unit_tests_enabled = boost_test_dep.found()
else
unit_tests_enabled = false
endif
subdir('include/restc-cpp')
restc_cpp_target = library(meson.project_name(),
@ -73,7 +82,7 @@ restc_cpp_dep = declare_dependency(
dependencies: [tls_dep, thread_dep, boost_dep],
)
if get_option('restc_cpp_with_unit_tests')
if unit_tests_enabled
lest_inc = include_directories('subprojects/lest/include')
subdir('tests')
endif

View file

@ -1,6 +1,6 @@
option('restc_cpp_max_input_buffer_length', type: 'integer', value: 0x7fffffff)
option('embedded_restc_cpp', type: 'boolean', value: false)
option('restc_cpp_with_unit_tests', type: 'boolean', value: false)
option('tests', type: 'feature', value: 'enabled', yield: true)
option('restc_cpp_with_tls', type: 'boolean', value: true)
option('restc_cpp_log_with_boost_log', type: 'boolean', value: true)
option('restc_cpp_with_zlib', type: 'boolean', value: true)

View file

@ -1,3 +1,5 @@
boost_dep = dependency('boost', modules: ['log'])
url_tests = executable('url_tests',
'../../restc-cpp/tests/unit/UrlTests.cpp',
dependencies: [restc_cpp_dep],
@ -6,25 +8,25 @@ url_tests = executable('url_tests',
json_serialize_tests = executable('json_serialize_tests',
'../../restc-cpp/tests/unit/JsonSerializeTests.cpp',
dependencies: [restc_cpp_dep],
dependencies: [restc_cpp_dep, boost_dep],
include_directories: [lest_inc],
)
json_iostream_tests = executable('json_iostream_tests',
'../../restc-cpp/tests/unit/Iostream2JsonTests.cpp',
dependencies: [restc_cpp_dep],
dependencies: [restc_cpp_dep, boost_dep],
include_directories: [lest_inc],
)
http_reply_tests = executable('http_reply_tests',
'../../restc-cpp/tests/unit/HttpReplyTests.cpp',
dependencies: [restc_cpp_dep],
dependencies: [restc_cpp_dep, boost_dep],
include_directories: [lest_inc],
)
async_sleep_tests = executable('async_sleep_tests',
'../../restc-cpp/tests/unit/AsyncSleepTests.cpp',
dependencies: [restc_cpp_dep],
dependencies: [restc_cpp_dep, boost_dep],
include_directories: [lest_inc],
)