firemail

标题: CMake引入 Qt Netrork [打印本页]

作者: Qter    时间: 2023-9-3 18:01
标题: CMake引入 Qt Netrork
本帖最后由 Qter 于 2023-9-3 18:19 编辑

Common项目下的文件
CMakeLists.txt

find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui Widgets Network REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets Network REQUIRED)



target_link_libraries(Common
  PUBLIC
  Qt${QT_VERSION_MAJOR}::Gui
  Qt${QT_VERSION_MAJOR}::Core
  Qt${QT_VERSION_MAJOR}::Widgets
  Qt${QT_VERSION_MAJOR}::Network
  PRIVATE
)


上面操作后,还没有自动把Qt5Networkd.dll 复制到out目录
  1.   # Copy the config directory to output folder
  2.     COMMAND ${CMAKE_COMMAND} -E copy_directory
  3.     ${CMAKE_CURRENT_BINARY_DIR}/config
  4.     [        DISCUZ_CODE_0        ]lt;TARGET_FILE_DIR:${PROJECT_NAME}>/config

  5.     # Deploy the Qt Application
  6.     COMMAND ${DEPLOYQT_EXECUTABLE}
  7.     --no-svg
  8.     --no-translations
  9.     --no-compiler-runtime
  10.     [        DISCUZ_CODE_0        ]lt;TARGET_FILE:${PROJECT_NAME}>
复制代码
这样程序中有依赖的库会自动复制过去。




欢迎光临 firemail (http://firemail.wang:8088/) Powered by Discuz! X3