From 50aab1987794940559d14e715a3eed8532daad4a Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 21 May 2019 17:33:31 -0700 Subject: [PATCH] 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. --- CMakeLists.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c13258850e79..6be16c29a4ed2 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})