set(target_name "S32K344")
# Contains compile link configuration/lookup function cmake file
include(./CompileCfg.cmake)
include(./Function.cmake)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
# Set project name and language
project(${target_name}_prj LANGUAGES C ASM)
# Set C language standard
set(CMAKE_C_STANDARD 99) # C99标准
set(CMAKE_C_EXTENSIONS ON) # 开启扩展,开启编译器特有扩展
set(CMAKE_C_STANDARD_REQUIRED ON) #强制指定标准
# Set engineering/OS src path
set(OS_SRC_DIR "${CA_DIR}/01_ProductCode/RTOS")
set(PRJ_SRC_DIR "${CA_DIR}/02_ProjectCode/00_OS_Project/${target_name}_CMake/src")
# Set link script file
set(LINK_SCRIPTS
--gnu_asm
-g
-dwarf2
-T "../src/McalLib/Mcal_lib/Platform_TS_T40D34M10I0R0/build_files/ghs/linker_flash_s32k344.ld"
-e Reset_Handler
-nostartfiles
-cpu=cortexm7
-thumb
)
# Set CommmonInclude header file directory
set(PRJ_COMMMONINCLUDE_INCS "${PRJ_SRC_DIR}/CommmonInclude")
# Contains cmake files corresponding to each module
include(${OS_SRC_DIR}/Os.cmake)
include(${PRJ_SRC_DIR}/McalLib/Mcal.cmake)
include(${PRJ_SRC_DIR}/Generate/Generate.cmake)
# Project Add Header File Dependency
include_directories(${PRJ_COMMMONINCLUDE_INCS} ${PRJ_GENERATE_INCS} ${BSW_OS_INCS} ${PRJ_SOURCE_INCS})
# get_property(dirs DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
# message(">>> include_dirs=${dirs}")
# Set output file
set(EXECUTABLE ${target_name}.elf CACHE INTERNAL "TARGET")
# Obtain user files and build them
file(GLOB PRJ_MAIN_SRCS "${PRJ_SRC_DIR}/*.c")
add_executable(${EXECUTABLE} ${PRJ_MAIN_SRCS})
# Introduce subdirectories and build them
target_sources(${EXECUTABLE} PUBLIC ${PRJ_MCAL_SRCS})
target_sources(${EXECUTABLE} PUBLIC ${PRJ_GENERATE_SRCS})
target_sources(${EXECUTABLE} PUBLIC ${BSW_OS_SRCS})
# Special processing of assembly files
list(APPEND CMAKE_ASM_SOURCE_FILE_EXTENSIONS S asm inc)
set(MCAL_ASM_PATH "${PRJ_SRC_DIR}/McalLib/Mcal_lib/Platform_TS_T40D34M10I0R0/startup/src/m7/ghs")
set(SAM_OBJ "${OS_SRC_DIR}/Platform/S32K3/S32K344/Arch_PendSV.s" "${MCAL_ASM_PATH}/startup_cm7.s" "${MCAL_ASM_PATH}/Vector_Table.s")
SET_SOURCE_FILES_PROPERTIES(${SAM_OBJ} PROPERTIES LANGUAGE ASM)
target_sources(${EXECUTABLE} PUBLIC ${SAM_OBJ})
# Link Options
target_link_options(${EXECUTABLE} PRIVATE ${LINK_SCRIPTS})
***************************************************************************************************************
How to use IDE debugging correctly,
Kind Regards.