2024-10-31 17:52:29 +08:00
|
|
|
#指定cmake最低版本
|
|
|
|
cmake_minimum_required(VERSION 3.10)
|
|
|
|
|
|
|
|
#x86平台
|
|
|
|
# set(CMAKE_C_COMPILER gcc)
|
|
|
|
# set(CMAKE_CXX_COMPILER g++)
|
2024-11-04 16:59:51 +08:00
|
|
|
|
2024-10-31 17:52:29 +08:00
|
|
|
#交叉编译
|
|
|
|
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
|
|
|
|
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
|
|
|
|
|
|
|
|
set(CMAKE_BUILD_TYPE "Debug")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
|
|
|
|
|
|
|
|
# 设置一个字符串变量,用与编译文件名称生成
|
|
|
|
set(ProjectName "EMS_C_V1.0.0")
|
|
|
|
|
|
|
|
project(${ProjectName})
|
|
|
|
|
2024-11-04 16:59:51 +08:00
|
|
|
# 添加头文件路径
|
2024-10-31 17:52:29 +08:00
|
|
|
include_directories(
|
2024-11-04 16:59:51 +08:00
|
|
|
${PROJECT_SOURCE_DIR}/alg
|
2024-10-31 17:52:29 +08:00
|
|
|
${PROJECT_SOURCE_DIR}/app
|
|
|
|
${PROJECT_SOURCE_DIR}/kit
|
|
|
|
${PROJECT_SOURCE_DIR}/bsp
|
|
|
|
${PROJECT_SOURCE_DIR}/drv
|
|
|
|
${PROJECT_SOURCE_DIR}/lib
|
|
|
|
${PROJECT_SOURCE_DIR}/model
|
2024-11-04 16:59:51 +08:00
|
|
|
|
|
|
|
${PROJECT_SOURCE_DIR}/test
|
|
|
|
)
|
|
|
|
|
|
|
|
# 添加驱动源文件
|
|
|
|
set(DRV_SOURCE
|
|
|
|
# DI驱动源文件
|
|
|
|
${PROJECT_SOURCE_DIR}/drv/drv_di.c
|
|
|
|
# DO驱动源文件
|
|
|
|
${PROJECT_SOURCE_DIR}/drv/drv_do.c
|
2024-11-12 08:21:37 +08:00
|
|
|
# UART驱动源文件
|
|
|
|
${PROJECT_SOURCE_DIR}/drv/drv_uart.c
|
2024-11-04 16:59:51 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# 添加KIT源文件
|
|
|
|
set(KIT_SOURCE
|
|
|
|
# Logger kit源文件
|
|
|
|
${PROJECT_SOURCE_DIR}/kit/kit_logger.c
|
2024-10-31 17:52:29 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
add_executable(${ProjectName}
|
|
|
|
main.c
|
2024-11-05 17:17:30 +08:00
|
|
|
# 测试代码源文件
|
2024-11-04 16:59:51 +08:00
|
|
|
${PROJECT_SOURCE_DIR}/test/test.c
|
2024-11-05 17:17:30 +08:00
|
|
|
# 驱动代码源文件
|
2024-11-04 16:59:51 +08:00
|
|
|
${DRV_SOURCE}
|
2024-11-05 17:17:30 +08:00
|
|
|
# 插件代码源文件
|
2024-11-04 16:59:51 +08:00
|
|
|
${KIT_SOURCE}
|
2024-10-31 17:52:29 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
add_definitions(-DHARDWARE_TYPE=1)
|
|
|
|
|
|
|
|
# 添加编译选项
|
|
|
|
target_compile_options(${ProjectName} PRIVATE -fno-stack-protector)
|
|
|
|
|
2024-11-04 16:59:51 +08:00
|
|
|
# 添加库头文件
|
|
|
|
include_directories(
|
|
|
|
lib/libsqlite3/include
|
|
|
|
lib/libxml2/include
|
|
|
|
lib/libssl/include
|
|
|
|
lib/libcjson/include
|
|
|
|
# /usr/include
|
|
|
|
)
|
|
|
|
|
2024-10-31 17:52:29 +08:00
|
|
|
# 添加库路径
|
|
|
|
find_library(MY_LIBRARY_PATH
|
2024-11-04 16:59:51 +08:00
|
|
|
NAMES
|
|
|
|
pthread PATHS /usr/aarch64-linux-gnu/lib
|
2024-10-31 17:52:29 +08:00
|
|
|
sqlite3 PATHS lib/libsqlite3/lib
|
2024-11-04 16:59:51 +08:00
|
|
|
xml2 PATHS lib/libxml2/lib
|
|
|
|
ssl PATHS lib/libssl/lib
|
|
|
|
crypto PATHS lib/libssl/lib
|
|
|
|
cjson PATHS lib/libcjson/lib
|
2024-10-31 17:52:29 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(${ProjectName} PRIVATE ${MY_LIBRARY_PATH})
|
|
|
|
|
|
|
|
# 拷贝文件
|
|
|
|
file(GLOB SQL_SCHEMAS ${CMAKE_SOURCE_DIR}/config/*.sql)
|
|
|
|
file(COPY ${SQL_SCHEMAS} DESTINATION ${CMAKE_BINARY_DIR}/config)
|
|
|
|
|
|
|
|
# 指定工作目录
|
|
|
|
# install(TARGETS ${ProjectName} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|