Skip to content

Commit 874b29c

Browse files
authored
Fix find_package(hidapi) warnings (#404)
- FindPkgConfig.cmake warns it is not called by find_package; - CMake package `config` file and `exports` file names should not match, otherwise it gets included recursively by GLOB expression;
1 parent 08563a0 commit 874b29c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ if(HIDAPI_INSTALL_TARGETS)
150150
include(CMakePackageConfigHelpers)
151151
set(EXPORT_DENERATED_LOCATION "${CMAKE_BINARY_DIR}/export_generated")
152152
set(EXPORT_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/hidapi")
153-
write_basic_package_version_file("${EXPORT_DENERATED_LOCATION}/hidapi-config-version.cmake"
153+
write_basic_package_version_file("${EXPORT_DENERATED_LOCATION}/libhidapi-version.cmake"
154154
COMPATIBILITY SameMajorVersion
155155
)
156156
configure_package_config_file("cmake/hidapi-config.cmake.in" "${EXPORT_DENERATED_LOCATION}/hidapi-config.cmake"
@@ -161,9 +161,10 @@ if(HIDAPI_INSTALL_TARGETS)
161161
install(EXPORT hidapi
162162
DESTINATION "${EXPORT_DESTINATION}"
163163
NAMESPACE hidapi::
164+
FILE "libhidapi.cmake"
164165
)
165166
install(FILES
166-
"${EXPORT_DENERATED_LOCATION}/hidapi-config-version.cmake"
167+
"${EXPORT_DENERATED_LOCATION}/libhidapi-version.cmake"
167168
"${EXPORT_DENERATED_LOCATION}/hidapi-config.cmake"
168169
DESTINATION "${EXPORT_DESTINATION}"
169170
)

src/cmake/hidapi-config.cmake.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if(HIDAPI_NEED_EXPORT_LIBUSB OR HIDAPI_NEED_EXPORT_LIBUDEV)
2323
if(CMAKE_VERSION VERSION_LESS 3.6.3)
2424
message(FATAL_ERROR "This file relies on consumers using CMake 3.6.3 or greater.")
2525
endif()
26-
include(FindPkgConfig)
26+
find_package(PkgConfig)
2727
if(HIDAPI_NEED_EXPORT_LIBUSB)
2828
pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0>=1.0.9)
2929
endif()
@@ -32,7 +32,7 @@ if(HIDAPI_NEED_EXPORT_LIBUSB OR HIDAPI_NEED_EXPORT_LIBUDEV)
3232
endif()
3333
endif()
3434

35-
include("${CMAKE_CURRENT_LIST_DIR}/hidapi.cmake")
35+
include("${CMAKE_CURRENT_LIST_DIR}/libhidapi.cmake")
3636

3737
set(hidapi_FOUND TRUE)
3838

0 commit comments

Comments
 (0)