CMakeForceCompiler.cmake 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. MACRO(CMAKE_FORCE_C_COMPILER compiler id)
  25. SET(CMAKE_C_COMPILER "${compiler}")
  26. SET(CMAKE_C_COMPILER_ID_RUN TRUE)
  27. SET(CMAKE_C_COMPILER_ID ${id})
  28. SET(CMAKE_C_COMPILER_WORKS TRUE)
  29. SET(CMAKE_C_COMPILER_FORCED TRUE)
  30. # Set old compiler id variables.
  31. IF("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
  32. SET(CMAKE_COMPILER_IS_GNUCC 1)
  33. ENDIF("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
  34. ENDMACRO(CMAKE_FORCE_C_COMPILER)
  35. MACRO(CMAKE_FORCE_CXX_COMPILER compiler id)
  36. SET(CMAKE_CXX_COMPILER "${compiler}")
  37. SET(CMAKE_CXX_COMPILER_ID_RUN TRUE)
  38. SET(CMAKE_CXX_COMPILER_ID ${id})
  39. SET(CMAKE_CXX_COMPILER_WORKS TRUE)
  40. SET(CMAKE_CXX_COMPILER_FORCED TRUE)
  41. # Set old compiler id variables.
  42. IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
  43. SET(CMAKE_COMPILER_IS_GNUCXX 1)
  44. ENDIF("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
  45. ENDMACRO(CMAKE_FORCE_CXX_COMPILER)