在clion IDE中编写ADI CCES的工程代码,cmake设置

有时需要在 CCES中编译代码,或者在stm32的mdk或者stm32cubeide中编译,但是习惯了在clion中编写代码,但是clion中需要CMAKES设置,所以需要自己写一个cmake 文件,下面是一个模板文件


cmake_minimum_required(VERSION 3.24)
project(proj_name)


#add_definitions(-DCORE0 -D_DEBUG -DADI_DEBUG -D_LANGUAGE_C -D_ADI_COMPILER -D__STDC_WANT_LIB_EXT1__)
#add_definitions(-D__ADSP21569_FAMILY__ -DCMAKE)
add_definitions(-D__ADSP21569_FAMILY__ -DCMAKE)



include_directories("D:/Analog Devices/CrossCore Embedded Studio 2.11.1/SHARC/include/")
include_directories("D:/Analog Devices/CrossCore Embedded Studio 2.11.1/SHARC/include/cplus/")
include_directories(../system)
include_directories(../system/drivers/uart)
include_directories(../system/pinmux/GeneratedSources)
include_directories(../system/services/pdma)
include_directories(../system/sru)
include_directories(../system/startup_ldf)

include_directories(.)
include_directories(subfolders)


# 定义查找源文件的目录列表
set(SOURCE_DIRS
        "subfolders"
        ) # 替换为你的各个源代码所在目录

# 初始化SRC变量
set(SRC "")

# 遍历每个目录并添加找到的.c文件到SRC变量
foreach(DIR ${SOURCE_DIRS})
    file(GLOB_RECURSE CURRENT_DIR_SRC "${DIR}/*.c")
    list(APPEND SRC ${CURRENT_DIR_SRC})
endforeach()

# 确保找到了源文件
if(NOT SRC)
    message(FATAL_ERROR "No source files found in the specified directory tree(s).")
endif()

# 将找到的源文件添加到项目中
add_executable(MyProject ${SRC})


# 头文件
#set(HEADER_DIRS
#        "D:\\Analog Devices\\CrossCore Embedded Studio 2.11.1\\SHARC\\include"
##        "../system"
#) # 替换为你的各个源代码所在目录
# 使用 GLOB_RECURSE 查找所有的头文件目录(非最佳实践,但这里仅作演示)
file(GLOB_RECURSE HEADER_DIRS LIST_DIRECTORIES true "D:\\Analog Devices\\CrossCore Embedded Studio 2.11.1\\SHARC\\include/**/*.h")

# 将找到的头文件所在目录添加到目标的包含路径
foreach(DIR ${HEADER_DIRS})
    get_filename_component(HEADER_DIR ${DIR} DIRECTORY)
    target_include_directories(MyProject PRIVATE ${HEADER_DIR})
endforeach()


posted @ 2024-08-12 17:11  Nichoooolas  阅读(9)  评论(0编辑  收藏  举报