1

I've built SDL for Android with ndk-build and Android-Make-Files. Now I want to find these libraries in my CMakeLists.txt. The libs are found here:

lib/
    SDL/
        arm64-v8a/
        armeabi/
        armeabi-v7a/
        x86/
        x96_64/

Each directory contains libSDL2.so. How can I load all these libraries in CMake and naming them SDL2_LIBRARY? My current approach is

set(SDL2_INCLUDE_DIR lib/SDL/include)
include_directories(${SDL2_INCLUDE_DIR})

FIND_LIBRARY(SDL2_LIBRARY NAMES libSDL2.so PATHS lib/Android/SDL/armeabi-v7a)

(I don't even know how to find all of them and not just armeabi-v7a.)

EDIT: Since building for all plattforms is not possible, what is wrong with my usage of FIND_LIBRARY?

  • Using several libraries with the same name **at once** looks very strange: what you are trying to achive with that? As for finding files, you may use command [file(GLOB_RECURSE)](https://cmake.org/cmake/help/v3.7/command/file.html), like `file(GLOB_RECURSE SDL2_LIBRARY "lib/Android/SDL/armeabi-v7a/*/libSDL2.so")`, But again, the whole intention seems weird for me. – Tsyvarev Jun 09 '17 at 18:42
  • It also seems weird to me, but NDK puts all those library into the APK, if built with Android make for support of more platforms. – PaulProgrammerNoob Jun 09 '17 at 18:45
  • 1
    With CMake you can build only for **single platform** at once. See also [this question](https://stackoverflow.com/questions/44343091/cmake-project-for-jni#comment75695830_44343091). – Tsyvarev Jun 09 '17 at 18:49

0 Answers0