CMakeForceCompiler.cmake 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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_FORCED TRUE)
  48. # Set old compiler id variables.
  49. if("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
  50. set(CMAKE_COMPILER_IS_GNUCC 1)
  51. endif()
  52. endmacro()
  53. macro(CMAKE_FORCE_CXX_COMPILER compiler id)
  54. set(CMAKE_CXX_COMPILER "${compiler}")
  55. set(CMAKE_CXX_COMPILER_ID_RUN TRUE)
  56. set(CMAKE_CXX_COMPILER_ID ${id})
  57. set(CMAKE_CXX_COMPILER_FORCED TRUE)
  58. # Set old compiler id variables.
  59. if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
  60. set(CMAKE_COMPILER_IS_GNUCXX 1)
  61. endif()
  62. endmacro()
  63. macro(CMAKE_FORCE_Fortran_COMPILER compiler id)
  64. set(CMAKE_Fortran_COMPILER "${compiler}")
  65. set(CMAKE_Fortran_COMPILER_ID_RUN TRUE)
  66. set(CMAKE_Fortran_COMPILER_ID ${id})
  67. set(CMAKE_Fortran_COMPILER_FORCED TRUE)
  68. # Set old compiler id variables.
  69. if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
  70. set(CMAKE_COMPILER_IS_GNUG77 1)
  71. endif()
  72. endmacro()