feat: update qwfassoc
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
project(qwfassoc LANGUAGES CXX)
|
||||
project(qwfassoc_suite LANGUAGES CXX)
|
||||
|
||||
# Qt 6 requires C++17 at minimum.
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
# Let CMake auto-process Q_OBJECT, .ui files and .qrc resources.
|
||||
# Let CMake auto-process Q_OBJECT, .ui files and .qrc resources for every
|
||||
# subproject below.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
@@ -15,64 +16,21 @@ set(CMAKE_AUTORCC ON)
|
||||
# Make the bundled Findwfassoc.cmake module visible to find_package().
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
# Locate third-party dependencies. The user is responsible for making these
|
||||
# discoverable through the usual CMake mechanisms (CMAKE_PREFIX_PATH, etc.).
|
||||
# LinguistTools is required to wire up Qt's translation pipeline
|
||||
# (lupdate + lrelease) so that .ts files are kept up to date and .qm files
|
||||
# are embedded as Qt resources.
|
||||
# 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.
|
||||
# toml11 is only needed when the standalone executable is built, so it is
|
||||
# looked up conditionally below.
|
||||
find_package(Qt6 REQUIRED COMPONENTS Widgets LinguistTools)
|
||||
find_package(toml11 REQUIRED)
|
||||
# Findwfassoc.cmake requires the wfassoc_ROOT variable to be set.
|
||||
find_package(wfassoc REQUIRED)
|
||||
|
||||
set(QWFASSOC_SOURCES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/main_window.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/manifest.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/icon_utils.cpp"
|
||||
)
|
||||
# The standalone executable is optional: embedders may want only the library.
|
||||
option(QWFASSOC_BUILD_STANDALONE "Build the qwfassoc-standalone executable" ON)
|
||||
|
||||
set(QWFASSOC_HEADERS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/main_window.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/manifest.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/icon_utils.h"
|
||||
)
|
||||
add_subdirectory(qwfassoc)
|
||||
|
||||
set(QWFASSOC_UI
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/main_window.ui"
|
||||
)
|
||||
|
||||
# WIN32 makes this a windowed application on Windows (no console window).
|
||||
add_executable(qwfassoc WIN32
|
||||
${QWFASSOC_SOURCES}
|
||||
${QWFASSOC_HEADERS}
|
||||
${QWFASSOC_UI}
|
||||
)
|
||||
|
||||
target_include_directories(qwfassoc PRIVATE
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src"
|
||||
)
|
||||
|
||||
target_link_libraries(qwfassoc PRIVATE
|
||||
Qt6::Widgets
|
||||
toml11::toml11
|
||||
wfassoc::wfassoc
|
||||
)
|
||||
|
||||
# Translation pipeline.
|
||||
#
|
||||
# qt6_add_translations() runs lupdate against the target's sources (keeping
|
||||
# the .ts files below in sync) and then runs lrelease to compile them into
|
||||
# .qm files. The .qm files are embedded under the ":/i18n" resource prefix,
|
||||
# where installTranslators() in main.cpp looks them up at runtime.
|
||||
#
|
||||
# The .ts files are intentionally shipped empty: translators are expected to
|
||||
# fill them in. Re-running cmake / building the target refreshes the entries
|
||||
# found by lupdate without dropping already-translated ones.
|
||||
set(QWFASSOC_TS_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/i18n/qwfassoc_zh_CN.ts"
|
||||
)
|
||||
|
||||
qt6_add_translations(qwfassoc
|
||||
TS_FILES ${QWFASSOC_TS_FILES}
|
||||
)
|
||||
if(QWFASSOC_BUILD_STANDALONE)
|
||||
find_package(toml11 REQUIRED)
|
||||
add_subdirectory(qwfassoc-standalone)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user