feat: adapt to new wfassoc lib for qwfassoc
This commit is contained in:
@@ -13,13 +13,12 @@ set(CMAKE_AUTOMOC ON)
|
|||||||
set(CMAKE_AUTOUIC ON)
|
set(CMAKE_AUTOUIC ON)
|
||||||
set(CMAKE_AUTORCC 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
|
# 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
|
# the top level. The same is true for wfassoc: although only the qwfassoc
|
||||||
# library links against it directly, PUBLIC propagation from the library
|
# library links against it directly, PUBLIC propagation from the library
|
||||||
# target makes the dependency available to qwfassoc-standalone as well.
|
# 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
|
# toml11 is only needed when the standalone executable is built, so it is
|
||||||
# looked up conditionally below.
|
# looked up conditionally below.
|
||||||
find_package(Qt6 REQUIRED COMPONENTS Widgets LinguistTools)
|
find_package(Qt6 REQUIRED COMPONENTS Widgets LinguistTools)
|
||||||
|
|||||||
@@ -9,9 +9,6 @@ The project is organized as two CMake subprojects:
|
|||||||
qwfassoc/ Parent directory (this README)
|
qwfassoc/ Parent directory (this README)
|
||||||
├── CMakeLists.txt Top-level CMake; add_subdirectory's both
|
├── CMakeLists.txt Top-level CMake; add_subdirectory's both
|
||||||
│ subprojects and finds Qt, wfassoc, toml11
|
│ 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
|
├── qwfassoc/ Shared library subproject
|
||||||
│ ├── CMakeLists.txt
|
│ ├── CMakeLists.txt
|
||||||
│ ├── i18n/
|
│ ├── i18n/
|
||||||
@@ -85,9 +82,9 @@ Reproduces the original tabbed wfassoc configurator by:
|
|||||||
* **CMake** 3.20 or newer (3.21+ recommended for `qt6_add_translations`).
|
* **CMake** 3.20 or newer (3.21+ recommended for `qt6_add_translations`).
|
||||||
* A C++17 compiler.
|
* A C++17 compiler.
|
||||||
* **Qt 6** with the `Widgets` and `LinguistTools` components.
|
* **Qt 6** with the `Widgets` and `LinguistTools` components.
|
||||||
* **wfassoc**, with `wfassoc_ROOT` pointing at an installed tree (see
|
* **wfassoc**, installed as a standard config-mode CMake package
|
||||||
[`cmake/Findwfassoc.cmake`](cmake/Findwfassoc.cmake) for the expected
|
(`wfassocConfig.cmake`). Point `wfassoc_ROOT` (or `CMAKE_PREFIX_PATH`) at
|
||||||
directory layout).
|
its install prefix so `find_package(wfassoc)` can locate it.
|
||||||
* **toml11** — only required when building the standalone executable.
|
* **toml11** — only required when building the standalone executable.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|||||||
@@ -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()
|
|
||||||
@@ -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.
|
|
||||||
@@ -127,13 +127,6 @@ int main(int argc, char* argv[]) {
|
|||||||
return fatal(nullptr, QString::fromUtf8(e.what()));
|
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.
|
// Build the manifest -> schema -> program pipeline and run the dialog.
|
||||||
// Program construction consumes the schema (move) and performs the deep
|
// Program construction consumes the schema (move) and performs the deep
|
||||||
// validation (identifier format, dangling references, etc.).
|
// validation (identifier format, dangling references, etc.).
|
||||||
@@ -147,10 +140,8 @@ int main(int argc, char* argv[]) {
|
|||||||
qwfassoc::MainWindow window(std::move(program), scope);
|
qwfassoc::MainWindow window(std::move(program), scope);
|
||||||
exitCode = window.exec();
|
exitCode = window.exec();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
wfassoc::WFShutdown();
|
|
||||||
return fatal(nullptr, QString::fromUtf8(e.what()));
|
return fatal(nullptr, QString::fromUtf8(e.what()));
|
||||||
}
|
}
|
||||||
|
|
||||||
wfassoc::WFShutdown();
|
|
||||||
return exitCode;
|
return exitCode;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user