#指定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( # /usr/include/libxml2 # /usr/include/libxml2/libxml # /usr/include/cjson # /usr/local/include lib/libsqlite3/include lib/libxml2/include ${PROJECT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/app ${PROJECT_SOURCE_DIR}/kit ${PROJECT_SOURCE_DIR}/bsp ${PROJECT_SOURCE_DIR}/drv ${PROJECT_SOURCE_DIR}/lib ${PROJECT_SOURCE_DIR}/model ) add_executable(${ProjectName} main.c ) add_definitions(-DHARDWARE_TYPE=1) # 添加编译选项 target_compile_options(${ProjectName} PRIVATE -fno-stack-protector) # 添加库路径 find_library(MY_LIBRARY_PATH NAMES sqlite3 PATHS lib/libsqlite3/lib xml2 PATHS lib/libxml2/lib ) # target_link_libraries(${ProjectName} sqlite3 xml2 m paho-mqtt3c pthread crypto ssl cjson ) # target_link_libraries(${ProjectName} sqlite3 xml2 m pthread crypto ssl cjson ) 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})