Android.cmake 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Include the NDK hook.
  2. # It can be used by NDK to inject necessary fixes for an earlier cmake.
  3. if(CMAKE_ANDROID_NDK)
  4. include(${CMAKE_ANDROID_NDK}/build/cmake/hooks/pre/Android.cmake OPTIONAL)
  5. endif()
  6. # Natively compiling on an Android host doesn't need these flags to be reset.
  7. if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android")
  8. return()
  9. endif()
  10. # NDK organizes API level specific libraries in numbered subdirectories. To
  11. # avoid incorrect inclusion of libraries below the targeted API level, disable
  12. # architecture specific path suffixes by default.
  13. set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS OFF)
  14. set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF)
  15. # Conventionally Android does not use versioned soname
  16. # But in modern versions it is acceptable
  17. if(NOT DEFINED CMAKE_PLATFORM_NO_VERSIONED_SONAME)
  18. set(CMAKE_PLATFORM_NO_VERSIONED_SONAME 1)
  19. endif()
  20. # Android reportedly ignores RPATH, and we cannot predict the install
  21. # location anyway.
  22. set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "")
  23. # Nsight Tegra Visual Studio Edition takes care of
  24. # prefixing library names with '-l'.
  25. if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
  26. set(CMAKE_LINK_LIBRARY_FLAG "")
  27. endif()
  28. # Commonly used Android toolchain files that pre-date CMake upstream support
  29. # set CMAKE_SYSTEM_VERSION to 1. Avoid interfering with them.
  30. if(CMAKE_SYSTEM_VERSION EQUAL 1)
  31. # The NDK legacy toolchain file provides its version number.
  32. set(CMAKE_ANDROID_NDK_VERSION ${ANDROID_NDK_MAJOR}.${ANDROID_NDK_MINOR})
  33. return()
  34. endif()
  35. # Include the NDK hook.
  36. # It can be used by NDK to inject necessary fixes for an earlier cmake.
  37. if(CMAKE_ANDROID_NDK)
  38. include(${CMAKE_ANDROID_NDK}/build/cmake/hooks/post/Android.cmake OPTIONAL)
  39. endif()