Android-Initialize.cmake 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. if(NOT CMAKE_SYSROOT)
  17. if(CMAKE_ANDROID_NDK)
  18. set(CMAKE_SYSROOT "${CMAKE_ANDROID_NDK}/platforms/android-${CMAKE_SYSTEM_VERSION}/arch-${CMAKE_ANDROID_ARCH}")
  19. if(NOT CMAKE_ANDROID_NDK_DEPRECATED_HEADERS)
  20. set(CMAKE_SYSROOT_COMPILE "${CMAKE_ANDROID_NDK}/sysroot")
  21. endif()
  22. elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
  23. set(CMAKE_SYSROOT "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/sysroot")
  24. endif()
  25. endif()
  26. if(CMAKE_SYSROOT)
  27. if(NOT IS_DIRECTORY "${CMAKE_SYSROOT}")
  28. message(FATAL_ERROR
  29. "Android: The system root directory needed for the selected Android version and architecture does not exist:\n"
  30. " ${CMAKE_SYSROOT}\n"
  31. )
  32. endif()
  33. else()
  34. message(FATAL_ERROR
  35. "Android: No CMAKE_SYSROOT was selected."
  36. )
  37. endif()
  38. set(CMAKE_BUILD_TYPE_INIT Debug)