Skip to content

Commit e8717b6

Browse files
committed
Hook cmake add_custom_command for reproducible .mo files
because msgfmt breaks .mo format for .po files with <=4 strings since v0.24.1
1 parent c6f9127 commit e8717b6

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

lib/fcitx5/src/main/cpp/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/Fcitx5AndroidInstallDirs.cmake")
3030
# LIBDATADIR is not a standard CMake install dir, defined in fcitx5/CMakeLists.txt#L169
3131
set(CMAKE_INSTALL_LIBDATADIR "/usr/lib")
3232

33+
# hook add_custom_command before configuring fcitx5
34+
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/HookAddCustomCommand.cmake")
35+
3336
option(ENABLE_TEST "" OFF)
3437
option(ENABLE_COVERAGE "" OFF)
3538
option(ENABLE_ENCHANT "" OFF)

lib/fcitx5/src/main/cpp/cmake/FindFcitx5Utils.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ find_package(Gettext REQUIRED)
1919
set(FCITX_INSTALL_CMAKECONFIG_DIR "${FCITX5_DEVEL_FILES}")
2020

2121
# mimic fcitx5/src/lib/fcitx-utils/Fcitx5UtilsConfig.cmake.in
22+
include("${CMAKE_CURRENT_LIST_DIR}/HookAddCustomCommand.cmake") # hook before macros
2223
include("${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5Macros.cmake")
2324
include("${CMAKE_CURRENT_LIST_DIR}/Fcitx5AndroidInstallDirs.cmake")
2425

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
find_package(Gettext)
2+
3+
# Do as I say, not as I do
4+
# https://crascit.com/2018/09/14/do-not-redefine-cmake-commands/
5+
if (NOT COMMAND _add_custom_command)
6+
function(add_custom_command)
7+
cmake_parse_arguments(arg "" "" "COMMAND" ${ARGN})
8+
list(GET arg_COMMAND 0 cmd_0)
9+
# find calls in fcitx5_install_translation
10+
if (cmd_0 STREQUAL GETTEXT_MSGFMT_EXECUTABLE AND NOT "-d" IN_LIST arg_COMMAND)
11+
# ARGV is a list like: "COMMAND;/path/to/msgfmt;-o;mo_file;po_file"
12+
# insert arguments after GETTEXT_MSGFMT_EXECUTABLE
13+
list(FIND ARGV "${GETTEXT_MSGFMT_EXECUTABLE}" idx)
14+
math(EXPR idx "${idx} + 1")
15+
list(INSERT ARGV ${idx} "--no-hash" "--endianness=little")
16+
endif ()
17+
_add_custom_command(${ARGV})
18+
endfunction()
19+
endif ()

0 commit comments

Comments
 (0)