From 6687ccb143160c5ddcc71175cc1f366a86ac50c7 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Mon, 17 Aug 2026 10:38:39 +0800 Subject: [PATCH] feat: adapt to new wfassoc lib for qwfassoc --- example/qwfassoc/CMakeLists.txt | 5 +- example/qwfassoc/README.md | 9 +- example/qwfassoc/cmake/Findwfassoc.cmake | 101 ------------------ example/qwfassoc/cmake/README.md | 19 ---- .../qwfassoc/qwfassoc-standalone/src/main.cpp | 9 -- 5 files changed, 5 insertions(+), 138 deletions(-) delete mode 100644 example/qwfassoc/cmake/Findwfassoc.cmake delete mode 100644 example/qwfassoc/cmake/README.md diff --git a/example/qwfassoc/CMakeLists.txt b/example/qwfassoc/CMakeLists.txt index e326e8f..c22c62c 100644 --- a/example/qwfassoc/CMakeLists.txt +++ b/example/qwfassoc/CMakeLists.txt @@ -13,13 +13,12 @@ set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) -# Make the bundled Findwfassoc.cmake module visible to find_package(). -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - # Qt and LinguistTools are used by both subprojects, so they are looked up at # the top level. The same is true for wfassoc: although only the qwfassoc # library links against it directly, PUBLIC propagation from the library # target makes the dependency available to qwfassoc-standalone as well. +# wfassoc ships a standard config-mode package (wfassocConfig.cmake); point +# CMAKE_PREFIX_PATH or wfassoc_ROOT at its install prefix to locate it. # toml11 is only needed when the standalone executable is built, so it is # looked up conditionally below. find_package(Qt6 REQUIRED COMPONENTS Widgets LinguistTools) diff --git a/example/qwfassoc/README.md b/example/qwfassoc/README.md index 9de1dd3..7229336 100644 --- a/example/qwfassoc/README.md +++ b/example/qwfassoc/README.md @@ -9,9 +9,6 @@ The project is organized as two CMake subprojects: qwfassoc/ Parent directory (this README) ├── CMakeLists.txt Top-level CMake; add_subdirectory's both │ subprojects and finds Qt, wfassoc, toml11 -├── cmake/ -│ ├── Findwfassoc.cmake Verbatim copy of wfassoc's Find module -│ └── README.md Provenance notes for the copy ├── qwfassoc/ Shared library subproject │ ├── CMakeLists.txt │ ├── i18n/ @@ -85,9 +82,9 @@ Reproduces the original tabbed wfassoc configurator by: * **CMake** 3.20 or newer (3.21+ recommended for `qt6_add_translations`). * A C++17 compiler. * **Qt 6** with the `Widgets` and `LinguistTools` components. -* **wfassoc**, with `wfassoc_ROOT` pointing at an installed tree (see - [`cmake/Findwfassoc.cmake`](cmake/Findwfassoc.cmake) for the expected - directory layout). +* **wfassoc**, installed as a standard config-mode CMake package + (`wfassocConfig.cmake`). Point `wfassoc_ROOT` (or `CMAKE_PREFIX_PATH`) at + its install prefix so `find_package(wfassoc)` can locate it. * **toml11** — only required when building the standalone executable. ## Building diff --git a/example/qwfassoc/cmake/Findwfassoc.cmake b/example/qwfassoc/cmake/Findwfassoc.cmake deleted file mode 100644 index b2ee06d..0000000 --- a/example/qwfassoc/cmake/Findwfassoc.cmake +++ /dev/null @@ -1,101 +0,0 @@ -# Findwfassoc.cmake -# ---------------- -# Find wfassoc library and headers. -# -# This module requires the user to set wfassoc_ROOT to the installation -# directory of wfassoc. The directory structure under wfassoc_ROOT must be: -# bin/ - contains wfassoc_cdylib.dll -# include/ - contains wfassoc.h and wfassoc++.h -# lib/ - contains wfassoc_cdylib.dll.lib (import library) -# -# This module defines the following variables: -# wfassoc_FOUND - True if wfassoc was found -# wfassoc_INCLUDE_DIRS - Path to wfassoc include directory -# wfassoc_LIBRARIES - Path to wfassoc import library -# wfassoc_DLL - Path to wfassoc DLL -# wfassoc_ROOT - The root directory (user-provided) -# -# This module also creates the following imported targets: -# wfassoc::wfassoc - Main wfassoc library (includes both include and link) -# - -set(wfassoc_FOUND FALSE) - -# Require user to set wfassoc_ROOT -if(NOT wfassoc_ROOT) - message(FATAL_ERROR "wfassoc_ROOT must be set to the installation directory of wfassoc") -endif() - -# Check existence of required subdirectories -if(NOT EXISTS ${wfassoc_ROOT}) - message(FATAL_ERROR "wfassoc_ROOT directory does not exist: ${wfassoc_ROOT}") -endif() - -set(wfassoc_INCLUDE_DIR ${wfassoc_ROOT}/include) -set(wfassoc_LIB_DIR ${wfassoc_ROOT}/lib) -set(wfassoc_BIN_DIR ${wfassoc_ROOT}/bin) - -# Find header files -if(EXISTS ${wfassoc_INCLUDE_DIR}/wfassoc.h AND EXISTS ${wfassoc_INCLUDE_DIR}/wfassoc++.h) - set(wfassoc_INCLUDE_DIRS ${wfassoc_INCLUDE_DIR}) -else() - message(SEND_ERROR "Missing wfassoc header files in ${wfassoc_INCLUDE_DIR}") - return() -endif() - -# Find import library (.lib) -find_file(wfassoc_LIBRARIES - NAMES wfassoc_cdylib.dll.lib - PATHS ${wfassoc_LIB_DIR} - NO_DEFAULT_PATH - DOC "wfassoc import library" -) - -if(NOT wfassoc_LIBRARIES) - message(SEND_ERROR "Missing wfassoc import library (wfassoc_cdylib.dll.lib) in ${wfassoc_LIB_DIR}") - return() -endif() - -# Find DLL file -find_file(wfassoc_DLL - NAMES wfassoc_cdylib.dll - PATHS ${wfassoc_BIN_DIR} - NO_DEFAULT_PATH - DOC "wfassoc dynamic library" -) - -if(NOT wfassoc_DLL) - message(SEND_ERROR "Missing wfassoc DLL (wfassoc_cdylib.dll) in ${wfassoc_BIN_DIR}") - return() -endif() - -# Everything found -set(wfassoc_FOUND TRUE) - -# Mark variables as advanced for ccmake/cmake-gui -mark_as_advanced(wfassoc_INCLUDE_DIRS wfassoc_LIBRARIES wfassoc_DLL) - -# Create imported target for wfassoc -if(wfassoc_FOUND AND NOT TARGET wfassoc::wfassoc) - add_library(wfassoc::wfassoc SHARED IMPORTED) - - # Set include directories - set_target_properties(wfassoc::wfassoc PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${wfassoc_INCLUDE_DIRS} - ) - - # Set import library location - set_target_properties(wfassoc::wfassoc PROPERTIES - IMPORTED_IMPLIB "${wfassoc_LIBRARIES}" - IMPORTED_LOCATION "${wfassoc_DLL}" - ) -endif() - -# Optional: Print status message -if(wfassoc_FOUND) - message(STATUS "Found wfassoc:") - message(STATUS " Root : ${wfassoc_ROOT}") - message(STATUS " Include : ${wfassoc_INCLUDE_DIRS}") - message(STATUS " Library : ${wfassoc_LIBRARIES}") - message(STATUS " DLL : ${wfassoc_DLL}") -endif() diff --git a/example/qwfassoc/cmake/README.md b/example/qwfassoc/cmake/README.md deleted file mode 100644 index 61ba811..0000000 --- a/example/qwfassoc/cmake/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# qwfassoc/cmake - -This directory holds CMake helper modules used by the `qwfassoc` project. - -## `Findwfassoc.cmake` - -This file is a verbatim copy of the upstream `Findwfassoc.cmake` shipped with -the wfassoc C dynamic library, located at: - -``` -wfassoc-cdylib/cbindgen/Findwfassoc.cmake -``` - -The copy is committed here so that `qwfassoc` can locate the wfassoc library -through a standard `find_package(wfassoc)` call without depending on the source -tree layout at configure time. - -To keep this copy in sync with the upstream version, re-run the copy command -shown above whenever `wfassoc-cdylib/cbindgen/Findwfassoc.cmake` is updated. diff --git a/example/qwfassoc/qwfassoc-standalone/src/main.cpp b/example/qwfassoc/qwfassoc-standalone/src/main.cpp index 45ef6ed..928cce9 100644 --- a/example/qwfassoc/qwfassoc-standalone/src/main.cpp +++ b/example/qwfassoc/qwfassoc-standalone/src/main.cpp @@ -127,13 +127,6 @@ int main(int argc, char* argv[]) { return fatal(nullptr, QString::fromUtf8(e.what())); } - // Initialize the wfassoc runtime. WFStartup must run before most other - // wfassoc calls; if it fails we cannot proceed. - if (!wfassoc::WFStartup()) { - return fatal(nullptr, - QString::fromUtf8(wfassoc::WFGetLastError())); - } - // Build the manifest -> schema -> program pipeline and run the dialog. // Program construction consumes the schema (move) and performs the deep // validation (identifier format, dangling references, etc.). @@ -147,10 +140,8 @@ int main(int argc, char* argv[]) { qwfassoc::MainWindow window(std::move(program), scope); exitCode = window.exec(); } catch (const std::exception& e) { - wfassoc::WFShutdown(); return fatal(nullptr, QString::fromUtf8(e.what())); } - wfassoc::WFShutdown(); return exitCode; }