From 0ec60c03cbe87cdbfb9fb199c7536fdcbc0a94b8 Mon Sep 17 00:00:00 2001 From: Ihor Dutchak Date: Fri, 24 Sep 2021 18:58:01 +0300 Subject: [PATCH] Add /libusb to includes for in-tree build Otherwise it is impossible to `#include `, when HIDAPI is added directly as a subdirectory of a CMake project. --- libusb/CMakeLists.txt | 5 +++-- src/CMakeLists.txt | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libusb/CMakeLists.txt b/libusb/CMakeLists.txt index c7873de..f4392d7 100644 --- a/libusb/CMakeLists.txt +++ b/libusb/CMakeLists.txt @@ -1,9 +1,10 @@ cmake_minimum_required(VERSION 3.6.3 FATAL_ERROR) +list(APPEND HIDAPI_PUBLIC_HEADERS "hidapi_libusb.h") + add_library(hidapi_libusb ${HIDAPI_PUBLIC_HEADERS} hid.c - hidapi_libusb.h ) target_link_libraries(hidapi_libusb PUBLIC hidapi_include) @@ -24,7 +25,7 @@ set_target_properties(hidapi_libusb OUTPUT_NAME "hidapi-libusb" VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} - PUBLIC_HEADER "${HIDAPI_PUBLIC_HEADERS};hidapi_libusb.h" + PUBLIC_HEADER "${HIDAPI_PUBLIC_HEADERS}" ) # compatibility with find_package() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ae59369..8f454e5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -125,6 +125,9 @@ else() set(HIDAPI_WITH_LIBUSB ON) endif() if(HIDAPI_WITH_LIBUSB) + target_include_directories(hidapi_include INTERFACE + "$" + ) add_subdirectory("${PROJECT_ROOT}/libusb" libusb) list(APPEND EXPORT_COMPONENTS libusb) if(NOT EXPORT_ALIAS)