CMakeForceCompiler.cmake 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # These are macros intended to be used only when crosscompiling in the
  2. # toolchain-file and only if the compiler is not able to link an
  3. # executable by default (usually because they need user-specific
  4. # linker files which describe the layout of the target memory).
  5. #
  6. # It offers the following macros:
  7. #
  8. # macro CMAKE_FORCE_SYSTEM(name version processor)
  9. # Set CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_VERSION and CMAKE_SYSTEM_PROCESSOR
  10. #
  11. # macro CMAKE_FORCE_C_COMPILER(compiler compiler_id sizeof_void)
  12. # Set CMAKE_C_COMPILER to the given compiler and set CMAKE_C_COMPILER_ID
  13. # to the given compiler_id. This Id is used by cmake to construct the filename
  14. # of the system-compiler.cmake file. For C also the size of a void-pointer
  15. # has to be predefined.
  16. #
  17. # macro CMAKE_FORCE_CXX_COMPILER(compiler compiler_id)
  18. # The same as CMAKE_FORCE_C_COMPILER, but for CXX. Here the size of
  19. # the void pointer is not requried.
  20. #
  21. # So a simple toolchain file could look like this:
  22. #
  23. # INCLUDE (CMakeForceCompiler)
  24. # CMAKE_FORCE_SYSTEM ("Generic" "0.0" "hc12")
  25. # CMAKE_FORCE_C_COMPILER (chc12 FreescaleCHC12 2)
  26. # CMAKE_FORCE_CXX_COMPILER (chc12 FreescaleCHC12)
  27. MACRO(CMAKE_FORCE_SYSTEM name version proc)
  28. SET(CMAKE_SYSTEM_NAME "${name}")
  29. SET(CMAKE_SYSTEM_VERSION "${version}")
  30. SET(CMAKE_SYSTEM_PROCESSOR "${proc}")
  31. ENDMACRO(CMAKE_FORCE_SYSTEM)
  32. MACRO(CMAKE_FORCE_C_COMPILER compiler id sizeof_void)
  33. SET(CMAKE_C_COMPILER "${compiler}")
  34. SET(CMAKE_C_COMPILER_ID_RUN TRUE)
  35. SET(CMAKE_C_COMPILER_ID ${id})
  36. SET(CMAKE_C_COMPILER_WORKS TRUE)
  37. # Set old compiler and platform id variables.
  38. IF("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
  39. SET(CMAKE_COMPILER_IS_GNUCC 1)
  40. ENDIF("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
  41. SET(CMAKE_SIZEOF_VOID_P ${sizeof_void} CACHE STRING "sizeof void")
  42. SET(HAVE_CMAKE_SIZEOF_VOID_P TRUE CACHE INTERNAL "have sizeof void")
  43. ENDMACRO(CMAKE_FORCE_C_COMPILER)
  44. MACRO(CMAKE_FORCE_CXX_COMPILER compiler id)
  45. SET(CMAKE_CXX_COMPILER "${compiler}")
  46. SET(CMAKE_CXX_COMPILER_ID_RUN TRUE)
  47. SET(CMAKE_CXX_COMPILER_ID ${id})
  48. SET(CMAKE_CXX_COMPILER_WORKS TRUE)
  49. IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
  50. SET(CMAKE_COMPILER_IS_GNUCXX 1)
  51. ENDIF("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
  52. ENDMACRO(CMAKE_FORCE_CXX_COMPILER)