#指定cmake最低版本 cmake_minimum_required(VERSION 3.10) #x86平台 # set(CMAKE_C_COMPILER gcc) # set(CMAKE_CXX_COMPILER g++) #交叉编译 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}) # 添加头文件路径 include_directories( ${PROJECT_SOURCE_DIR}/alg ${PROJECT_SOURCE_DIR}/app ${PROJECT_SOURCE_DIR}/kit ${PROJECT_SOURCE_DIR}/bsp ${PROJECT_SOURCE_DIR}/drv ${PROJECT_SOURCE_DIR}/lib ${PROJECT_SOURCE_DIR}/model ${PROJECT_SOURCE_DIR}/test ) # 添加驱动源文件 set(DRV_SOURCE # DI驱动源文件 ${PROJECT_SOURCE_DIR}/drv/drv_di.c # DO驱动源文件 ${PROJECT_SOURCE_DIR}/drv/drv_do.c # UART驱动源文件 ${PROJECT_SOURCE_DIR}/drv/drv_uart.c ) # 添加KIT源文件 set(KIT_SOURCE # Logger kit源文件 ${PROJECT_SOURCE_DIR}/kit/kit_logger.c ) add_executable(${ProjectName} main.c # 测试代码源文件 ${PROJECT_SOURCE_DIR}/test/test.c # 驱动代码源文件 ${DRV_SOURCE} # 插件代码源文件 ${KIT_SOURCE} ) add_definitions(-DHARDWARE_TYPE=1) # 添加编译选项 target_compile_options(${ProjectName} PRIVATE -fno-stack-protector) # 添加库头文件 include_directories( lib/libsqlite3/include lib/libxml2/include lib/libssl/include lib/libcjson/include # /usr/include ) # 添加库路径 find_library(MY_LIBRARY_PATH NAMES pthread PATHS /usr/aarch64-linux-gnu/lib sqlite3 PATHS lib/libsqlite3/lib xml2 PATHS lib/libxml2/lib ssl PATHS lib/libssl/lib crypto PATHS lib/libssl/lib cjson PATHS lib/libcjson/lib ) 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})