Files
soft_bus_edge/CMakeLists.txt
flower_linux 5e5e608dad first commit
2026-05-19 16:38:09 +08:00

114 lines
4.2 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.19)
project(softbus_edge_agent LANGUAGES CXX VERSION 0.1.0)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)
find_package(Qt6 6.5 REQUIRED COMPONENTS Core Network SerialPort)
find_package(Qt6 QUIET COMPONENTS SerialBus)
if(TARGET Qt6::SerialBus)
set(SOFTBUS_HAVE_CAN 1)
else()
set(SOFTBUS_HAVE_CAN 0)
message(STATUS "Qt6 SerialBus not found: building edge_agent without SocketCAN (CAN reconcile disabled)")
endif()
qt_standard_project_setup()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(EDGE_AGENT_SOURCES
src/main.cpp
src/pipeline/EdgeStreamPipeline.cpp
src/pipeline/EdgeStreamPipeline.h
src/device_bus/monitor/DeviceEvent.h
src/device_bus/monitor/IDeviceMonitor.h
src/device_bus/monitor/UdevDeviceMonitor.cpp
src/device_bus/monitor/UdevDeviceMonitor.h
src/device_bus/monitor/EdgeDiscoveryCoordinator.cpp
src/device_bus/monitor/EdgeDiscoveryCoordinator.h
src/ops_ui_http.cpp
src/ops_ui_http.hpp
src/device_bus/EdgeDeviceBus.cpp
src/device_bus/EdgeDeviceBus.h
src/device_bus/tree/DeviceTreeModel.cpp
src/device_bus/tree/DeviceTreeModel.h
src/device_bus/manager/SerialDeviceManager.cpp
src/device_bus/manager/SerialDeviceManager.h
src/devices/DeviceTypes.cpp
src/devices/DeviceTypes.h
src/devices/physical/SerialDevice.cpp
src/devices/physical/SerialDevice.h
src/hardware/drivers/serial/SerialQtDriver.cpp
src/hardware/drivers/serial/SerialQtDriver.h
src/message_bus/ingress/EdgeSession.cpp
src/message_bus/ingress/EdgeSession.h
src/message_bus/ingress/EdgeTcpUplinkPort.cpp
src/message_bus/ingress/EdgeTcpUplinkPort.h
src/message_bus/ingress/EdgeUplinkWire.cpp
src/message_bus/ingress/EdgeUplinkWire.h
src/message_bus/ingress/IIngressPort.h
)
if(SOFTBUS_HAVE_CAN)
list(APPEND EDGE_AGENT_SOURCES
src/device_bus/manager/CanDeviceManager.cpp
src/device_bus/manager/CanDeviceManager.h
src/devices/physical/CanDevice.cpp
src/devices/physical/CanDevice.h
)
endif()
qt_add_executable(softbus_edge_agent ${EDGE_AGENT_SOURCES})
set(SOFTBUS_DAEMON_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../softbus_daemon")
target_sources(softbus_edge_agent PRIVATE
${SOFTBUS_DAEMON_ROOT}/src/core/plugin_system/PluginHost.cpp
${SOFTBUS_DAEMON_ROOT}/src/core/plugin_system/PluginManager.cpp
${SOFTBUS_DAEMON_ROOT}/src/message_bus/pipeline/stages/1_framers/PassthroughFramer.cpp
)
target_include_directories(softbus_edge_agent
PRIVATE
${CMAKE_SOURCE_DIR}/src
${SOFTBUS_DAEMON_ROOT}/src
${SOFTBUS_DAEMON_ROOT}
)
target_link_libraries(softbus_edge_agent PRIVATE Qt6::Core Qt6::Network Qt6::SerialPort)
if(UNIX AND NOT APPLE)
target_link_libraries(softbus_edge_agent PRIVATE dl)
endif()
if(SOFTBUS_HAVE_CAN)
target_link_libraries(softbus_edge_agent PRIVATE Qt6::SerialBus)
endif()
target_compile_definitions(softbus_edge_agent PRIVATE SOFTBUS_HAVE_CAN=${SOFTBUS_HAVE_CAN})
# 与 daemon 侧 ASan 编译的协议 .so 对齐Debug/RelWithDebInfo 下主程序也链 ASan否则 dlopen 会报
# "ASan runtime does not come first" 并退出。Release 不受影响。可用 -DSOFTBUS_EDGE_AGENT_DEBUG_ASAN=OFF 关闭。
option(SOFTBUS_EDGE_AGENT_DEBUG_ASAN "Link AddressSanitizer in Debug/RelWithDebInfo (non-Apple Unix)" ON)
if(SOFTBUS_EDGE_AGENT_DEBUG_ASAN AND UNIX AND NOT APPLE)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(softbus_edge_agent PRIVATE
$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:-fsanitize=address>)
target_link_options(softbus_edge_agent PRIVATE
$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:-fsanitize=address>)
endif()
endif()
if(UNIX AND NOT APPLE)
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(UDEV QUIET libudev)
endif()
if(UDEV_FOUND)
target_include_directories(softbus_edge_agent PRIVATE ${UDEV_INCLUDE_DIRS})
target_link_directories(softbus_edge_agent PRIVATE ${UDEV_LIBRARY_DIRS})
target_link_libraries(softbus_edge_agent PRIVATE ${UDEV_LIBRARIES})
else()
target_link_libraries(softbus_edge_agent PRIVATE udev)
endif()
endif()