2021-09-04 08:33:53 -07:00
|
|
|
# SPDX-FileCopyrightText: 2021 Andrea Pappacoda
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: MIT
|
2021-06-05 13:45:00 -07:00
|
|
|
|
2021-09-04 08:33:53 -07:00
|
|
|
project(
|
|
|
|
'cpp-httplib',
|
|
|
|
'cpp',
|
|
|
|
license: 'MIT',
|
|
|
|
default_options: [
|
2021-09-11 11:26:48 -07:00
|
|
|
'cpp_std=c++11',
|
2021-09-04 08:33:53 -07:00
|
|
|
'buildtype=release',
|
|
|
|
'b_ndebug=if-release',
|
|
|
|
'b_lto=true',
|
|
|
|
'warning_level=3'
|
|
|
|
],
|
2024-09-17 13:58:09 -07:00
|
|
|
meson_version: '>=0.62.0'
|
2021-09-04 08:33:53 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
# Check just in case downstream decides to edit the source
|
|
|
|
# and add a project version
|
|
|
|
version = meson.project_version()
|
|
|
|
if version == 'undefined'
|
2022-04-19 04:11:51 -07:00
|
|
|
cxx = meson.get_compiler('cpp')
|
|
|
|
version = cxx.get_define('CPPHTTPLIB_VERSION',
|
|
|
|
prefix: '#include <httplib.h>',
|
|
|
|
include_directories: include_directories('.')).strip('"')
|
|
|
|
assert(version != '', 'failed to get version from httplib.h')
|
2021-09-04 08:33:53 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
deps = [dependency('threads')]
|
|
|
|
args = []
|
|
|
|
|
2023-12-24 06:20:58 -07:00
|
|
|
openssl_dep = dependency('openssl', version: '>=3.0.0', required: get_option('cpp-httplib_openssl'))
|
2021-09-04 08:33:53 -07:00
|
|
|
if openssl_dep.found()
|
|
|
|
deps += openssl_dep
|
|
|
|
args += '-DCPPHTTPLIB_OPENSSL_SUPPORT'
|
2023-02-17 10:06:55 -07:00
|
|
|
if host_machine.system() == 'darwin'
|
2023-04-04 07:12:15 -07:00
|
|
|
macosx_keychain_dep = dependency('appleframeworks', modules: ['CoreFoundation', 'Security'], required: get_option('cpp-httplib_macosx_keychain'))
|
|
|
|
if macosx_keychain_dep.found()
|
|
|
|
deps += macosx_keychain_dep
|
|
|
|
args += '-DCPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN'
|
|
|
|
endif
|
2023-02-17 10:06:55 -07:00
|
|
|
endif
|
2021-09-04 08:33:53 -07:00
|
|
|
endif
|
|
|
|
|
|
|
|
zlib_dep = dependency('zlib', required: get_option('cpp-httplib_zlib'))
|
|
|
|
if zlib_dep.found()
|
|
|
|
deps += zlib_dep
|
|
|
|
args += '-DCPPHTTPLIB_ZLIB_SUPPORT'
|
|
|
|
endif
|
|
|
|
|
|
|
|
brotli_deps = [dependency('libbrotlicommon', required: get_option('cpp-httplib_brotli'))]
|
|
|
|
brotli_deps += dependency('libbrotlidec', required: get_option('cpp-httplib_brotli'))
|
|
|
|
brotli_deps += dependency('libbrotlienc', required: get_option('cpp-httplib_brotli'))
|
|
|
|
|
|
|
|
brotli_found_all = true
|
|
|
|
foreach brotli_dep : brotli_deps
|
|
|
|
if not brotli_dep.found()
|
|
|
|
brotli_found_all = false
|
|
|
|
endif
|
|
|
|
endforeach
|
|
|
|
|
|
|
|
if brotli_found_all
|
|
|
|
deps += brotli_deps
|
|
|
|
args += '-DCPPHTTPLIB_BROTLI_SUPPORT'
|
|
|
|
endif
|
|
|
|
|
2021-09-11 11:26:48 -07:00
|
|
|
cpp_httplib_dep = dependency('', required: false)
|
2021-09-04 08:33:53 -07:00
|
|
|
|
|
|
|
if get_option('cpp-httplib_compile')
|
2022-04-30 14:40:47 -07:00
|
|
|
python3 = find_program('python3')
|
|
|
|
|
2021-09-04 08:33:53 -07:00
|
|
|
httplib_ch = custom_target(
|
|
|
|
'split',
|
|
|
|
input: 'httplib.h',
|
|
|
|
output: ['httplib.cc', 'httplib.h'],
|
2022-02-03 17:50:49 -07:00
|
|
|
command: [python3, files('split.py'), '--out', meson.current_build_dir()],
|
2021-09-04 08:33:53 -07:00
|
|
|
install: true,
|
|
|
|
install_dir: [false, get_option('includedir')]
|
|
|
|
)
|
|
|
|
lib = library(
|
|
|
|
'cpp-httplib',
|
|
|
|
sources: httplib_ch,
|
|
|
|
dependencies: deps,
|
|
|
|
cpp_args: args,
|
|
|
|
version: version,
|
2022-08-12 10:48:40 -07:00
|
|
|
soversion: version.split('.')[0] + '.' + version.split('.')[1],
|
2021-09-04 08:33:53 -07:00
|
|
|
install: true
|
|
|
|
)
|
2021-11-15 12:03:25 -07:00
|
|
|
cpp_httplib_dep = declare_dependency(compile_args: args, dependencies: deps, link_with: lib, sources: httplib_ch[1])
|
2021-09-04 08:33:53 -07:00
|
|
|
|
|
|
|
import('pkgconfig').generate(
|
|
|
|
lib,
|
|
|
|
description: 'A C++ HTTP/HTTPS server and client library',
|
2021-11-15 20:50:33 -07:00
|
|
|
extra_cflags: args,
|
2021-09-04 08:33:53 -07:00
|
|
|
url: 'https://github.com/yhirose/cpp-httplib',
|
|
|
|
version: version
|
|
|
|
)
|
|
|
|
else
|
|
|
|
install_headers('httplib.h')
|
2024-09-17 13:58:09 -07:00
|
|
|
cpp_httplib_dep = declare_dependency(compile_args: args, dependencies: deps, include_directories: '.')
|
2022-02-03 17:50:49 -07:00
|
|
|
|
|
|
|
import('pkgconfig').generate(
|
|
|
|
name: 'cpp-httplib',
|
|
|
|
description: 'A C++ HTTP/HTTPS server and client library',
|
2024-09-17 13:58:09 -07:00
|
|
|
install_dir: get_option('datadir')/'pkgconfig',
|
2022-02-03 17:50:49 -07:00
|
|
|
url: 'https://github.com/yhirose/cpp-httplib',
|
|
|
|
version: version
|
|
|
|
)
|
2021-09-04 08:33:53 -07:00
|
|
|
endif
|
2021-06-05 13:45:00 -07:00
|
|
|
|
2024-09-17 13:58:09 -07:00
|
|
|
meson.override_dependency('cpp-httplib', cpp_httplib_dep)
|
2021-09-11 11:26:48 -07:00
|
|
|
|
|
|
|
if get_option('cpp-httplib_test')
|
|
|
|
subdir('test')
|
|
|
|
endif
|