Files
Schedule/client/CMakeLists.txt
T
Misaki 059fd721ba fix: link static ElaWidgetTools on Windows
Propagate ELAWIDGETTOOLS_LIBRARY to consumers when the Windows build uses the static ElaWidgetTools library. This avoids dllimport symbols such as __imp_ZN7ElaMenu... under MinGW. Document the stale-build workaround.
2026-10-26 14:47:19 +08:00

57 lines
2.1 KiB
CMake

cmake_minimum_required(VERSION 3.24)
find_package(Qt6 6.5 REQUIRED COMPONENTS Core Gui Widgets Sql Network Concurrent WebSockets Test)
qt_standard_project_setup()
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
# 警告选项集中定义,仅作用于本工程目标,避免第三方库告警阻断构建。
add_library(schedule_warnings INTERFACE)
if(MSVC)
target_compile_options(schedule_warnings INTERFACE /W4 /permissive-)
if(SCHEDULE_WARNINGS_AS_ERRORS)
target_compile_options(schedule_warnings INTERFACE /WX)
endif()
else()
target_compile_options(schedule_warnings INTERFACE -Wall -Wextra -Wnon-virtual-dtor)
if(SCHEDULE_WARNINGS_AS_ERRORS)
target_compile_options(schedule_warnings INTERFACE -Werror)
endif()
endif()
add_library(tomlplusplus INTERFACE)
target_include_directories(tomlplusplus SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/3rd/tomlplusplus)
# ElaWidgetTools 以静态库方式引入,避免额外运行时库分发。
set(QT_VERSION_MAJOR 6)
set(ELAWIDGETTOOLS_BUILD_STATIC_LIB ON CACHE BOOL "" FORCE)
set(CMAKE_WARN_DEPRECATED OFF)
add_subdirectory(3rd/ElaWidgetTools/ElaWidgetTools EXCLUDE_FROM_ALL)
unset(CMAKE_WARN_DEPRECATED)
# 第三方库按自身要求的 C++17 编译,避免其 C++20 弃用告警污染构建输出。
set_target_properties(ElaWidgetTools PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
if(NOT MSVC)
# 第三方库内部仍使用少量 Qt 已弃用 API,抑制其告警但不修改其源码。
target_compile_options(ElaWidgetTools PRIVATE -Wno-deprecated-declarations)
endif()
if(WIN32 AND ELAWIDGETTOOLS_BUILD_STATIC_LIB)
# ElaProperty.h 默认把使用方当作动态库客户端(dllimport)。静态链接时必须让
# 使用方也看到 ELAWIDGETTOOLS_LIBRARY,否则 MinGW 会生成 __imp_ 前缀符号。
target_compile_definitions(ElaWidgetTools INTERFACE ELAWIDGETTOOLS_LIBRARY)
if(MSVC)
target_compile_options(ElaWidgetTools INTERFACE /wd4251 /wd4275)
endif()
endif()
add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(tools)