Skip to content

meson: honor default_library=static - #858

Open
ebraminio wants to merge 1 commit into
libusb:masterfrom
ebraminio:meson-static
Open

ebraminio wants to merge 1 commit into
libusb:masterfrom
ebraminio:meson-static

Conversation

@ebraminio

@ebraminio ebraminio commented Nov 18, 2026 •

Copy link
Copy Markdown

HIDAPI's Meson build hands the work to CMake, but it currently drops Meson's default_library choice on the floor. Asking for -Ddefault_library=static still builds a shared library, which breaks downstream/wrap builds that need static linking.

The CMake project already understands BUILD_SHARED_LIBS, so forward the requested choice: OFF for static and ON for shared. Shared remains the default.

@Youw Youw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit odd that an of-the-box adapter doesn't pass all the standard parameters by default...

In addition to this - should you also have a symmetric option:

if get_option('default_library') == 'static'
	hidapi_build_options.add_cmake_defines({'BUILD_SHARED_LIBS': 'OFF'})
elif get_option('default_library') == 'shared'
	hidapi_build_options.add_cmake_defines({'BUILD_SHARED_LIBS': 'ON'})
endif

?

The Meson shim delegates to the CMake build without forwarding the requested
library type, so default_library=static still produced shared libraries.
Forward the requested type: BUILD_SHARED_LIBS=OFF for static, ON for shared.

Assisted-by: deepseek-harness:deepseek-flash
@ebraminio

ebraminio commented Nov 19, 2026 •

Copy link
Copy Markdown
Author

Added the symmetric shared branch (BUILD_SHARED_LIBS=ON). Re-tested both modes: static produces libhidapi_darwin.a, shared produces libhidapi_darwin.dylib.

@mcuee mcuee added the build system/CI Anything related to building the project or running on CI label Nov 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build system/CI Anything related to building the project or running on CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants