CMakeForceCompiler.cmake 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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(CMAKE_SIZEOF_VOID_P ${sizeof_void} CACHE STRING "sizeof void")
  38. SET(HAVE_CMAKE_SIZEOF_VOID_P TRUE CACHE INTERNAL "have sizeof void")
  39. ENDMACRO(CMAKE_FORCE_C_COMPILER)
  40. MACRO(CMAKE_FORCE_CXX_COMPILER compiler id)
  41. SET(CMAKE_CXX_COMPILER "${compiler}")
  42. SET(CMAKE_CXX_COMPILER_ID_RUN TRUE)
  43. SET(CMAKE_CXX_COMPILER_ID ${id})
  44. SET(CMAKE_CXX_COMPILER_WORKS TRUE)
  45. ENDMACRO(CMAKE_FORCE_CXX_COMPILER)