Skip to content

Commit

Permalink
CMake: avoid unnecessarily remaking all .mo files on each build
Browse files Browse the repository at this point in the history
All the .mo files had a dependency on the target directory, which meant that
every change to the timestamp of that directory caused all the files to be
remade; and each file remade caused a change to the directory's timestamp ...

Since CMake 3.0, "cmake -E make_directory" has been deprecated in favor of
"file(MAKE_DIRECTORY ...)", so use that instead of the custom command. This
means the directories are created when the cmake config is generated, instead
of during the subsequent make steps.

Note: the mo-update target which builds the .mo files is only run when the
build is configured with ENABLE_NLS=ON. Both before and after this change,
none of the .mo files are rebuilt when ENABLE_NLS=OFF.
  • Loading branch information
stevecotton committed Feb 13, 2021
1 parent 09be367 commit eab006f
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions po/CMakeLists.txt
Expand Up @@ -239,20 +239,14 @@ if(ENABLE_NLS)

foreach(DOMAIN ${DOMAINS})

add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES
COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES
COMMENT "mo-update [${LINGUA}]: Creating locale directory."
)
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES)

add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE}
${GETTEXT_MSGFMT_PARAMETER}
-o ${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo ${LINGUA}.po
DEPENDS
${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${LINGUA}.po
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/po/${DOMAIN}
COMMENT "mo-update [${DOMAIN}-${LINGUA}]: Creating mo file."
Expand Down

0 comments on commit eab006f

Please sign in to comment.