Skip to content

Commit

Permalink
Update arm-gcc-toolchain.cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
vpetrigo authored Jul 21, 2023
1 parent d4004d5 commit 040fb9b
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions arm-gcc-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,26 +1,8 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR ARM)

if (MINGW OR CYGWIN OR WIN32)
set(UTIL_SEARCH_CMD where)
elseif (UNIX OR APPLE)
set(UTIL_SEARCH_CMD which)
endif ()

set(TOOLCHAIN_PREFIX arm-none-eabi-)

execute_process(
COMMAND ${UTIL_SEARCH_CMD} ${TOOLCHAIN_PREFIX}gcc
OUTPUT_VARIABLE BINUTILS_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if (MINGW OR CYGWIN OR WIN32)
if (BINUTILS_PATH)
string(REPLACE "\n" ";" BINUTILS_PATH "${BINUTILS_PATH}")
list(GET BINUTILS_PATH 0 BINUTILS_PATH)
endif ()
endif ()
find_program(BINUTILS_PATH ${TOOLCHAIN_PREFIX}gcc NO_CACHE)

if (NOT BINUTILS_PATH)
message(FATAL_ERROR "ARM GCC toolchain not found")
Expand All @@ -40,6 +22,9 @@ set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
set(CMAKE_AR ${TOOLCHAIN_PREFIX}gcc-ar)
set(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}gcc-ranlib)

execute_process(COMMAND ${CMAKE_C_COMPILER} -print-sysroot
OUTPUT_VARIABLE ARM_GCC_SYSROOT OUTPUT_STRIP_TRAILING_WHITESPACE)

# Default C compiler flags
set(CMAKE_C_FLAGS_DEBUG_INIT "-g3 -Og -Wall -pedantic -DDEBUG")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG_INIT}" CACHE STRING "" FORCE)
Expand All @@ -62,7 +47,7 @@ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT}" CACH
set(CMAKE_OBJCOPY ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objcopy CACHE INTERNAL "objcopy tool")
set(CMAKE_SIZE_UTIL ${ARM_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}size CACHE INTERNAL "size tool")

set(CMAKE_SYSROOT ${ARM_TOOLCHAIN_DIR}/../arm-none-eabi)
set(CMAKE_SYSROOT ${ARM_GCC_SYSROOT})
set(CMAKE_FIND_ROOT_PATH ${BINUTILS_PATH})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
Expand Down

0 comments on commit 040fb9b

Please sign in to comment.