xref: /aosp_15_r20/external/oboe/samples/LiveEffect/src/main/cpp/ndk-stl-config.cmake (revision 05767d913155b055644481607e6fa1e35e2fe72c)
1# Copy shared STL files to Android Studio output directory so they can be
2# packaged in the APK.
3# Usage:
4#
5#   find_package(ndk-stl REQUIRED)
6#
7# or
8#
9#   find_package(ndk-stl REQUIRED PATHS ".")
10
11if(NOT ${ANDROID_STL} MATCHES "_shared")
12  return()
13endif()
14
15function(configure_shared_stl lib_path so_base)
16  message("Configuring STL ${so_base} for ${ANDROID_ABI}")
17  configure_file(
18    "${ANDROID_NDK}/sources/cxx-stl/${lib_path}/libs/${ANDROID_ABI}/lib${so_base}.so"
19    "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${so_base}.so"
20    COPYONLY)
21endfunction()
22
23if("${ANDROID_STL}" STREQUAL "libstdc++")
24  # The default minimal system C++ runtime library.
25elseif("${ANDROID_STL}" STREQUAL "gabi++_shared")
26  # The GAbi++ runtime (shared).
27  message(FATAL_ERROR "gabi++_shared was not configured by ndk-stl package")
28elseif("${ANDROID_STL}" STREQUAL "stlport_shared")
29  # The STLport runtime (shared).
30  configure_shared_stl("stlport" "stlport_shared")
31elseif("${ANDROID_STL}" STREQUAL "gnustl_shared")
32  # The GNU STL (shared).
33  configure_shared_stl("gnu-libstdc++/4.9" "gnustl_shared")
34elseif("${ANDROID_STL}" STREQUAL "c++_shared")
35  # The LLVM libc++ runtime (shared).
36  configure_shared_stl("llvm-libc++" "c++_shared")
37else()
38   message(FATAL_ERROR "STL configuration ANDROID_STL=${ANDROID_STL} is not supported")
39endif()
40
41