Skip to content

Linux/CMake: INTERFACE_INCLUDE_DIRECTORIES property of target hidapi::hidapi not correctly set in libhidapi.cmake (v0.12.0) #483

@stsichler

Description

@stsichler

I have built hidapi (0.12.0) from source and installed it into a local directory (/home/xxxx/.lib/hidapi-0.12.0/x86_64-linux-gnu) using following commands:

git clone https://github.com/libusb/hidapi.git --branch hidapi-0.12.0 --depth 1 -c advice.detachedHead=false .lib/hidapi-0.12.0/src
cmake -S .lib/hidapi-0.12.0/src -B .lib/hidapi-0.12.0/x86_64-linux-gnu/.build -DCMAKE_INSTALL_PREFIX=.lib/hidapi-0.12.0/x86_64-linux-gnu -DBUILD_SHARED_LIBS=OFF
cmake --build .lib/hidapi-0.12.0/x86_64-linux-gnu/.build --config Release
cmake --install .lib/hidapi-0.12.0/x86_64-linux-gnu/.build

hidapi properly installes into the correct location, but the resulting contents of the generated libhidapi.cmake file includes these lines:

set_target_properties(hidapi::include PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "/hidapi"
)

Note that installation prefix is missing here from the INTERFACE_INCLUDE_DIRECTORIES path.
In consequence, CMake outputs the following error when I try to consume the hidapi::hidapi target from another project:

CMake Error in CMakeLists.txt:
  Imported target "hidapi::hidapi" includes non-existent path

    "/hidapi"

  in its INTERFACE_INCLUDE_DIRECTORIES.  Possible reasons include:

  * The path was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and references files it does not
  provide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CMakeRelated to CMake build systembugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions