cmake: provide generic hidapi pkg-config alias #831

Merged
giri256 merged 2 commits from fix/generic-pkg-config-alias into master 2026-07-30 11:56:38 -05:00
giri256 commented 2026-07-26 17:24:57 -05:00 (Migrated from github.com)

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

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
Youw commented 2026-07-27 05:20:00 -05:00 (Migrated from github.com)

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

Thanks for looking into this! I'll update this a bit per my taste, to generalize the solution.
Youw (Migrated from github.com) approved these changes 2026-07-27 07:14:20 -05:00
Youw (Migrated from github.com) left a comment

Try if this works for you.

Try if this works for you.
Youw commented 2026-07-30 03:59:18 -05:00 (Migrated from github.com)

@giri256 once you confirm latest changes didn't break anything for your flow - I'll have this merged

@giri256 once you confirm latest changes didn't break anything for your flow - I'll have this merged
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libusb/hidapi!831
No description provided.