Linux/CMake: find_package(hidapi) cannot find specific version (v0.12.0) #482

Closed
opened 2022-11-16 03:17:25 -06:00 by stsichler · 2 comments
stsichler commented 2022-11-16 03:17:25 -06:00 (Migrated from github.com)

I have built hidapi (0.12.0) from source (using git clone from git tag hidapi-0.12.0) and installed it into a local directory (/home/xxxx/.lib/hidapi-0.12.0/x86_64-linux-gnu).
When I now try to import it into my CMake build system using find_package(hidapi 0.12.0 CONFIG REQUIRED), CMake rejects the installation.
CMake Output:

CMake Error at xxxx (find_package):
  Could not find a configuration file for package "hidapi" that exactly
  matches requested version "0.12.0".

  The following configuration files were considered but not accepted:

    /home/xxxx/.lib/hidapi-0.12.0/x86_64-linux-gnu/lib/cmake/hidapi/hidapi-config.cmake, version: unknown

Note that it is accepted when I remove the package version requirement from find_package().

This is strange, because all required files seem to be correctly installed:

$ find /home/xxxx/.lib/hidapi-0.12.0/x86_64-linux-gnu/lib/cmake/hidapi
/home/xxxx/.lib/hidapi-0.12.0/x86_64-linux-gnu/lib/cmake/hidapi
/home/xxxx/.lib/hidapi-0.12.0/x86_64-linux-gnu/lib/cmake/hidapi/hidapi-config.cmake
/home/xxxx/.lib/hidapi-0.12.0/x86_64-linux-gnu/lib/cmake/hidapi/libhidapi-release.cmake
/home/xxxx/.lib/hidapi-0.12.0/x86_64-linux-gnu/lib/cmake/hidapi/libhidapi.cmake
/home/xxxx/.lib/hidapi-0.12.0/x86_64-linux-gnu/lib/cmake/hidapi/libhidapi-version.cmake
I have built hidapi (0.12.0) from source (using git clone from git tag hidapi-0.12.0) and installed it into a local directory (/home/xxxx/.lib/hidapi-0.12.0/x86_64-linux-gnu). When I now try to import it into my CMake build system using `find_package(hidapi 0.12.0 CONFIG REQUIRED)`, CMake rejects the installation. CMake Output: ``` CMake Error at xxxx (find_package): Could not find a configuration file for package "hidapi" that exactly matches requested version "0.12.0". The following configuration files were considered but not accepted: /home/xxxx/.lib/hidapi-0.12.0/x86_64-linux-gnu/lib/cmake/hidapi/hidapi-config.cmake, version: unknown ``` Note that **it is accepted** when I remove the package version requirement from `find_package()`. This is strange, because all required files seem to be correctly installed: ``` $ find /home/xxxx/.lib/hidapi-0.12.0/x86_64-linux-gnu/lib/cmake/hidapi /home/xxxx/.lib/hidapi-0.12.0/x86_64-linux-gnu/lib/cmake/hidapi /home/xxxx/.lib/hidapi-0.12.0/x86_64-linux-gnu/lib/cmake/hidapi/hidapi-config.cmake /home/xxxx/.lib/hidapi-0.12.0/x86_64-linux-gnu/lib/cmake/hidapi/libhidapi-release.cmake /home/xxxx/.lib/hidapi-0.12.0/x86_64-linux-gnu/lib/cmake/hidapi/libhidapi.cmake /home/xxxx/.lib/hidapi-0.12.0/x86_64-linux-gnu/lib/cmake/hidapi/libhidapi-version.cmake ```
stsichler commented 2022-11-16 03:38:29 -06:00 (Migrated from github.com)

Ok, renaming the file libhidapi-version.cmake to hidapi-config-version.cmake solves the problem, but I don't know enough about CMake to decide whether that is the correct solution.
In addition, still the question remains whether the other files libhidapi*.cmake are named correctly.

Ok, renaming the file `libhidapi-version.cmake` to `hidapi-config-version.cmake` **solves** the problem, but I don't know enough about CMake to decide whether that is the correct solution. In addition, still the question remains whether the other files `libhidapi*.cmake` are named correctly.
Youw commented 2022-11-16 09:14:54 -06:00 (Migrated from github.com)

In addition, still the question remains whether the other files libhidapi*.cmake are named correctly.

Those are correct, otherwise you wouldn't get CMake targets for HIDAPI working.

> In addition, still the question remains whether the other files libhidapi*.cmake are named correctly. Those are correct, otherwise you wouldn't get CMake targets for HIDAPI working.
Sign in to join this conversation.
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#482
No description provided.