Skip to content

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

Closed

Description

@stsichler

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

Activity

  1. stsichler commented on Nov 16, 2022

    @stsichler
    ContributorAuthor

    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.

  2. changed the title [-]Linux/CMake: find_package(hidapi) cannot find specific version[/-] [+]Linux/CMake: find_package(hidapi) cannot find specific version (v0.12.0)[/+] on Nov 16, 2022
  3. added
    CMake
    bug
    on Nov 16, 2022
  4. Youw commented on Nov 16, 2022

    @Youw
    Member

    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.

  5. added a commit that references this issue on Nov 22, 2022
    3973449
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CMakebug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions