--good
This commit is contained in:
117
Cmake_templates/main_cmakelists_template.txt
Normal file
117
Cmake_templates/main_cmakelists_template.txt
Normal file
@@ -0,0 +1,117 @@
|
||||
#THIS FILE IS AUTO GENERATED FROM THE TEMPLATE! DO NOT CHANGE!
|
||||
cmake_minimum_required(VERSION 3.23)
|
||||
|
||||
|
||||
#/////////////////////////////////////////////PLEASE CHOOSE THIS OPTIONS BY YOURSELF
|
||||
set(ENV{MCU} "STM32G070xx")
|
||||
set(ENV{LINKER_SCRIPT} ${CMAKE_SOURCE_DIR}/STM32G070CBTX_FLASH.ld)
|
||||
set(ENV{FREERTOS_CONFIG} "${CMAKE_CURRENT_SOURCE_DIR}/main_prog/Core/Inc/FreeRTOSConfig.h")
|
||||
#/////////////////////////////////////////////
|
||||
|
||||
string (SUBSTRING "$ENV{MCU}" 0 7 MCU_SERIES)
|
||||
string(APPEND MCU_SERIES "XX")
|
||||
if(${MCU_SERIES} MATCHES "STM32F4|STM32F3|STM32WB|STM32WL|STM32L4|STM32WB|STM32WL|STM32G4")
|
||||
set(ENV{CORTEX-M} "4")
|
||||
set(ENV{HARDWARE_FLOAT} 1)
|
||||
elseif(${MCU_SERIES} MATCHES "STM32F2|STM32F1")
|
||||
set(ENV{CORTEX-M} "3")
|
||||
set(ENV{HARDWARE_FLOAT} 0)
|
||||
elseif(${MCU_SERIES} MATCHES "STM32F0|STM32C0|STM32G0|STM32L0" )
|
||||
set(ENV{CORTEX-M} "0")
|
||||
set(ENV{HARDWARE_FLOAT} 0)
|
||||
else()
|
||||
message(FATAL_ERROR "${MCU_SERIES} is not supported")
|
||||
endif()
|
||||
|
||||
set(ENV{MCU_SERIES} ${MCU_SERIES})
|
||||
|
||||
add_subdirectory(Cmake_templates)
|
||||
if(GTEST)
|
||||
add_subdirectory(libs/Drivers/CMSIS)
|
||||
add_subdirectory(libs/Drivers/$ENV{MCU_SERIES}_HAL_Driver)
|
||||
add_subdirectory(gtests)
|
||||
else()
|
||||
set(CMAKE_SYSTEM_NAME Generic)
|
||||
set(CMAKE_OBJECT_PATH_MAX 300)
|
||||
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
|
||||
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
|
||||
set(CMAKE_ASM_COMPILER arm-none-eabi-gcc)
|
||||
set(CMAKE_AR arm-none-eabi-ar)
|
||||
set(CMAKE_OBJCOPY arm-none-eabi-objcopy)
|
||||
set(CMAKE_OBJDUMP arm-none-eabi-objdump)
|
||||
set(SIZE arm-none-eabi-size)
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
project(myProject C CXX)
|
||||
#//////////////////////////////////////////////////////THIS IS USER CODE PART
|
||||
add_subdirectory(cmake_func)
|
||||
SET(FW_VERSION "0.7.2")
|
||||
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" AND NOT BOOT)
|
||||
set(MEM_MAP_FILE_DEBUG "memory_map_debug.inc")
|
||||
FUNC_CREATE_MEMORY_MAP("${MEM_MAP_FILE_DEBUG}" "128" "0" "4")
|
||||
else()
|
||||
set(MEM_MAP_FILE "memory_map.inc")
|
||||
FUNC_CREATE_MEMORY_MAP("${MEM_MAP_FILE}" "128" "8" "4" )
|
||||
endif()
|
||||
#//////////////////////////////////////////////////////END USER CODE PART
|
||||
|
||||
|
||||
set(CMAKE_AR arm-none-eabi-ar)
|
||||
set(CMAKE_OBJCOPY arm-none-eabi-objcopy)
|
||||
set(CMAKE_OBJDUMP arm-none-eabi-objdump)
|
||||
set(SIZE arm-none-eabi-size)
|
||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||
|
||||
|
||||
set(COMPILE_OPTIONS
|
||||
-mcpu=cortex-m$ENV{CORTEX-M}
|
||||
-mthumb -mthumb-interwork
|
||||
-ffunction-sections
|
||||
-fdata-sections
|
||||
-fno-common
|
||||
-fmessage-length=0
|
||||
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
|
||||
$<$<COMPILE_LANGUAGE:CXX>:-fpermissive>
|
||||
|
||||
)
|
||||
set(LINK_OPTIONS
|
||||
-Wl,-gc-sections,--print-memory-usage,-Map=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.map
|
||||
-mcpu=cortex-m$ENV{CORTEX-M}
|
||||
-mthumb
|
||||
-mthumb-interwork
|
||||
-T $ENV{LINKER_SCRIPT}
|
||||
)
|
||||
|
||||
set(COMPILE_DEF
|
||||
USE_HAL_DRIVER
|
||||
USE_FULL_LL_DRIVER
|
||||
${ENV_MCU}
|
||||
#//////////////////////////USER DEFINITIONS
|
||||
MBEDTLS_CONFIG_FILE="mbedtls_config.h"
|
||||
#/////////////////////////////////////////
|
||||
FW_VERSION="${FW_VERSION}"
|
||||
)
|
||||
|
||||
set(ENV{LINK_OPTIONS} "${LINK_OPTIONS}")
|
||||
|
||||
|
||||
add_link_options($ENV{LINK_OPTIONS})
|
||||
if ($ENV{CORTEX-M} EQUAL 4)
|
||||
if ($ENV{HARDWARE_FLOAT} EQUAL 1)
|
||||
add_compile_options(-mfloat-abi=hard -mfpu=fpv4-sp-d16)
|
||||
add_link_options(-mfloat-abi=hard -mfpu=fpv4-sp-d16)
|
||||
add_compile_definitions(ARM_MATH_CM4 ARM_MATH_MATRIX_CHECK ARM_MATH_ROUNDING)
|
||||
elseif($ENV{HARDWARE_FLOAT} EQUAL 0 AND $ENV})
|
||||
string(PREPEND COMPILE_OPTIONS " -mfloat-abi=soft")
|
||||
endif ()
|
||||
endif()
|
||||
set(ENV{COMPILE_OPTIONS} "${COMPILE_OPTIONS}")
|
||||
set(ENV{COMPILE_DEF} "${COMPILE_DEF}")
|
||||
add_subdirectory(libs)
|
||||
add_subdirectory(main_prog)
|
||||
|
||||
|
||||
|
||||
#//////////////////////////////////////////////////////THIS IS USER CODE PART
|
||||
|
||||
#//////////////////////////////////////////////////////END USER CODE PART
|
||||
endif()
|
||||
Reference in New Issue
Block a user