CMakeForceCompiler.cmake 3.3 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("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
  53. ENDMACRO(CMAKE_FORCE_C_COMPILER)
  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("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
  64. ENDMACRO(CMAKE_FORCE_CXX_COMPILER)
  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("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
  75. ENDMACRO(CMAKE_FORCE_Fortran_COMPILER)