CMakeForceCompiler.cmake 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. # So a simple toolchain file could look like this:
  20. # INCLUDE (CMakeForceCompiler)
  21. # SET(CMAKE_SYSTEM_NAME Generic)
  22. # CMAKE_FORCE_C_COMPILER (chc12 MetrowerksHicross)
  23. # CMAKE_FORCE_CXX_COMPILER (chc12 MetrowerksHicross)
  24. #=============================================================================
  25. # Copyright 2007-2009 Kitware, Inc.
  26. #
  27. # Distributed under the OSI-approved BSD License (the "License");
  28. # see accompanying file Copyright.txt for details.
  29. #
  30. # This software is distributed WITHOUT ANY WARRANTY; without even the
  31. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  32. # See the License for more information.
  33. #=============================================================================
  34. # (To distributed this file outside of CMake, substitute the full
  35. # License text for the above reference.)
  36. MACRO(CMAKE_FORCE_C_COMPILER compiler id)
  37. SET(CMAKE_C_COMPILER "${compiler}")
  38. SET(CMAKE_C_COMPILER_ID_RUN TRUE)
  39. SET(CMAKE_C_COMPILER_ID ${id})
  40. SET(CMAKE_C_COMPILER_WORKS TRUE)
  41. SET(CMAKE_C_COMPILER_FORCED TRUE)
  42. # Set old compiler id variables.
  43. IF("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
  44. SET(CMAKE_COMPILER_IS_GNUCC 1)
  45. ENDIF("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
  46. ENDMACRO(CMAKE_FORCE_C_COMPILER)
  47. MACRO(CMAKE_FORCE_CXX_COMPILER compiler id)
  48. SET(CMAKE_CXX_COMPILER "${compiler}")
  49. SET(CMAKE_CXX_COMPILER_ID_RUN TRUE)
  50. SET(CMAKE_CXX_COMPILER_ID ${id})
  51. SET(CMAKE_CXX_COMPILER_WORKS TRUE)
  52. SET(CMAKE_CXX_COMPILER_FORCED TRUE)
  53. # Set old compiler id variables.
  54. IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
  55. SET(CMAKE_COMPILER_IS_GNUCXX 1)
  56. ENDIF("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
  57. ENDMACRO(CMAKE_FORCE_CXX_COMPILER)