From 2b5d1eea8d7e9f881ac4be04ce31df782b26b6a9 Mon Sep 17 00:00:00 2001 From: Andrea Pappacoda Date: Wed, 19 Feb 2025 18:47:56 +0100 Subject: [PATCH] build(meson): automatically use poll or select as needed (#2067) Follow-up to 6e73a63153e936e753211a5608acf336fb848a37 --- meson.build | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 9fa1919c8b..4ae18c0fb9 100644 --- a/meson.build +++ b/meson.build @@ -16,17 +16,26 @@ project( meson_version: '>=0.62.0' ) +cxx = meson.get_compiler('cpp') + # Check just in case downstream decides to edit the source # and add a project version version = meson.project_version() if version == 'undefined' - cxx = meson.get_compiler('cpp') version = cxx.get_define('CPPHTTPLIB_VERSION', prefix: '#include ', include_directories: include_directories('.')).strip('"') assert(version != '', 'failed to get version from httplib.h') endif +if cxx.has_function('poll', prefix: '#include ') + # Use poll if present + add_project_arguments('-DCPPHTTPLIB_USE_POLL', language: 'cpp') +else if cxx.has_function('select', prefix: '#include ') + # Use select otherwise + add_project_arguments('-DCPPHTTPLIB_USE_SELECT', language: 'cpp') +endif + deps = [dependency('threads')] args = []