cmake_minimum_required(VERSION 3.10)  # 必须
set(CMAKE_CXX_STANDARD 14)	# C++14

project(app_XHHW)  #工程名,比如APP_TCU，APP_CCU，APP_PCU

# set(CMAKE_ROOTFS /home/sunjt/myir-am62x/oe-layersetup/build/arago-tmp-default-glibc/work/myd_am62x-oe-linux/myir-image-full/1.0-r0_edgeai_0/recipe-sysroot-native)
# include_directories(${CMAKE_ROOTFS}/usr/include) # 头文件目录
# link_directories(${CMAKE_ROOTFS}/usr/lib)

include_directories(${CMAKE_SYSROOT}/usr/local/include) # 头文件目录
link_directories(${CMAKE_SYSROOT}/usr/local/lib/) # 链接库目录

include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${PROJECT_SOURCE_DIR}/ptimer)
include_directories(${PROJECT_SOURCE_DIR}/easylog)
include_directories(${PROJECT_SOURCE_DIR}/cJSON)

link_directories(${PROJECT_SOURCE_DIR}/lib)

aux_source_directory(./src SRCS) # 源文件
aux_source_directory(./ptimer SRCS)
aux_source_directory(./easylog SRCS)
aux_source_directory(./cJSON SRCS)

set(CMAKE_C_FLAGS "-O1 -g") # 设置C工程的 CFLAGS
set(CMAKE_CXX_FLAGS "-O0 -Werror -g") # 设置C++ 工程的 CXX_FLAGS

add_executable(${PROJECT_NAME} ${SRCS}) # 生成可执行文件，这里程序名即为功能名

target_link_libraries(${PROJECT_NAME} ssl crypto pthread m dl) # 链接库

# 下面使用install作为项目打包使用
set(CMAKE_INSTALL_PREFIX ./bin)  # 自定义安装目录，打包使用
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) # 打包二进制文件

set(CONFIGS ${PROJECT_SOURCE_DIR}/etc/tcu_config.json) 
install(FILES ${CONFIGS} DESTINATION config) # 打包配置文件
