Skip to content

Commit 99edf29

Browse files
committed
build(meson): automatically use poll or select as needed
Follow-up to 6e73a63
1 parent d274c0a commit 99edf29

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

meson.build

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,26 @@ project(
1616
meson_version: '>=0.62.0'
1717
)
1818

19+
cxx = meson.get_compiler('cpp')
20+
1921
# Check just in case downstream decides to edit the source
2022
# and add a project version
2123
version = meson.project_version()
2224
if version == 'undefined'
23-
cxx = meson.get_compiler('cpp')
2425
version = cxx.get_define('CPPHTTPLIB_VERSION',
2526
prefix: '#include <httplib.h>',
2627
include_directories: include_directories('.')).strip('"')
2728
assert(version != '', 'failed to get version from httplib.h')
2829
endif
2930

31+
if cxx.has_function('poll', prefix: '#include <poll.h>')
32+
# Use poll if present
33+
add_project_arguments('-DCPPHTTPLIB_USE_POLL', language: 'cpp')
34+
else if cxx.has_function('select', prefix: '#include <sys/select.h>')
35+
# Use select otherwise
36+
add_project_arguments('-DCPPHTTPLIB_USE_SELECT', language: 'cpp')
37+
endif
38+
3039
deps = [dependency('threads')]
3140
args = []
3241

0 commit comments

Comments
 (0)