Android-Clang.cmake 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. # Natively compiling on an Android host doesn't use the NDK cross-compilation
  24. # tools.
  25. if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android")
  26. macro(__android_compiler_clang lang)
  27. endmacro()
  28. return()
  29. endif()
  30. include(Platform/Android-Common)
  31. # The NDK toolchain configuration files at:
  32. #
  33. # <ndk>/[build/core/]toolchains/*-clang*/setup.mk
  34. #
  35. # contain logic to set LLVM_TRIPLE for Clang-based toolchains for each target.
  36. # We need to produce the same target here to produce compatible binaries.
  37. include(Platform/Android/abi-${CMAKE_ANDROID_ARCH_ABI}-Clang)
  38. macro(__android_compiler_clang lang)
  39. if(NOT "x${lang}" STREQUAL "xASM")
  40. __android_compiler_common(${lang})
  41. endif()
  42. if(NOT CMAKE_${lang}_COMPILER_TARGET)
  43. set(CMAKE_${lang}_COMPILER_TARGET "${_ANDROID_ABI_CLANG_TARGET}")
  44. if(CMAKE_ANDROID_NDK_TOOLCHAIN_UNIFIED)
  45. string(APPEND CMAKE_${lang}_COMPILER_TARGET "${CMAKE_SYSTEM_VERSION}")
  46. endif()
  47. list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "--target=${CMAKE_${lang}_COMPILER_TARGET}")
  48. endif()
  49. if(CMAKE_GENERATOR MATCHES "Visual Studio")
  50. set(_ANDROID_STL_NOSTDLIBXX 1)
  51. endif()
  52. endmacro()