Android-Clang.cmake 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. # This module is shared by multiple languages; use include blocker.
  4. if(__ANDROID_COMPILER_CLANG)
  5. return()
  6. endif()
  7. set(__ANDROID_COMPILER_CLANG 1)
  8. # Support for NVIDIA Nsight Tegra Visual Studio Edition was previously
  9. # implemented in the CMake VS IDE generators. Avoid interfering with
  10. # that functionality for now. Later we may try to integrate this.
  11. if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
  12. macro(__android_compiler_clang lang)
  13. endmacro()
  14. return()
  15. endif()
  16. # Commonly used Android toolchain files that pre-date CMake upstream support
  17. # set CMAKE_SYSTEM_VERSION to 1. Avoid interfering with them.
  18. if(CMAKE_SYSTEM_VERSION EQUAL 1)
  19. macro(__android_compiler_clang lang)
  20. endmacro()
  21. return()
  22. endif()
  23. include(Platform/Android-Common)
  24. # The NDK toolchain configuration files at:
  25. #
  26. # <ndk>/[build/core/]toolchains/*-clang*/setup.mk
  27. #
  28. # contain logic to set LLVM_TRIPLE for Clang-based toolchains for each target.
  29. # We need to produce the same target here to produce compatible binaries.
  30. include(Platform/Android/abi-${CMAKE_ANDROID_ARCH_ABI}-Clang)
  31. macro(__android_compiler_clang lang)
  32. if(NOT "x${lang}" STREQUAL "xASM")
  33. __android_compiler_common(${lang})
  34. endif()
  35. if(NOT CMAKE_${lang}_COMPILER_TARGET)
  36. set(CMAKE_${lang}_COMPILER_TARGET "${_ANDROID_ABI_CLANG_TARGET}")
  37. if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
  38. string(APPEND CMAKE_${lang}_COMPILER_TARGET "${CMAKE_SYSTEM_VERSION}")
  39. endif()
  40. list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "--target=${CMAKE_${lang}_COMPILER_TARGET}")
  41. endif()
  42. endmacro()