CMakeForceCompiler.cmake 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # This module defines macros intended for use by cross-compiling
  2. # toolchain files when CMake is not able to automatically detect the
  3. # compiler identification.
  4. #
  5. # Macro CMAKE_FORCE_C_COMPILER has the following signature:
  6. # CMAKE_FORCE_C_COMPILER(<compiler> <compiler-id>)
  7. # It sets CMAKE_C_COMPILER to the given compiler and the cmake
  8. # internal variable CMAKE_C_COMPILER_ID to the given compiler-id.
  9. # It also bypasses the check for working compiler and basic compiler
  10. # information tests.
  11. #
  12. # Macro CMAKE_FORCE_CXX_COMPILER has the following signature:
  13. # CMAKE_FORCE_CXX_COMPILER(<compiler> <compiler-id>)
  14. # It sets CMAKE_CXX_COMPILER to the given compiler and the cmake
  15. # internal variable CMAKE_CXX_COMPILER_ID to the given compiler-id.
  16. # It also bypasses the check for working compiler and basic compiler
  17. # information tests.
  18. #
  19. # Macro CMAKE_FORCE_Fortran_COMPILER has the following signature:
  20. # CMAKE_FORCE_Fortran_COMPILER(<compiler> <compiler-id>)
  21. # It sets CMAKE_Fortran_COMPILER to the given compiler and the cmake
  22. # internal variable CMAKE_Fortran_COMPILER_ID to the given compiler-id.
  23. # It also bypasses the check for working compiler and basic compiler
  24. # information tests.
  25. #
  26. # So a simple toolchain file could look like this:
  27. # include (CMakeForceCompiler)
  28. # set(CMAKE_SYSTEM_NAME Generic)
  29. # CMAKE_FORCE_C_COMPILER (chc12 MetrowerksHicross)
  30. # CMAKE_FORCE_CXX_COMPILER (chc12 MetrowerksHicross)
  31. #=============================================================================
  32. # Copyright 2007-2009 Kitware, Inc.
  33. #
  34. # Distributed under the OSI-approved BSD License (the "License");
  35. # see accompanying file Copyright.txt for details.
  36. #
  37. # This software is distributed WITHOUT ANY WARRANTY; without even the
  38. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  39. # See the License for more information.
  40. #=============================================================================
  41. # (To distribute this file outside of CMake, substitute the full
  42. # License text for the above reference.)
  43. macro(CMAKE_FORCE_C_COMPILER compiler id)
  44. set(CMAKE_C_COMPILER "${compiler}")
  45. set(CMAKE_C_COMPILER_ID_RUN TRUE)
  46. set(CMAKE_C_COMPILER_ID ${id})
  47. set(CMAKE_C_COMPILER_WORKS TRUE)
  48. set(CMAKE_C_COMPILER_FORCED TRUE)
  49. # Set old compiler id variables.
  50. if("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
  51. set(CMAKE_COMPILER_IS_GNUCC 1)
  52. endif()
  53. endmacro()
  54. macro(CMAKE_FORCE_CXX_COMPILER compiler id)
  55. set(CMAKE_CXX_COMPILER "${compiler}")
  56. set(CMAKE_CXX_COMPILER_ID_RUN TRUE)
  57. set(CMAKE_CXX_COMPILER_ID ${id})
  58. set(CMAKE_CXX_COMPILER_WORKS TRUE)
  59. set(CMAKE_CXX_COMPILER_FORCED TRUE)
  60. # Set old compiler id variables.
  61. if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
  62. set(CMAKE_COMPILER_IS_GNUCXX 1)
  63. endif()
  64. endmacro()
  65. macro(CMAKE_FORCE_Fortran_COMPILER compiler id)
  66. set(CMAKE_Fortran_COMPILER "${compiler}")
  67. set(CMAKE_Fortran_COMPILER_ID_RUN TRUE)
  68. set(CMAKE_Fortran_COMPILER_ID ${id})
  69. set(CMAKE_Fortran_COMPILER_WORKS TRUE)
  70. set(CMAKE_Fortran_COMPILER_FORCED TRUE)
  71. # Set old compiler id variables.
  72. if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
  73. set(CMAKE_COMPILER_IS_GNUG77 1)
  74. endif()
  75. endmacro()