Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ venv/
ENV/
env.bak/
venv.bak/
example/arm-none-eabi/.vs
7 changes: 7 additions & 0 deletions conan_provider.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,13 @@ function(detect_host_profile output_file)
string(APPEND profile "[conf]\n")
string(APPEND profile "tools.cmake.cmaketoolchain:generator=${CMAKE_GENERATOR}\n")

# if a custom cmake toolchain was specified use it
if(CMAKE_TOOLCHAIN_FILE)
# pass cmake toolchain file to conan
string(APPEND profile "tools.cmake.cmaketoolchain:toolchain_file=${CMAKE_TOOLCHAIN_FILE}\n")
endif()


# propagate compilers via profile
append_compiler_executables_configuration()

Expand Down
61 changes: 61 additions & 0 deletions example/arm-none-eabi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

cmake_minimum_required (VERSION 3.30)



project ("arm-none-eabi")

set(EXE_NAME arm_none_eabi_test)

set(CMAKE_EXECUTABLE_SUFFIX ".elf")
set(EXE_SOURCES "main.c" "syscall_wrapper.h" "syscall_wrapper.c" "fmt_dummy.h" "fmt_dummy.cpp")

list(APPEND EXE_SOURCES "startup_stm32f429xx.s")
# Cmake does not seam to recognise *.s files as ASM. Tell Cmake the language
set_source_files_properties("target/startup_stm32f429xx.s"
PROPERTIES LANGUAGE ASM)

find_program(CMAKE_SIZE arm-none-eabi-size)
if(NOT CMAKE_SIZE)
message(FATAL_ERROR "Could not find 'arm-none-eabi-size'. Please install it or set CMAKE_SIZE manually.")
endif()

set(LINKER_SCRIPT_PATH "${CMAKE_CURRENT_LIST_DIR}/STM32F429XX_FLASH.ld")

# Check file existance
if(NOT EXISTS ${LINKER_SCRIPT_PATH})
message(FATAL_ERROR "Linker Script does not exist. Path = ${LINKER_SCRIPT_PATH}")
endif()

add_link_options(-T${LINKER_SCRIPT_PATH} -Wl,--gc-sections -Wl,-Map=${PROJECT_NAME}.map)



find_package(fmt REQUIRED)

add_executable(${EXE_NAME} ${EXE_SOURCES})

# create an alias target if fmt is used in header only mode
if(NOT TARGET fmt::fmt AND TARGET fmt::fmt-header-only)
add_library(fmt::fmt ALIAS fmt::fmt-header-only)
endif()

target_link_libraries(${EXE_NAME} PUBLIC fmt::fmt)

set(WRAPPED_SYMBOLS malloc free realloc calloc)

set(WRAP_OPTIONS "")
foreach(SYM IN LISTS WRAPPED_SYMBOLS)
list(APPEND WRAP_OPTIONS "-Wl,--wrap=${SYM}")
endforeach()

set(LINKER_STATS_OPTIONS "-Wl,--print-memory-usage")

target_link_options(${EXE_NAME} PUBLIC ${WRAP_OPTIONS}
${LINKER_STATS_OPTIONS})

add_custom_command(
TARGET ${EXE_NAME}
POST_BUILD
COMMAND ${CMAKE_SIZE} $<TARGET_FILE:${EXE_NAME}>
COMMENT "Memory usage summary")
85 changes: 85 additions & 0 deletions example/arm-none-eabi/CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"version": 3,
"configurePresets": [
{
"name": "_conan",
"hidden": true,
"cacheVariables": {
"CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "${sourceDir}/../../conan_provider.cmake"
}
},
{
"name": "_dir",
"hidden": true,
"binaryDir": "${sourceDir}/out/${presetName}/build",
"installDir": "${sourceDir}/out/${presetName}/install",
"cacheVariables": {
"REPORTS_DIR": "${sourceDir}/out/${presetName}/reports"
}
},
{
"name": "_arm_none_eabi",
"inherits": [ "_conan", "_dir" ],
"hidden": true,
"generator": "Ninja Multi-Config",
"toolchainFile": "${sourceDir}/gcc-arm-none-eabi.cmake",
"cacheVariables": {
"BUILD_TARGET": true,
"COMPILER_ARCH_FLAGS": "-mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard"
}
},
{
"name": "arm_none_eabi_gcc_14_win",
"description": "Windows Cross Compiler",
"inherits": [ "_arm_none_eabi" ],
"cacheVariables": {
"TOOLCHAIN_URL": "https://developer.arm.com/-/media/Files/downloads/gnu/14.3.rel1/binrel/arm-gnu-toolchain-14.3.rel1-mingw-w64-i686-arm-none-eabi.zip"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "arm_none_eabi_gcc_14_linux",
"description": "Linux Cross Compiler",
"hidden": true,
"inherits": [ "_arm_none_eabi" ],
"cacheVariables": {
"TOOLCHAIN_URL": "https://developer.arm.com/-/media/Files/downloads/gnu/14.3.rel1/binrel/arm-gnu-toolchain-14.3.rel1-x86_64-arm-none-eabi.tar.xz"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
}
],
"buildPresets": [
{
"name": "arm_none_eabi_gcc_14_win_dbg",
"configurePreset": "arm_none_eabi_gcc_14_win",
"displayName": "Debug",
"configuration": "Debug"
},
{
"name": "arm_none_eabi_gcc_14_win_rel",
"configurePreset": "arm_none_eabi_gcc_14_win",
"displayName": "Release",
"configuration": "Release"
},
{
"name": "arm_none_eabi_gcc_14_linux_dbg",
"configurePreset": "arm_none_eabi_gcc_14_linux",
"displayName": "Debug",
"configuration": "Debug"
},
{
"name": "arm_none_eabi_gcc_14_linux_rel",
"configurePreset": "arm_none_eabi_gcc_14_linux",
"displayName": "Release",
"configuration": "Release"
}
]
}
Loading