Determine-Compiler.cmake 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. # This module is shared by multiple languages; use include blocker.
  14. if(__ANDROID_DETERMINE_COMPILER)
  15. return()
  16. endif()
  17. set(__ANDROID_DETERMINE_COMPILER 1)
  18. # Support for NVIDIA Nsight Tegra Visual Studio Edition was previously
  19. # implemented in the CMake VS IDE generators. Avoid interfering with
  20. # that functionality for now. Later we may try to integrate this.
  21. if(CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")
  22. macro(__android_determine_compiler lang)
  23. endmacro()
  24. return()
  25. endif()
  26. # Identify the host platform.
  27. if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
  28. set(_ANDROID_HOST_EXT "")
  29. elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
  30. set(_ANDROID_HOST_EXT "")
  31. elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
  32. set(_ANDROID_HOST_EXT ".exe")
  33. else()
  34. message(FATAL_ERROR "Android: Builds hosted on '${CMAKE_HOST_SYSTEM_NAME}' not supported.")
  35. endif()
  36. if(CMAKE_ANDROID_NDK)
  37. include(Platform/Android/Determine-Compiler-NDK)
  38. elseif(CMAKE_ANDROID_STANDALONE_TOOLCHAIN)
  39. include(Platform/Android/Determine-Compiler-Standalone)
  40. else()
  41. set(_ANDROID_TOOL_C_COMPILER "")
  42. set(_ANDROID_TOOL_C_TOOLCHAIN_VERSION "")
  43. set(_ANDROID_TOOL_C_COMPILER_EXTERNAL_TOOLCHAIN "")
  44. set(_ANDROID_TOOL_C_TOOLCHAIN_PREFIX "")
  45. set(_ANDROID_TOOL_C_TOOLCHAIN_SUFFIX "")
  46. set(_ANDROID_TOOL_CXX_COMPILER "")
  47. set(_ANDROID_TOOL_CXX_TOOLCHAIN_VERSION "")
  48. set(_ANDROID_TOOL_CXX_COMPILER_EXTERNAL_TOOLCHAIN "")
  49. set(_ANDROID_TOOL_CXX_TOOLCHAIN_PREFIX "")
  50. set(_ANDROID_TOOL_CXX_TOOLCHAIN_SUFFIX "")
  51. endif()
  52. unset(_ANDROID_HOST_EXT)
  53. macro(__android_determine_compiler lang)
  54. if(_ANDROID_TOOL_${lang}_COMPILER)
  55. set(CMAKE_${lang}_COMPILER "${_ANDROID_TOOL_${lang}_COMPILER}")
  56. set(CMAKE_${lang}_COMPILER_EXTERNAL_TOOLCHAIN "${_ANDROID_TOOL_${lang}_COMPILER_EXTERNAL_TOOLCHAIN}")
  57. # Save the Android-specific information in CMake${lang}Compiler.cmake.
  58. set(CMAKE_${lang}_COMPILER_CUSTOM_CODE "
  59. set(CMAKE_${lang}_ANDROID_TOOLCHAIN_VERSION \"${_ANDROID_TOOL_${lang}_TOOLCHAIN_VERSION}\")
  60. set(CMAKE_${lang}_COMPILER_EXTERNAL_TOOLCHAIN \"${_ANDROID_TOOL_${lang}_COMPILER_EXTERNAL_TOOLCHAIN}\")
  61. set(CMAKE_${lang}_ANDROID_TOOLCHAIN_PREFIX \"${_ANDROID_TOOL_${lang}_TOOLCHAIN_PREFIX}\")
  62. set(CMAKE_${lang}_ANDROID_TOOLCHAIN_SUFFIX \"${_ANDROID_TOOL_${lang}_TOOLCHAIN_SUFFIX}\")
  63. ")
  64. endif()
  65. endmacro()