Skip to content

cmake: provide generic hidapi pkg-config alias#831

Open
giri256 wants to merge 2 commits into
libusb:masterfrom
giri256:fix/generic-pkg-config-alias
Open

cmake: provide generic hidapi pkg-config alias#831
giri256 wants to merge 2 commits into
libusb:masterfrom
giri256:fix/generic-pkg-config-alias

Conversation

@giri256

@giri256 giri256 commented Jul 26, 2026

Copy link
Copy Markdown

Provide a generic hidapi.pc package for the selected default backend while continuing to install each enabled backend's own pkg-config package.

The generic pc/hidapi.pc.in template now accepts an explicit library name and is reused by both CMake and Autotools. Backend-specific packages are generated from one parameterized pc/hidapi-backend-specific.pc.in template, including dedicated hidapi-darwin.pc and hidapi-winapi.pc packages. Autotools preserves the existing package names, descriptions, linker flags, and direct config.status pc/hidapi-*.pc outputs for compatibility with existing build systems.

Linux CI now verifies that hidapi.pc is installed and uses a small standalone Autotools consumer to compile and link through pkg-config hidapi when both hidraw and libusb backends are present.

Tests:

  • CMake configure/build/install with both Linux backends, plus the standalone pkg-config consumer
  • Autotools bootstrap/configure/build/install, direct config.status regeneration, and the standalone pkg-config consumer
  • Synthetic Darwin, FreeBSD, Windows, and NetBSD pkg-config generation checks
  • Native Windows CMake build/install with Visual Studio 2022
  • Full PR CI matrix, including the new Ubuntu pkg-config compile/link step
  • git diff --check and whitespace-insensitive diff audit

Fixes: #638

Assisted-by: ChatGPT:GPT-5.6-Thinking
Assisted-by: codex:gpt-5.6-sol

Assisted-by: ChatGPT:GPT-5.6-Thinking
@mcuee mcuee added build system/CI Anything related to building the project or running on CI CMake Related to CMake build system and removed build system/CI Anything related to building the project or running on CI labels Jul 27, 2026
@Youw

Youw commented Jul 27, 2026

Copy link
Copy Markdown
Member

Thanks for looking into this!
I'll update this a bit per my taste, to generalize the solution.

Reuse one backend-specific template across CMake and Autotools, install the generic package consistently, and exercise it through an Autotools consumer in Linux CI.

Assisted-by: codex:gpt-5.6-sol

@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.

Try if this works for you.

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

Labels

CMake Related to CMake build system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

hidapi is not available via pkg-config on BSD systems when built with CMake

3 participants