Skip to content

Commit

Permalink
move stm32 compiler and linker basic info to a dedicated toolchain file
Browse files Browse the repository at this point in the history
  • Loading branch information
PonomarevDA committed Jun 24, 2024
1 parent 702be67 commit cad5f4a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
12 changes: 1 addition & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ endif()

# Pathes
set(ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})
set(SRC_DIR ${ROOT_DIR}/Src)
set(CMAKE_DIR ${ROOT_DIR}/cmake)
set(LIBPARAMS_PATH ${ROOT_DIR}/Libs/libparams)
set(BUILD_SRC_DIR ${ROOT_DIR}/build/src)
Expand Down Expand Up @@ -61,17 +62,6 @@ add_definitions(-DHW_VERSION_MINOR=1)

set(CMAKE_CXX_STANDARD 20)

if(USE_PLATFORM_UBUNTU)
else()
set(TOOLCHAIN_PREFIX arm-none-eabi-)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)
set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy)
set(CMAKE_SIZE ${TOOLCHAIN_PREFIX}size)
endif()


include(${ROOT_DIR}/Src/platform/${APP_PLATFORM}/CMakeLists.txt)
set(EXECUTABLE ${PROJECT_NAME}.out)
add_executable(${EXECUTABLE}
Expand Down
4 changes: 4 additions & 0 deletions Src/platform/stm32f103/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Copyright (C) 2023-2024 Dmitry Ponomarev <[email protected]>
# Distributed under the terms of the GPL v3 license, available in the file LICENSE.

# Include the toolchain file
include(${CMAKE_CURRENT_LIST_DIR}/cmake/Toolchain-arm-none-eabi.cmake)

# Collect source files
FILE(GLOB coreSources ${stm32cubeMxProjectPath}/Core/Src/*)
FILE(GLOB driversSources ${stm32cubeMxProjectPath}/Drivers/*/*/*.c)
FILE(GLOB startupFile ${stm32cubeMxProjectPath}/*.s
Expand Down
16 changes: 16 additions & 0 deletions Src/platform/stm32f103/cmake/Toolchain-arm-none-eabi.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (C) 2023-2024 Dmitry Ponomarev <[email protected]>
# Distributed under the terms of the GPL v3 license, available in the file LICENSE.

# Define the system name and processor
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)

# Define the compiler to be used
set(TOOLCHAIN_PREFIX arm-none-eabi-)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++)

# Define the linker and other tools
set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy)
set(CMAKE_SIZE ${TOOLCHAIN_PREFIX}size)

0 comments on commit cad5f4a

Please sign in to comment.