From 6a6816ada750e8c3a936cf97f293d5d12445d8de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <> Date: Mon, 11 Dec 2023 22:16:58 -0500 Subject: [PATCH] build/meson: allow to build c binding --- meson.build | 31 ++++++++++++++++++++++++------ meson_options.txt => meson.options | 1 + 2 files changed, 26 insertions(+), 6 deletions(-) rename meson_options.txt => meson.options (82%) diff --git a/meson.build b/meson.build index c9a26057..0f806db3 100644 --- a/meson.build +++ b/meson.build @@ -74,26 +74,45 @@ opendht = shared_library('opendht', install : true) readline = meson.get_compiler('c').find_library('readline', required: get_option('tools')) + +if get_option('c').enabled() + opendht_c = shared_library('opendht-c', + ['c/opendht.cpp', 'c/opendht_c.h'], + include_directories : opendht_interface_inc, + link_with : opendht, + dependencies : [msgpack, fmt], + cpp_args : ['-DOPENDHT_C_BUILD', '-Dopendht_c_EXPORTS'], + install : true) + + if get_option('tools').enabled() + dhtcnode = executable('dhtcnode', 'tools/dhtcnode.c', + include_directories : ['c', opendht_interface_inc], + link_with : opendht_c, + dependencies : [readline], + install : true) + endif +endif + if get_option('tools').enabled() dhtnode = executable('dhtnode', 'tools/dhtnode.cpp', include_directories : opendht_interface_inc, link_with : opendht, - dependencies : [readline, msgpack, fmt], + dependencies : [readline, msgpack, fmt, openssl], install : true) dhtchat = executable('dhtchat', 'tools/dhtchat.cpp', include_directories : opendht_interface_inc, link_with : opendht, - dependencies : [readline, msgpack, fmt], + dependencies : [readline, msgpack, fmt, openssl], install : true) dhtscanner = executable('dhtscanner', 'tools/dhtscanner.cpp', include_directories : opendht_interface_inc, link_with : opendht, - dependencies : [readline, msgpack, fmt], + dependencies : [readline, msgpack, fmt, openssl], install : true) if http_parser.found() durl = executable('durl', 'tools/durl.cpp', - include_directories : opendht_interface_inc, - link_with : opendht, - dependencies : [msgpack, openssl]) + include_directories : opendht_interface_inc, + link_with : opendht, + dependencies : [msgpack, openssl]) endif endif diff --git a/meson_options.txt b/meson.options similarity index 82% rename from meson_options.txt rename to meson.options index 29017954..7bed03d1 100644 --- a/meson_options.txt +++ b/meson.options @@ -2,3 +2,4 @@ option('proxy_client', type : 'feature', value : 'disabled') option('proxy_server', type : 'feature', value : 'disabled') option('peer_discovery', type : 'feature', value : 'enabled') option('tools', type : 'feature', value : 'enabled') +option('c', type : 'feature', value : 'enabled') -- GitLab