target.cmake 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # find the compilers for C, CPP, assembly
  2. find_program(CMAKE_C_COMPILER ${CROSS_COMPILE}ccac PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
  3. find_program(CMAKE_CXX_COMPILER ${CROSS_COMPILE}ccac PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
  4. find_program(CMAKE_ASM_COMPILER ${CROSS_COMPILE}ccac PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
  5. # The CMAKE_REQUIRED_FLAGS variable is used by check_c_compiler_flag()
  6. # (and other commands which end up calling check_c_source_compiles())
  7. # to add additional compiler flags used during checking. These flags
  8. # are unused during "real" builds of Zephyr source files linked into
  9. # the final executable.
  10. #
  11. # Appending onto any existing values lets users specify
  12. # toolchain-specific flags at generation time.
  13. list(APPEND CMAKE_REQUIRED_FLAGS
  14. -c
  15. -HL
  16. -Hnosdata
  17. -Hnolib
  18. -Hnocrt
  19. -Hnoentry
  20. -Hldopt=-Bbase=0x0 # Set an entry point to avoid a warning
  21. -Werror
  22. )
  23. string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
  24. set(NOSTDINC "")
  25. list(APPEND NOSTDINC ${TOOLCHAIN_HOME}/arc/inc)
  26. if(CONFIG_ARCMWDT_LIBC AND CONFIG_LIB_CPLUSPLUS)
  27. list(APPEND NOSTDINC ${TOOLCHAIN_HOME}/arc/lib/src/c++/inc)
  28. endif()
  29. # For CMake to be able to test if a compiler flag is supported by the
  30. # toolchain we need to give CMake the necessary flags to compile and
  31. # link a dummy C file.
  32. #
  33. # CMake checks compiler flags with check_c_compiler_flag() (Which we
  34. # wrap with target_cc_option() in extentions.cmake)
  35. foreach(isystem_include_dir ${NOSTDINC})
  36. list(APPEND isystem_include_flags -isystem "\"${isystem_include_dir}\"")
  37. endforeach()
  38. # common compile options, no copyright msg, little-endian, no small data,
  39. # no MWDT stack checking
  40. list(APPEND TOOLCHAIN_C_FLAGS -Hnocopyr -HL -Hnosdata -Hoff=Stackcheck_alloca)
  41. # The MWDT compiler can replace some code with call to builtin functions.
  42. # We can't rely on these functions presence if we don't use MWDT libc.
  43. # NOTE: the option name '-fno-builtin' is misleading a bit - we still can
  44. # manually call __builtin_** functions even if we specify it.
  45. if(NOT CONFIG_ARCMWDT_LIBC)
  46. list(APPEND TOOLCHAIN_C_FLAGS -fno-builtin)
  47. endif()