gcc-arm-none-eabi.cmake 1.3 KB

12345678910111213141516171819202122232425262728
  1. set(CMAKE_SYSTEM_NAME Generic)
  2. set(CMAKE_SYSTEM_PROCESSOR arm)
  3. # Some default GCC settings
  4. # arm-none-eabi- must be part of path environment
  5. set(TOOLCHAIN_PREFIX arm-none-eabi-)
  6. set(C_FLAGS "-Wall -Wextra -Wpedantic -fdata-sections -ffunction-sections --specs=nano.specs -Wl,--gc-sections")
  7. set(ASM_FLAGS "-x assembler-with-cpp -MMD -MP")
  8. set(CPP_FLAGS "-fno-rtti -fno-exceptions -fno-threadsafe-statics")
  9. set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc ${C_FLAGS})
  10. set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
  11. set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++ ${C_FLAGS} ${CPP_FLAGS})
  12. set(CMAKE_LINKER ${TOOLCHAIN_PREFIX}g++)
  13. set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy)
  14. set(CMAKE_SIZE ${TOOLCHAIN_PREFIX}size)
  15. set(CMAKE_EXECUTABLE_SUFFIX_ASM ".elf")
  16. set(CMAKE_EXECUTABLE_SUFFIX_C ".elf")
  17. set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf")
  18. set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
  19. if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
  20. execute_process(
  21. COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/compile_commands.json ${CMAKE_SOURCE_DIR}/compile_commands.json
  22. )
  23. endif()