*
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Sergey Serb
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+1
@@ -0,0 +1 @@
|
||||
# LFramework.CMake
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
find_program(nuget "nuget" REQUIRED)
|
||||
|
||||
|
||||
function(nugetRestore)
|
||||
execute_process(
|
||||
COMMAND "${nuget}" "restore" "-PackagesDirectory" "${CMAKE_SOURCE_DIR}/packages"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
)
|
||||
#nuget restore -PackagesDirectory ./packages
|
||||
endfunction()
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
|
||||
|
||||
|
||||
set(MCU_ARCH cortex-m7)
|
||||
set(MCU_FLOAT_ABI softfp)
|
||||
set(MCU_FPU fpv4-sp-d16)
|
||||
|
||||
|
||||
set(COMMON_COMPILE_FLAGS -mcpu=${MCU_ARCH} -mthumb -mfloat-abi=${MCU_FLOAT_ABI} -mfpu=${MCU_FPU})
|
||||
set(C_CXX_COMPILE_FLAGS -ffunction-sections -fdata-sections -fsigned-char -g -fmessage-length=0)
|
||||
|
||||
if(NOT (TARGET STM32::F7))
|
||||
add_library(STM32::F7 INTERFACE IMPORTED)
|
||||
|
||||
target_compile_options(STM32::F7 INTERFACE
|
||||
--sysroot="${TOOLCHAIN_SYSROOT}"
|
||||
${COMMON_COMPILE_FLAGS}
|
||||
)
|
||||
|
||||
#target_compile_options(STM32::F7 INTERFACE $<$<COMPILE_LANGUAGE:ASM>:-x assembler-with-cpp>)
|
||||
target_compile_options(STM32::F7 INTERFACE $<$<COMPILE_LANGUAGE:C>:${C_CXX_COMPILE_FLAGS}>)
|
||||
target_compile_options(STM32::F7 INTERFACE $<$<COMPILE_LANGUAGE:CXX>:${C_CXX_COMPILE_FLAGS}>)
|
||||
target_compile_options(STM32::F7 INTERFACE $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions -fno-rtti -fno-use-cxa-atexit -fno-threadsafe-statics>)
|
||||
|
||||
target_link_options(STM32::F7 INTERFACE
|
||||
--sysroot="${TOOLCHAIN_SYSROOT}"
|
||||
${COMMON_COMPILE_FLAGS}
|
||||
${C_CXX_COMPILE_FLAGS}
|
||||
LINKER:-gc-sections
|
||||
)
|
||||
|
||||
|
||||
target_link_options(STM32::F7 INTERFACE $<$<CONFIG:RELEASE>:LINKER:--undefined=vTaskSwitchContext,--undefined=HardFault_HandlerC,-undefined=_realloc_r>)
|
||||
|
||||
target_compile_definitions(STM32::F7 INTERFACE
|
||||
STM32F7
|
||||
"__weak=__attribute__((weak))"
|
||||
"__packed=__attribute__((__packed__))"
|
||||
)
|
||||
endif()
|
||||
@@ -0,0 +1,25 @@
|
||||
add_library(Stm32CmsisCore INTERFACE)
|
||||
|
||||
target_include_directories(Stm32CmsisCore
|
||||
INTERFACE
|
||||
${STM32_CMSIS_CORE_SOURCE_DIR}/Core/Include
|
||||
${STM32_CMSIS_CORE_SOURCE_DIR}/RTOS2/Include
|
||||
)
|
||||
|
||||
|
||||
file(GLOB_RECURSE Stm32CmsisCore_HEADERS "${STM32_CMSIS_CORE_SOURCE_DIR}/Core/Include/*.h" "${STM32_CMSIS_CORE_SOURCE_DIR}/RTOS2/Include/*.h")
|
||||
#file(GLOB_RECURSE cmsis_device_f7_SOURCES1 "${cmsis_device_f7_SOURCE_DIR}/Src/**/*.c")
|
||||
|
||||
target_sources(Stm32CmsisCore
|
||||
INTERFACE
|
||||
${Stm32CmsisCore_HEADERS1}
|
||||
)
|
||||
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Stm32CmsisCore
|
||||
REQUIRED_VARS
|
||||
Stm32CmsisCore_HEADERS
|
||||
#Stm32CmsisCore_SOURCES
|
||||
)
|
||||
@@ -0,0 +1,33 @@
|
||||
add_library(Stm32CmsisDevice INTERFACE)
|
||||
|
||||
target_include_directories(Stm32CmsisDevice
|
||||
INTERFACE
|
||||
${STM32_CMSIS_DEVICE_SOURCE_DIR}/Include
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE Stm32CmsisDevice_HEADERS "${STM32_CMSIS_DEVICE_SOURCE_DIR}/Include/*.h")
|
||||
|
||||
set(Stm32CmsisDevice_SOURCES
|
||||
${STM32_CMSIS_DEVICE_SOURCE_DIR}/Source/Templates/system_stm32f7xx.c
|
||||
${STM32_CMSIS_DEVICE_SOURCE_DIR}/Source/Templates/gcc/startup_stm32f746xx.s
|
||||
)
|
||||
|
||||
target_compile_definitions(Stm32CmsisDevice
|
||||
INTERFACE
|
||||
STM32${MCU_FAMILY}${MCU_CORE}${MCU_LINE}xx
|
||||
)
|
||||
|
||||
|
||||
target_sources(Stm32CmsisDevice
|
||||
INTERFACE
|
||||
${Stm32CmsisDevice_HEADERS}
|
||||
${Stm32CmsisDevice_SOURCES}
|
||||
)
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Stm32CmsisDevice
|
||||
REQUIRED_VARS
|
||||
Stm32CmsisDevice_HEADERS
|
||||
Stm32CmsisDevice_SOURCES
|
||||
)
|
||||
@@ -0,0 +1,37 @@
|
||||
add_library(Stm32FreeRtos INTERFACE)
|
||||
|
||||
target_include_directories(Stm32FreeRtos
|
||||
INTERFACE
|
||||
${STM32_FREERTOS_SOURCE_DIR}/Source
|
||||
${STM32_FREERTOS_SOURCE_DIR}/Source/include
|
||||
#${STM32_FREERTOS_SOURCE_DIR}/Source/CMSIS_RTOS_V2
|
||||
${STM32_FREERTOS_SOURCE_DIR}/Source/portable/GCC/ARM_CM7/r0p1
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE Stm32FreeRtos_HEADERS
|
||||
#"${STM32_FREERTOS_SOURCE_DIR}/Source/CMSIS_RTOS_V2/*.h"
|
||||
"${STM32_FREERTOS_SOURCE_DIR}/Source/include/**/*.h"
|
||||
"${STM32_FREERTOS_SOURCE_DIR}/Source/portable/GCC/ARM_CM7/*.h"
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE Stm32FreeRtos_SOURCES
|
||||
#"${STM32_FREERTOS_SOURCE_DIR}/Source/CMSIS_RTOS_V2/*.c"
|
||||
"${STM32_FREERTOS_SOURCE_DIR}/Source/portable/GCC/ARM_CM7/*.c"
|
||||
)
|
||||
|
||||
file(GLOB Stm32FreeRtos_SOURCES2 "${STM32_FREERTOS_SOURCE_DIR}/Source/*.c")
|
||||
list(APPEND Stm32FreeRtos_SOURCES ${Stm32FreeRtos_SOURCES2} ${STM32_FREERTOS_SOURCE_DIR}/Source/portable/MemMang/heap_4.c)
|
||||
|
||||
target_sources(Stm32FreeRtos
|
||||
INTERFACE
|
||||
${Stm32FreeRtos_HEADERS}
|
||||
${Stm32FreeRtos_SOURCES}
|
||||
)
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Stm32FreeRtos
|
||||
REQUIRED_VARS
|
||||
Stm32FreeRtos_HEADERS
|
||||
Stm32FreeRtos_SOURCES
|
||||
)
|
||||
@@ -0,0 +1,25 @@
|
||||
add_library(Stm32Hal INTERFACE)
|
||||
|
||||
target_include_directories(Stm32Hal
|
||||
INTERFACE
|
||||
${STM32_HAL_SOURCE_DIR}/Inc
|
||||
${STM32_HAL_SOURCE_DIR}/Inc/Legacy
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE Stm32Hal_HEADERS "${STM32_HAL_SOURCE_DIR}/Inc/*.h")
|
||||
file(GLOB_RECURSE Stm32Hal_SOURCES "${STM32_HAL_SOURCE_DIR}/Src/*.c")
|
||||
list(FILTER Stm32Hal_SOURCES EXCLUDE REGEX ".*_template.c$")
|
||||
|
||||
target_sources(Stm32Hal
|
||||
INTERFACE
|
||||
${Stm32Hal_HEADERS}
|
||||
${Stm32Hal_SOURCES}
|
||||
)
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Stm32Hal
|
||||
REQUIRED_VARS
|
||||
Stm32Hal_HEADERS
|
||||
Stm32Hal_SOURCES
|
||||
)
|
||||
@@ -0,0 +1,25 @@
|
||||
add_library(Stm32UsbDevice INTERFACE)
|
||||
|
||||
target_include_directories(Stm32UsbDevice
|
||||
INTERFACE
|
||||
${STM32_USB_DEVICE_SOURCE_DIR}/Core/Inc
|
||||
)
|
||||
|
||||
file(GLOB_RECURSE Stm32UsbDevice_HEADERS "${STM32_USB_DEVICE_SOURCE_DIR}/Core/Inc/*.h")
|
||||
file(GLOB_RECURSE Stm32UsbDevice_SOURCES "${STM32_USB_DEVICE_SOURCE_DIR}/Core/Src/*.c")
|
||||
list(FILTER Stm32UsbDevice_SOURCES EXCLUDE REGEX ".*_template.c$")
|
||||
list(FILTER Stm32UsbDevice_HEADERS EXCLUDE REGEX ".*_template.h$")
|
||||
|
||||
target_sources(Stm32UsbDevice
|
||||
INTERFACE
|
||||
${Stm32UsbDevice_HEADERS}
|
||||
${Stm32UsbDevice_SOURCES}
|
||||
)
|
||||
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Stm32UsbDevice
|
||||
REQUIRED_VARS
|
||||
Stm32UsbDevice_HEADERS
|
||||
Stm32UsbDevice_SOURCES
|
||||
)
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
|
||||
set(MCU_ARCH cortex-m7)
|
||||
set(MCU_FLOAT_ABI hard)
|
||||
set(MCU_FPU fpv5-d16)
|
||||
|
||||
|
||||
set(COMMON_COMPILE_FLAGS -mcpu=${MCU_ARCH} -mthumb -mfloat-abi=${MCU_FLOAT_ABI} -mfpu=${MCU_FPU})
|
||||
set(C_CXX_COMPILE_FLAGS -ffunction-sections -fdata-sections -fsigned-char -g -fmessage-length=0)
|
||||
|
||||
if(NOT (TARGET STM32::H7))
|
||||
add_library(STM32::H7 INTERFACE IMPORTED)
|
||||
|
||||
target_compile_options(STM32::H7 INTERFACE
|
||||
--sysroot="${TOOLCHAIN_SYSROOT}"
|
||||
${COMMON_COMPILE_FLAGS}
|
||||
)
|
||||
|
||||
#target_compile_options(STM32::H7 INTERFACE $<$<COMPILE_LANGUAGE:ASM>:-x assembler-with-cpp>)
|
||||
target_compile_options(STM32::H7 INTERFACE $<$<COMPILE_LANGUAGE:C>:${C_CXX_COMPILE_FLAGS}>)
|
||||
target_compile_options(STM32::H7 INTERFACE $<$<COMPILE_LANGUAGE:CXX>:${C_CXX_COMPILE_FLAGS}>)
|
||||
target_compile_options(STM32::H7 INTERFACE $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions -fno-rtti -fno-use-cxa-atexit -fno-threadsafe-statics>)
|
||||
|
||||
target_link_options(STM32::H7 INTERFACE
|
||||
--sysroot="${TOOLCHAIN_SYSROOT}"
|
||||
${COMMON_COMPILE_FLAGS}
|
||||
${C_CXX_COMPILE_FLAGS}
|
||||
LINKER:-gc-sections
|
||||
)
|
||||
|
||||
|
||||
target_link_options(STM32::H7 INTERFACE $<$<CONFIG:RELEASE>:LINKER:--undefined=vTaskSwitchContext,--undefined=HardFault_HandlerC,-undefined=_realloc_r>)
|
||||
|
||||
target_compile_definitions(STM32::H7 INTERFACE
|
||||
STM32H7
|
||||
"__weak=__attribute__((weak))"
|
||||
"__packed=__attribute__((__packed__))"
|
||||
)
|
||||
endif()
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
if (DEFINED STM32_DEVICE AND NOT STM32_DEVICE STREQUAL "")
|
||||
string(REGEX MATCH "STM(32|8)(F|L|H|W|U)([0-9])([^A-Z]+)([A-Z])(.)" STM32_DEVICE_ ${STM32_DEVICE}])
|
||||
set(MCU_FAMILY ${CMAKE_MATCH_2})
|
||||
set(MCU_CORE ${CMAKE_MATCH_3})
|
||||
set(MCU_LINE ${CMAKE_MATCH_4})
|
||||
|
||||
message("MCU_FAMILY: ${MCU_FAMILY}")
|
||||
message("MCU_CORE: ${MCU_CORE}")
|
||||
message("MCU_LINE: ${MCU_LINE}")
|
||||
|
||||
set(STM32_FAMILY_EX "${MCU_FAMILY}${MCU_CORE}" )
|
||||
|
||||
message("STM32_FAMILY_EX: ${STM32_FAMILY_EX}")
|
||||
else()
|
||||
message("STM32_DEVICE not defined")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
set(STM32_FAMILIES F7 )
|
||||
set(STM32_HAL_DEFAULT_VERSION v1.3.0 )
|
||||
set(STM32_FREERTOS_DEFAULT_VERSION v10.5.1 )
|
||||
set(STM32_CMSIS_DEVICE_DEFAULT_VERSION v1.2.8 )
|
||||
|
||||
set(STM32_CMSIS_CORE_DEFAULT_VERSION v5.6.0 )
|
||||
|
||||
set(STM32_USB_DEVICE_DEFAULT_VERSION v2.11.2 )
|
||||
set(STM32_USB_HOST_DEFAULT_VERSION v3.5.1 )
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
FetchContent_Declare(stm32_usb_host
|
||||
GIT_REPOSITORY https://github.com/STMicroelectronics/stm32_mw_usb_host.git
|
||||
GIT_TAG ${STM32_USB_HOST_DEFAULT_VERSION}
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
|
||||
FetchContent_Declare(stm32_usb_device
|
||||
GIT_REPOSITORY https://github.com/STMicroelectronics/stm32_mw_usb_device.git
|
||||
GIT_TAG ${STM32_USB_DEVICE_DEFAULT_VERSION}
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
|
||||
function(FetchStm32UsbDevice)
|
||||
string(TOLOWER ${STM32_FAMILY_EX} STM32_FAMILY_EX_LOWER_CASE)
|
||||
FetchContent_MakeAvailable(stm32_usb_device)
|
||||
set(STM32_USB_DEVICE_SOURCE_DIR ${stm32_usb_device_SOURCE_DIR} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(FetchStm32UsbHost)
|
||||
string(TOLOWER ${STM32_FAMILY_EX} STM32_FAMILY_EX_LOWER_CASE)
|
||||
FetchContent_MakeAvailable(stm32_usb_host)
|
||||
set(STM32_USB_HOST_SOURCE_DIR ${stm32_usb_host_SOURCE_DIR} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
|
||||
FetchContent_Declare(stm32_cmsis_core
|
||||
GIT_REPOSITORY https://github.com/STMicroelectronics/cmsis_core.git
|
||||
GIT_TAG ${STM32_CMSIS_CORE_DEFAULT_VERSION}
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
|
||||
|
||||
set(ARRAY_INDEX 0)
|
||||
foreach(FAMILY ${STM32_FAMILIES})
|
||||
string(TOLOWER ${FAMILY} STM_FAMILY_LOWER_CASE)
|
||||
|
||||
if (DEFINED STM32_HAL_VERSION AND NOT STM32_HAL_VERSION STREQUAL "")
|
||||
|
||||
else()
|
||||
list(GET STM32_HAL_DEFAULT_VERSION ${ARRAY_INDEX} STM32_HAL_VERSION)
|
||||
endif()
|
||||
message("STM32_HAL_VERSION: ${STM32_HAL_VERSION}")
|
||||
|
||||
if (DEFINED STM32_FREERTOS_VERSION AND NOT STM32_FREERTOS_VERSION STREQUAL "")
|
||||
|
||||
else()
|
||||
list(GET STM32_FREERTOS_DEFAULT_VERSION ${ARRAY_INDEX} STM32_FREERTOS_VERSION)
|
||||
endif()
|
||||
message("STM32_FREERTOS_VERSION: ${STM32_FREERTOS_VERSION}")
|
||||
|
||||
|
||||
if (DEFINED STM32_CMSIS_DEVICE_VERSION AND NOT STM32_CMSIS_DEVICE_VERSION STREQUAL "")
|
||||
|
||||
else()
|
||||
list(GET STM32_CMSIS_DEVICE_DEFAULT_VERSION ${ARRAY_INDEX} STM32_CMSIS_DEVICE_VERSION)
|
||||
endif()
|
||||
message("STM32_CMSIS_DEVICE_VERSION: ${STM32_CMSIS_DEVICE_VERSION}")
|
||||
|
||||
#CMSIS Device
|
||||
FetchContent_Declare(stm32_cmsis_device_${STM_FAMILY_LOWER_CASE}
|
||||
GIT_REPOSITORY https://github.com/STMicroelectronics/cmsis_device_${STM_FAMILY_LOWER_CASE}.git
|
||||
GIT_TAG ${STM32_CMSIS_DEVICE_VERSION}
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
|
||||
#Hal
|
||||
FetchContent_Declare(stm32_hal_${STM_FAMILY_LOWER_CASE}
|
||||
GIT_REPOSITORY https://github.com/STMicroelectronics/stm32${STM_FAMILY_LOWER_CASE}xx_hal_driver.git
|
||||
GIT_TAG ${STM32_HAL_VERSION}
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
|
||||
#FreeRTOS
|
||||
FetchContent_Declare(stm32_freertos
|
||||
GIT_REPOSITORY https://github.com/STMicroelectronics/stm32_mw_freertos.git
|
||||
GIT_TAG ${STM32_FREERTOS_VERSION}
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
GIT_PROGRESS TRUE
|
||||
)
|
||||
|
||||
math(EXPR ARRAY_INDEX "${ARRAY_INDEX} + 1")
|
||||
endforeach()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function(FetchStm32Hal)
|
||||
string(TOLOWER ${STM32_FAMILY_EX} STM32_FAMILY_EX_LOWER_CASE)
|
||||
FetchContent_MakeAvailable(stm32_hal_${STM32_FAMILY_EX_LOWER_CASE} )
|
||||
set(STM32_HAL_SOURCE_DIR ${stm32_hal_${STM32_FAMILY_EX_LOWER_CASE}_SOURCE_DIR} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(FetchStm32FreeRtos)
|
||||
FetchContent_MakeAvailable(stm32_freertos)
|
||||
set(STM32_FREERTOS_SOURCE_DIR ${stm32_freertos_SOURCE_DIR} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(FetchStm32CmsisDevice)
|
||||
string(TOLOWER ${STM32_FAMILY_EX} STM32_FAMILY_EX_LOWER_CASE)
|
||||
FetchContent_MakeAvailable(stm32_cmsis_device_${STM32_FAMILY_EX})
|
||||
set(STM32_CMSIS_DEVICE_SOURCE_DIR ${stm32_cmsis_device_${STM32_FAMILY_EX_LOWER_CASE}_SOURCE_DIR} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(FetchStm32CmsisCore)
|
||||
FetchContent_MakeAvailable(STM32_CMSIS_CORE)
|
||||
set(STM32_CMSIS_CORE_SOURCE_DIR ${stm32_cmsis_core_SOURCE_DIR} PARENT_SCOPE)
|
||||
endfunction()
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
if(NOT DEFINED TOOLCHAIN_DIR)
|
||||
if(CMAKE_HOST_UNIX)
|
||||
file(GLOB TOOLCHAIN_DIRS "/usr/local/gcc-arm-none-eabi-*")
|
||||
else()
|
||||
file(GLOB TOOLCHAIN_DIRS "C:/Program Files (x86)/GNU Arm Embedded Toolchain/*" "C:/Program Files (x86)/Arm GNU Toolchain arm-none-eabi/*")
|
||||
endif()
|
||||
|
||||
if(TOOLCHAIN_DIRS)
|
||||
list(GET TOOLCHAIN_DIRS 0 TOOLCHAIN_DIR)
|
||||
message("FOUND ARM GCC Toolchain Directory: ${TOOLCHAIN_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
GET_FILENAME_COMPONENT(STM32_CMAKE_DIR ${CMAKE_CURRENT_LIST_FILE} DIRECTORY)
|
||||
list(APPEND CMAKE_MODULE_PATH ${STM32_CMAKE_DIR})
|
||||
|
||||
set(EXE_SUFFIX "")
|
||||
|
||||
set(CMAKE_LIBRARY_ARCHITECTURE arm-none-eabi)
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
set(CMAKE_SYSTEM_PROCESSOR arm)
|
||||
set(CMAKE_SYSTEM_VERSION 1)
|
||||
|
||||
|
||||
set(TOOLCHAIN_PREFIX "${CMAKE_LIBRARY_ARCHITECTURE}-")
|
||||
set(TOOLCHAIN_BIN_PATH "${TOOLCHAIN_DIR}/bin")
|
||||
set(TOOLCHAIN_INC_PATH "${TOOLCHAIN_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}/include")
|
||||
set(TOOLCHAIN_LIB_PATH "${TOOLCHAIN_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}/lib")
|
||||
set(TOOLCHAIN_SYSROOT "${TOOLCHAIN_DIR}/${CMAKE_LIBRARY_ARCHITECTURE}")
|
||||
|
||||
|
||||
|
||||
|
||||
find_program(CMAKE_C_COMPILER NAMES ${TOOLCHAIN_PREFIX}gcc HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
find_program(CMAKE_CXX_COMPILER NAMES ${TOOLCHAIN_PREFIX}g++ HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
find_program(CMAKE_ASM_COMPILER NAMES ${TOOLCHAIN_PREFIX}gcc HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
find_program(CMAKE_CPPFILT NAMES ${TOOLCHAIN_PREFIX}c++filt HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
find_program(CMAKE_DEBUGGER NAMES ${TOOLCHAIN_PREFIX}gdb HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
find_program(CMAKE_OBJCOPY NAMES ${TOOLCHAIN_PREFIX}objcopy HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
find_program(CMAKE_OBJDUMP NAMES ${TOOLCHAIN_PREFIX}objdump HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
find_program(CMAKE_SIZE NAMES ${TOOLCHAIN_PREFIX}size HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
find_program(CMAKE_AS NAMES ${TOOLCHAIN_PREFIX}as HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
find_program(CMAKE_AR NAMES ${TOOLCHAIN_PREFIX}ar HINTS ${TOOLCHAIN_BIN_PATH})
|
||||
|
||||
|
||||
set(CMAKE_EXECUTABLE_SUFFIX_C .elf)
|
||||
set(CMAKE_EXECUTABLE_SUFFIX_CXX .elf)
|
||||
set(CMAKE_EXECUTABLE_SUFFIX_ASM .elf)
|
||||
|
||||
|
||||
|
||||
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
|
||||
|
||||
|
||||
#set(COMMON_FLAGS "-mcpu=${MCU_ARCH} -mthumb -mfloat-abi=${MCU_FLOAT_ABI} -mfpu=${MCU_FPU} -ffunction-sections -fdata-sections -fsigned-char -g -fmessage-length=0 -D__weak=__attribute__((weak)) -D__packed=__attribute__((__packed__))")
|
||||
#
|
||||
#set(CMAKE_CXX_FLAGS "${COMMON_FLAGS} -std=c++17 -fno-exceptions -fno-rtti -fno-use-cxa-atexit -fno-threadsafe-statics" CACHE INTERNAL "cxx compiler flags")
|
||||
#set(CMAKE_C_FLAGS "${COMMON_FLAGS} -std=c11" CACHE INTERNAL "c compiler flags")
|
||||
#
|
||||
#set(CMAKE_EXE_LINKER_FLAGS "-Wl,-gc-sections -specs=nosys.specs -specs=nano.specs" CACHE INTERNAL "exe compiler flags")
|
||||
#SET(CMAKE_ASM_FLAGS "-mthumb -mcpu=${MCU_ARCH} -mfpu=${MCU_FPU} -mfloat-abi=${MCU_FLOAT_ABI} -x assembler-with-cpp" CACHE INTERNAL "asm compiler flags")
|
||||
#
|
||||
#
|
||||
#include(fetch_utils)
|
||||
|
||||
|
||||
|
||||
if(NOT (TARGET GCC::Specs::NoSys))
|
||||
add_library(GCC::Specs::NoSys INTERFACE IMPORTED)
|
||||
target_link_options(GCC::Specs::NoSys INTERFACE
|
||||
-specs=nosys.specs
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT (TARGET GCC::Specs::Nano))
|
||||
add_library(GCC::Specs::Nano INTERFACE IMPORTED)
|
||||
target_link_options(GCC::Specs::Nano INTERFACE
|
||||
-specs=nano.specs
|
||||
)
|
||||
endif()
|
||||
|
||||
function(gcc_add_linker_script TARGET VISIBILITY SCRIPT_PATH)
|
||||
get_filename_component(SCRIPT_PATH "${SCRIPT_PATH}" ABSOLUTE)
|
||||
target_link_options(${TARGET} ${VISIBILITY} -T "${SCRIPT_PATH}")
|
||||
endfunction()
|
||||
|
||||
function(gcc_generate_bin_file TargetName)
|
||||
add_custom_command(
|
||||
TARGET ${TargetName}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Generating flash image ${TargetName}.bin"
|
||||
COMMAND ${CMAKE_OBJCOPY} -O binary ${TargetName}${CMAKE_EXECUTABLE_SUFFIX_C} ${TargetName}.bin
|
||||
BYPRODUCTS ${TargetName}.bin
|
||||
)
|
||||
endfunction()
|
||||
|
||||
|
||||
|
||||
function(gcc_print_target_size TargetName)
|
||||
add_custom_command(
|
||||
TARGET ${TargetName}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Invoking: GCC Print Size"
|
||||
COMMAND ${CMAKE_SIZE} ${TargetName}${CMAKE_EXECUTABLE_SUFFIX_C}
|
||||
)
|
||||
endfunction()
|
||||
Reference in New Issue
Block a user