CMakeForceCompiler.cmake 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #.rst:
  4. # CMakeForceCompiler
  5. # ------------------
  6. #
  7. # Deprecated. Do not use.
  8. #
  9. # The macros provided by this module were once intended for use by
  10. # cross-compiling toolchain files when CMake was not able to automatically
  11. # detect the compiler identification. Since the introduction of this module,
  12. # CMake's compiler identification capabilities have improved and can now be
  13. # taught to recognize any compiler. Furthermore, the suite of information
  14. # CMake detects from a compiler is now too extensive to be provided by
  15. # toolchain files using these macros.
  16. #
  17. # One common use case for this module was to skip CMake's checks for a
  18. # working compiler when using a cross-compiler that cannot link binaries
  19. # without special flags or custom linker scripts. This case is now supported
  20. # by setting the :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` variable in the
  21. # toolchain file instead.
  22. #
  23. # -------------------------------------------------------------------------
  24. #
  25. # Macro CMAKE_FORCE_C_COMPILER has the following signature:
  26. #
  27. # ::
  28. #
  29. # CMAKE_FORCE_C_COMPILER(<compiler> <compiler-id>)
  30. #
  31. # It sets CMAKE_C_COMPILER to the given compiler and the cmake internal
  32. # variable CMAKE_C_COMPILER_ID to the given compiler-id. It also
  33. # bypasses the check for working compiler and basic compiler information
  34. # tests.
  35. #
  36. # Macro CMAKE_FORCE_CXX_COMPILER has the following signature:
  37. #
  38. # ::
  39. #
  40. # CMAKE_FORCE_CXX_COMPILER(<compiler> <compiler-id>)
  41. #
  42. # It sets CMAKE_CXX_COMPILER to the given compiler and the cmake
  43. # internal variable CMAKE_CXX_COMPILER_ID to the given compiler-id. It
  44. # also bypasses the check for working compiler and basic compiler
  45. # information tests.
  46. #
  47. # Macro CMAKE_FORCE_Fortran_COMPILER has the following signature:
  48. #
  49. # ::
  50. #
  51. # CMAKE_FORCE_Fortran_COMPILER(<compiler> <compiler-id>)
  52. #
  53. # It sets CMAKE_Fortran_COMPILER to the given compiler and the cmake
  54. # internal variable CMAKE_Fortran_COMPILER_ID to the given compiler-id.
  55. # It also bypasses the check for working compiler and basic compiler
  56. # information tests.
  57. #
  58. # So a simple toolchain file could look like this:
  59. #
  60. # ::
  61. #
  62. # include (CMakeForceCompiler)
  63. # set(CMAKE_SYSTEM_NAME Generic)
  64. # CMAKE_FORCE_C_COMPILER (chc12 MetrowerksHicross)
  65. # CMAKE_FORCE_CXX_COMPILER (chc12 MetrowerksHicross)
  66. macro(CMAKE_FORCE_C_COMPILER compiler id)
  67. message(DEPRECATION "The CMAKE_FORCE_C_COMPILER macro is deprecated. "
  68. "Instead just set CMAKE_C_COMPILER and allow CMake to identify the compiler.")
  69. set(CMAKE_C_COMPILER "${compiler}")
  70. set(CMAKE_C_COMPILER_ID_RUN TRUE)
  71. set(CMAKE_C_COMPILER_ID ${id})
  72. set(CMAKE_C_COMPILER_FORCED TRUE)
  73. # Set old compiler id variables.
  74. if(CMAKE_C_COMPILER_ID MATCHES "GNU")
  75. set(CMAKE_COMPILER_IS_GNUCC 1)
  76. endif()
  77. endmacro()
  78. macro(CMAKE_FORCE_CXX_COMPILER compiler id)
  79. message(DEPRECATION "The CMAKE_FORCE_CXX_COMPILER macro is deprecated. "
  80. "Instead just set CMAKE_CXX_COMPILER and allow CMake to identify the compiler.")
  81. set(CMAKE_CXX_COMPILER "${compiler}")
  82. set(CMAKE_CXX_COMPILER_ID_RUN TRUE)
  83. set(CMAKE_CXX_COMPILER_ID ${id})
  84. set(CMAKE_CXX_COMPILER_FORCED TRUE)
  85. # Set old compiler id variables.
  86. if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
  87. set(CMAKE_COMPILER_IS_GNUCXX 1)
  88. endif()
  89. endmacro()
  90. macro(CMAKE_FORCE_Fortran_COMPILER compiler id)
  91. message(DEPRECATION "The CMAKE_FORCE_Fortran_COMPILER macro is deprecated. "
  92. "Instead just set CMAKE_Fortran_COMPILER and allow CMake to identify the compiler.")
  93. set(CMAKE_Fortran_COMPILER "${compiler}")
  94. set(CMAKE_Fortran_COMPILER_ID_RUN TRUE)
  95. set(CMAKE_Fortran_COMPILER_ID ${id})
  96. set(CMAKE_Fortran_COMPILER_FORCED TRUE)
  97. # Set old compiler id variables.
  98. if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
  99. set(CMAKE_COMPILER_IS_GNUG77 1)
  100. endif()
  101. endmacro()