33 lines
2.0 KiB
CMake
33 lines
2.0 KiB
CMake
# 定义 qwt 静态库目标(Qwt 6.2 二维科学图表:数据集详情散点/等值线图)。
|
||
#
|
||
# 为何不用 Qwt 原生 qmake:本机 VS2026 预览版缺 vswhere,qmake 探测 cl 失败。
|
||
# 为何不用 vcpkg 的 qwt:其端口依赖 vcpkg-qtbase,会与官方 Qt 形成双 Qt 冲突(项目铁律:
|
||
# 依赖 Qt 的组件不走 vcpkg)。故此处用 CMake 直接编 Qwt 源码,对接官方 Qt6(同 VTK 思路)。
|
||
#
|
||
# 源码目录 external/qwt-src(已 gitignore,按 docs/ENV_SETUP 拉取):
|
||
# git clone --depth 1 https://github.com/opencor/qwt external/qwt-src # Qwt 6.2.0 镜像
|
||
# 由根 CMakeLists 在源码存在时 include 本文件。
|
||
|
||
set(QWT_SRC_DIR "${CMAKE_SOURCE_DIR}/external/qwt-src/src")
|
||
|
||
find_package(Qt6 REQUIRED COMPONENTS Widgets Concurrent PrintSupport Svg)
|
||
|
||
file(GLOB _qwt_sources CONFIGURE_DEPENDS "${QWT_SRC_DIR}/*.cpp")
|
||
file(GLOB _qwt_headers CONFIGURE_DEPENDS "${QWT_SRC_DIR}/*.h")
|
||
# 排除:OpenGL 画布 / SVG plot item / QwtPolar 部件(避免额外模块依赖与面积)。
|
||
# 保留 qwt_symbol.cpp(用 QSvgRenderer,故链 Qt6::Svg)与 qwt_point_polar.cpp(几何工具)。
|
||
list(FILTER _qwt_sources EXCLUDE REGEX "qwt_plot_glcanvas|qwt_plot_opengl_canvas|qwt_plot_svgitem|qwt_polar_")
|
||
list(FILTER _qwt_headers EXCLUDE REGEX "qwt_plot_glcanvas|qwt_plot_opengl_canvas|qwt_plot_svgitem|qwt_polar_")
|
||
|
||
add_library(qwt STATIC ${_qwt_sources} ${_qwt_headers})
|
||
set_target_properties(qwt PROPERTIES AUTOMOC ON)
|
||
target_include_directories(qwt PUBLIC "${QWT_SRC_DIR}")
|
||
target_link_libraries(qwt PUBLIC Qt6::Widgets Qt6::Concurrent Qt6::PrintSupport Qt6::Svg)
|
||
target_compile_features(qwt PUBLIC cxx_std_17)
|
||
# QWT_MOC_INCLUDE=1:启用 Qwt 源文件末尾 #if QWT_MOC_INCLUDE 保护的 #include "moc_xxx.cpp"。
|
||
# Qwt 原生用 qmake(qwtbuild.pri 里设置),CMake 构建需显式定义,否则 MOC 元对象代码不被编译进 .obj。
|
||
target_compile_definitions(qwt PRIVATE QWT_MOC_INCLUDE=1)
|
||
if(MSVC)
|
||
target_compile_options(qwt PRIVATE /bigobj /EHsc /wd4244 /wd4267 /wd4305 /wd4456)
|
||
endif()
|