Skip to content
Permalink
Browse files

Fixed bug 4639 - CMake build does not generate libhidapi.so for Android

Manuel Sabogal

I noticed that the current Android.mk builds a libhidapi.so library for Android but the CMake build hasn't been updated to do so. I'll attach a patch that fixes this issue.
  • Loading branch information
slouken committed May 22, 2019
1 parent 9b22028 commit 50aab1987794940559d14e715a3eed8532daad4a
Showing with 14 additions and 1 deletion.
  1. +14 −1 CMakeLists.txt
@@ -3,7 +3,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
endif()

cmake_minimum_required(VERSION 2.8.11)
project(SDL2 C)
project(SDL2 C CXX)

# !!! FIXME: this should probably do "MACOSX_RPATH ON" as a target property
# !!! FIXME: for the SDL2 shared library (so you get an
@@ -914,6 +914,8 @@ if(ANDROID)
endif()
endif()

file(GLOB ANDROID_HIDAPI_SOURCES ${SDL2_SOURCE_DIR}/src/hidapi/android/*.cpp)

CheckPTHREAD()

endif()
@@ -1776,6 +1778,17 @@ if(SDL_SHARED)
endif()
endif()

if(ANDROID)
add_library(hidapi SHARED ${ANDROID_HIDAPI_SOURCES})
if(MSVC AND NOT LIBC)
# Don't try to link with the default set of libraries.
set_target_properties(hidapi PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB")
set_target_properties(hidapi PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB")
set_target_properties(hidapi PROPERTIES STATIC_LIBRARY_FLAGS "/NODEFAULTLIB")
endif()
target_link_libraries(hidapi log)
endif()

if(SDL_STATIC)
set (BUILD_SHARED_LIBS FALSE)
add_library(SDL2-static STATIC ${SOURCE_FILES})

0 comments on commit 50aab19

Please sign in to comment.