1
0
mirror of synced 2025-04-21 22:25:55 +03:00

build(meson): automatically use poll or select as needed (#2067)

Follow-up to 6e73a63153e936e753211a5608acf336fb848a37
This commit is contained in:
Andrea Pappacoda 2025-02-19 18:47:56 +01:00 committed by GitHub
parent d274c0abe5
commit 2b5d1eea8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,17 +16,26 @@ project(
meson_version: '>=0.62.0' meson_version: '>=0.62.0'
) )
cxx = meson.get_compiler('cpp')
# Check just in case downstream decides to edit the source # Check just in case downstream decides to edit the source
# and add a project version # and add a project version
version = meson.project_version() version = meson.project_version()
if version == 'undefined' if version == 'undefined'
cxx = meson.get_compiler('cpp')
version = cxx.get_define('CPPHTTPLIB_VERSION', version = cxx.get_define('CPPHTTPLIB_VERSION',
prefix: '#include <httplib.h>', prefix: '#include <httplib.h>',
include_directories: include_directories('.')).strip('"') include_directories: include_directories('.')).strip('"')
assert(version != '', 'failed to get version from httplib.h') assert(version != '', 'failed to get version from httplib.h')
endif endif
if cxx.has_function('poll', prefix: '#include <poll.h>')
# Use poll if present
add_project_arguments('-DCPPHTTPLIB_USE_POLL', language: 'cpp')
else if cxx.has_function('select', prefix: '#include <sys/select.h>')
# Use select otherwise
add_project_arguments('-DCPPHTTPLIB_USE_SELECT', language: 'cpp')
endif
deps = [dependency('threads')] deps = [dependency('threads')]
args = [] args = []