Android.cmake 1.7 KB

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