From 115a68878c80cb34f5b251f9d49e9262f9ce9b24 Mon Sep 17 00:00:00 2001 From: Serein <2075337935@qq.com> Date: Wed, 25 Sep 2024 22:00:05 +0800 Subject: [PATCH] build: install msgfmt by vcpkg --- .github/workflows/build.yml | 1 + CMakeLists.txt | 2 +- src/CMakeLists.txt | 6 ++++-- src/Infrastructure/Utils/Config.h | 2 +- vcpkg.json | 7 +++++++ 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ad7787e6..278e1e08 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -114,6 +114,7 @@ jobs: Import-Module (Join-Path $vsPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll") Enter-VsDevShell -VsInstallPath $vsPath -SkipAutomaticLocation -DevCmdArguments '-arch=${{ matrix.msvc_arch }} -host_arch=x64' $additionalConfigureArgs += '-DPKG_CONFIG_EXECUTABLE:FILEPATH=./build/vcpkg_installed/x64-windows/tools/pkgconf/pkgconf.exe' + $additionalConfigureArgs += '-DMSGFMT_EXECUTABLE:FILEPATH=./build/vcpkg_installed/x64-windows/tools/gettext/bin/msgfmt.exe' } if ($vcpkgTargetTriplet) { $additionalConfigureArgs += "-DVCPKG_TARGET_TRIPLET:STRING=$vcpkgTargetTriplet" diff --git a/CMakeLists.txt b/CMakeLists.txt index c6182b60..44afa99f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,7 @@ if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/3rdpart/sast-link-cxx-sdk/CMakeLists message(FATAL_ERROR "Git submodule not found. Run `git submodule update --init` from the source tree to fetch the submodule contents.") endif() -#i18n +# i18n set(SOURCE_LOCALE_DIR "${CMAKE_SOURCE_DIR}/ui/locale") # source code diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ce4238f9..62280214 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -77,11 +77,13 @@ if (WIN32) add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $ $ COMMAND_EXPAND_LISTS) endif() +find_program(MSGFMT_EXECUTABLE msgfmt REQUIRED) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${SOURCE_LOCALE_DIR}/en/LC_MESSAGES - COMMAND msgfmt ${SOURCE_LOCALE_DIR}/en.po -o ${SOURCE_LOCALE_DIR}/en/LC_MESSAGES/sast-evento.mo + COMMAND ${MSGFMT_EXECUTABLE} ${SOURCE_LOCALE_DIR}/en.po -o ${SOURCE_LOCALE_DIR}/en/LC_MESSAGES/sast-evento.mo COMMAND ${CMAKE_COMMAND} -E make_directory ${SOURCE_LOCALE_DIR}/zh/LC_MESSAGES - COMMAND msgfmt ${SOURCE_LOCALE_DIR}/zh.po -o ${SOURCE_LOCALE_DIR}/zh/LC_MESSAGES/sast-evento.mo + COMMAND ${MSGFMT_EXECUTABLE} ${SOURCE_LOCALE_DIR}/zh.po -o ${SOURCE_LOCALE_DIR}/zh/LC_MESSAGES/sast-evento.mo ) add_subdirectory(Tray) diff --git a/src/Infrastructure/Utils/Config.h b/src/Infrastructure/Utils/Config.h index 1463d47f..417c72f4 100644 --- a/src/Infrastructure/Utils/Config.h +++ b/src/Infrastructure/Utils/Config.h @@ -40,7 +40,7 @@ const std::filesystem::path localePath = #ifdef EVENTO_DEBUG LOCALE_DIR; #else - boost::dll::program_location().parent_path() / "locale"; + std::filesystem::path{(boost::dll::program_location().parent_path() / "locale").string()}; #endif // EVENTO_DEBUG inline struct Settings { diff --git a/vcpkg.json b/vcpkg.json index 47499bf0..1b102ef8 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -10,6 +10,13 @@ "nlohmann-json", "spdlog", "tomlplusplus", + { + "name": "gettext", + "features": [ + "tools" + ], + "host": true + }, "gettext-libintl", { "name": "pkgconf",