kunlang_mqtt_client/CMakeLists.txt

62 lines
1.5 KiB
CMake
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

cmake_minimum_required(VERSION 3.10)
project(mqtt_client)
# 设置 C++ 标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# 设置可执行文件输出目录
# 包含头文件目录
include_directories(
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/third_party/paho_mqtt
${CMAKE_SOURCE_DIR}/third_party/
)
option(PLATFORM_HISI "Build for HiSilicon platform" ON)
if (PLATFORM_HISI)
link_directories(${CMAKE_SOURCE_DIR}/lib/hisi)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../../bin/hisi)
set(PAHO_C_LIB paho-mqtt3a) # TCP 库
else()
link_directories(${CMAKE_SOURCE_DIR}/lib/x86)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../../bin/x86)
set(PAHO_C_LIB paho-mqtt3a) # 本机测试也用 TCP 库,如果需要 SSL再改成 paho-mqtt3as
endif()
# 源文件列表
set(SOURCES
src/main.cpp
src/config/mqtt_config.cpp
src/data/protocol_codec.cpp
src/log/logger.cpp
src/tcp/tcp_client.cpp
src/tcp/tcp_server.cpp
src/mqtt/mqtt_client.cpp
src/mqtt/mqtt_client_wrapper.cpp
src/tcp/tcp_thread/broadcast_client.cpp
src/tcp/tcp_thread/mqtt_config_client.cpp
src/tcp/tcp_thread/uplink_data_client.cpp
src/tcp/tcp_thread/uplink_notify_client.cpp
src/tcp/tcp_thread/reply_server.cpp
)
# 创建可执行文件
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(mqtt_client
pthread
paho-mqttpp3
${PAHO_C_LIB}
ssl
crypto
dl
)