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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7c13258..6be16c2 100644
--- a/CMakeLists.txt
+++ b/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})