Android-Initialize.cmake 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #=============================================================================
  2. # Copyright 2015-2016 Kitware, Inc.
  3. #
  4. # Distributed under the OSI-approved BSD License (the "License");
  5. # see accompanying file Copyright.txt for details.
  6. #
  7. # This software is distributed WITHOUT ANY WARRANTY; without even the
  8. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. # See the License for more information.
  10. #=============================================================================
  11. # (To distribute this file outside of CMake, substitute the full
  12. # License text for the above reference.)
  13. # When CMAKE_SYSTEM_NAME is "Android", CMakeSystemSpecificInitialize loads this
  14. # module.
  15. # Support for NVIDIA Nsight Tegra Visual Studio Edition was previously
  16. # implemented in the CMake VS IDE generators. Avoid interfering with
  17. # that functionality for now. Later we may try to integrate this.
  18. if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
  19. return()
  20. endif()
  21. # Commonly used Android toolchain files that pre-date CMake upstream support
  22. # set CMAKE_SYSTEM_VERSION to 1. Avoid interfering with them.
  23. if(CMAKE_SYSTEM_VERSION EQUAL 1)
  24. return()
  25. endif()
  26. if(NOT CMAKE_SYSROOT)
  27. if(CMAKE_ANDROID_NDK)
  28. set(CMAKE_SYSROOT "${CMAKE_ANDROID_NDK}/platforms/android-${CMAKE_SYSTEM_VERSION}/arch-${CMAKE_ANDROID_ARCH}")
  29. elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
  30. set(CMAKE_SYSROOT "${CMAKE_ANDROID_STANDALONE_TOOLCHAIN}/sysroot")
  31. endif()
  32. endif()
  33. if(CMAKE_SYSROOT)
  34. if(NOT IS_DIRECTORY "${CMAKE_SYSROOT}")
  35. message(FATAL_ERROR
  36. "Android: The system root directory needed for the selected Android version and architecture does not exist:\n"
  37. " ${CMAKE_SYSROOT}\n"
  38. )
  39. endif()
  40. else()
  41. message(FATAL_ERROR
  42. "Android: No CMAKE_SYSROOT was selected."
  43. )
  44. endif()
  45. set(CMAKE_BUILD_TYPE_INIT Debug)