Skip to content

Commit

Permalink
Add <root>/libusb to includes for in-tree build
Browse files Browse the repository at this point in the history
Otherwise it is impossible to `#include <hidapi_libusb.h>`,
when HIDAPI is added directly as a subdirectory of a CMake project.
  • Loading branch information
Youw committed Sep 27, 2021
1 parent b923aed commit 0ec60c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libusb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ else()
set(HIDAPI_WITH_LIBUSB ON)
endif()
if(HIDAPI_WITH_LIBUSB)
target_include_directories(hidapi_include INTERFACE
"$<BUILD_INTERFACE:${PROJECT_ROOT}/libusb>"
)
add_subdirectory("${PROJECT_ROOT}/libusb" libusb)
list(APPEND EXPORT_COMPONENTS libusb)
if(NOT EXPORT_ALIAS)
Expand Down

0 comments on commit 0ec60c0

Please sign in to comment.