Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake: clean up HIDAPI build #5318

Merged
merged 2 commits into from
May 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMake/FindHIDAPI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,12 @@ set(HIDAPI_INCLUDE_DIRS ${HIDAPI_INCLUDE_DIR})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(HIDAPI DEFAULT_MSG HIDAPI_LIBRARY HIDAPI_INCLUDE_DIR)

if(HIDAPI_FOUND AND NOT TARGET Hidapi::Hidapi)
add_library(Hidapi::Hidapi UNKNOWN IMPORTED)
set_target_properties(Hidapi::Hidapi PROPERTIES
IMPORTED_LOCATION ${HIDAPI_LIBRARIES}
INTERFACE_INCLUDE_DIRECTORIES ${HIDAPI_INCLUDE_DIRS}
)
endif()

mark_as_advanced(HIDAPI_INCLUDE_DIR HIDAPI_LIBRARY)
36 changes: 3 additions & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -752,39 +752,9 @@ list(APPEND LIBS ${ICONV_LIBRARIES})

if(NOT ANDROID)
find_package(HIDAPI)
if(HIDAPI_FOUND)
message(STATUS "Using shared ${HIDAPI_LIBRARIES} ${HIDAPI_VERSION}")
include_directories(${HIDAPI_INCLUDE_DIRS})
list(APPEND LIBS ${HIDAPI_LIBRARIES})
else()
set(HIDAPI_FOUND 1)
include_directories(Externals/hidapi/hidapi)
if(APPLE)
message(STATUS "Using static hidapi from Externals")
add_subdirectory(Externals/hidapi/mac)
list(APPEND LIBS hidapi)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
find_package(Libudev)
if(LIBUDEV_FOUND)
message(STATUS "Using static hidapi-hidraw from Externals")
add_subdirectory(Externals/hidapi/linux)
list(APPEND LIBS hidapi-hidraw udev)
else()
message(STATUS "Could not find udev, disabling hidapi")
set(HIDAPI_FOUND 0)
endif()
elseif(MSVC)
message(STATUS "Using static hidapi-hid from Externals")
add_subdirectory(Externals/hidapi/windows)
list(APPEND LIBS hidapi-hid)
else()
message(STATUS "Using static hidapi-libusb from Externals")
add_subdirectory(Externals/hidapi/libusb)
list(APPEND LIBS hidapi-libusb)
endif()
endif()
if(HIDAPI_FOUND)
add_definitions(-DHAVE_HIDAPI=1)
if(NOT HIDAPI_FOUND)
message(STATUS "Using static HIDAPI from Externals")
add_subdirectory(Externals/hidapi EXCLUDE_FROM_ALL)
endif()
endif()

Expand Down
20 changes: 0 additions & 20 deletions Externals/hidapi/.gitignore

This file was deleted.

20 changes: 20 additions & 0 deletions Externals/hidapi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
project(hidapi)

add_library(hidapi STATIC hidapi/hidapi.h)
target_include_directories(hidapi PUBLIC hidapi)

if(APPLE)
target_sources(hidapi PRIVATE mac/hid.c)
elseif(MSVC)
target_sources(hidapi PRIVATE windows/hid.c)
else()
find_package(Libudev)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND LIBUDEV_FOUND)
target_sources(hidapi PRIVATE linux/hid.c)
target_link_libraries(hidapi PRIVATE udev)
else()
target_sources(hidapi PRIVATE libusb/hid.c)
endif()
endif()

add_library(Hidapi::Hidapi ALIAS hidapi)
81 changes: 0 additions & 81 deletions Externals/hidapi/Makefile.am

This file was deleted.

19 changes: 0 additions & 19 deletions Externals/hidapi/android/jni/Android.mk

This file was deleted.

2 changes: 0 additions & 2 deletions Externals/hidapi/bootstrap

This file was deleted.