Android-Initialize.cmake 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. # When CMAKE_SYSTEM_NAME is "Android", CMakeSystemSpecificInitialize loads this
  4. # module.
  5. # Support for NVIDIA Nsight Tegra Visual Studio Edition was previously
  6. # implemented in the CMake VS IDE generators. Avoid interfering with
  7. # that functionality for now. Later we may try to integrate this.
  8. if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
  9. return()
  10. endif()
  11. # Commonly used Android toolchain files that pre-date CMake upstream support
  12. # set CMAKE_SYSTEM_VERSION to 1. Avoid interfering with them.
  13. if(CMAKE_SYSTEM_VERSION EQUAL 1)
  14. return()
  15. endif()
  16. set(CMAKE_BUILD_TYPE_INIT Debug)
  17. # Skip sysroot selection if the NDK has a unified toolchain.
  18. if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
  19. return()
  20. endif()
  21. if(NOT CMAKE_SYSROOT)
  22. if(CMAKE_ANDROID_NDK)
  23. set(CMAKE_SYSROOT "${CMAKE_ANDROID_NDK}/platforms/android-${CMAKE_SYSTEM_VERSION}/arch-${CMAKE_ANDROID_ARCH}")
  24. if(NOT CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
  25. set(CMAKE_SYSROOT_COMPILE "${CMAKE_ANDROID_NDK}/sysroot")
  26. endif()
  27. elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
  28. set(CMAKE_SYSROOT "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/sysroot")
  29. endif()
  30. endif()
  31. if(CMAKE_SYSROOT)
  32. if(NOT IS_DIRECTORY "${CMAKE_SYSROOT}")
  33. message(FATAL_ERROR
  34. "Android: The system root directory needed for the selected Android version and architecture does not exist:\n"
  35. " ${CMAKE_SYSROOT}\n"
  36. )
  37. endif()
  38. else()
  39. message(FATAL_ERROR
  40. "Android: No CMAKE_SYSROOT was selected."
  41. )
  42. endif()