summaryrefslogtreecommitdiffhomepage
path: root/cmake
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-02-11 21:40:16 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-02-12 10:04:54 +0100
commit6bb50c04e5c40a5e036e41dde11b1660c3b077f6 (patch)
tree631e2895855276a3908b2ca0e11244286737dfc3 /cmake
parent5f3a8456cdb53b9679086e3286716fff1e67b4a8 (diff)
cmake/i18n: fix `make i18n'
Also remove disabling i18n regen cf. #746
Diffstat (limited to 'cmake')
-rw-r--r--cmake/opentrack-i18n.cmake133
-rw-r--r--cmake/opentrack-install.cmake3
2 files changed, 72 insertions, 64 deletions
diff --git a/cmake/opentrack-i18n.cmake b/cmake/opentrack-i18n.cmake
index 7005187c..16530e1e 100644
--- a/cmake/opentrack-i18n.cmake
+++ b/cmake/opentrack-i18n.cmake
@@ -1,61 +1,72 @@
-function(otr_i18n_for_target_directory n)
- get_property(variant GLOBAL PROPERTY opentrack-variant)
- if(NOT ".${variant}" STREQUAL "default")
- set(force-skip-update TRUE)
- else()
- set(force-skip-update FALSE)
- endif()
-
- set(k "opentrack-${n}")
-
- get_property(lupdate-binary TARGET "${Qt5_LUPDATE_EXECUTABLE}" PROPERTY IMPORTED_LOCATION)
-
- foreach(i ${opentrack_all-translations})
- set(t "${CMAKE_CURRENT_SOURCE_DIR}/lang/${i}.ts")
- set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" PROPERTY CLEAN_NO_CUSTOM 1)
- if(maybe-skip-update OR NOT opentrack_disable-i18n-update)
- add_custom_command(OUTPUT "${t}"
- COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_SOURCE_DIR}/lang"
- COMMAND "${lupdate-binary}" -silent -recursive -no-obsolete -locations relative . -ts "${t}"
- WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
- DEPENDS ${${k}-cc} ${${k}-hh} ${${k}-ui} ${${k}-rc}
- COMMENT "Running lupdate for ${n}/${i}")
- set(target-name "i18n-lang-${i}-module-${n}")
- add_custom_target(${target-name} DEPENDS "${t}")
- endif()
- set_property(GLOBAL APPEND PROPERTY "opentrack-ts-files-${i}" "${t}")
- endforeach()
-endfunction()
-
-function(otr_merge_translations)
- install(CODE "file(REMOVE_RECURSE \"\${CMAKE_INSTALL_PREFIX}/i18n\")")
-
- set(all-qm-files "")
-
- foreach(i ${opentrack_all-translations})
- get_property(ts-files GLOBAL PROPERTY "opentrack-ts-files-${i}")
-
- set(ts-files_ "")
-
- foreach(k ${ts-files})
- if(EXISTS "${k}" OR NOT opentrack_disable-i18n-update)
- list(APPEND ts-files_ "${k}")
- endif()
- endforeach()
-
- get_property(lrelease-binary TARGET "${Qt5_LRELEASE_EXECUTABLE}" PROPERTY IMPORTED_LOCATION)
-
- if(NOT ".${ts-files_}" STREQUAL ".")
- set(qm-output "${CMAKE_CURRENT_BINARY_DIR}/${i}.qm")
- list(APPEND all-qm-files "${qm-output}")
- add_custom_command(OUTPUT "${qm-output}"
- COMMAND "${lrelease-binary}" -nounfinished -silent ${ts-files_} -qm "${qm-output}"
- DEPENDS ${ts-files}
- COMMENT "Running lrelease for ${i}")
- set(lang-target "i18n-lang-${i}")
- add_custom_target("${lang-target}" DEPENDS "${qm-output}")
- install(FILES "${qm-output}" DESTINATION "${opentrack-i18n-pfx}" RENAME "${i}.qm" ${opentrack-perms})
- endif()
- endforeach()
- add_custom_target(i18n ALL DEPENDS ${all-qm-files})
-endfunction()
+function(otr_i18n_for_target_directory n)
+ set(k "opentrack-${n}")
+
+ get_property(lupdate-binary TARGET "${Qt5_LUPDATE_EXECUTABLE}" PROPERTY IMPORTED_LOCATION)
+
+ foreach(i ${opentrack_all-translations})
+ set(t "${CMAKE_CURRENT_SOURCE_DIR}/lang/${i}.ts")
+ set(t2 "${CMAKE_CURRENT_BINARY_DIR}/lang/${i}.ts")
+ set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" PROPERTY CLEAN_NO_CUSTOM 1)
+ set(input ${${k}-cc} ${${k}-hh} ${${k}-ui} ${${k}-rc})
+ add_custom_command(OUTPUT "${t2}"
+ COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_CURRENT_SOURCE_DIR}/lang"
+ COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/lang"
+ COMMAND "${lupdate-binary}" .
+ -I "${CMAKE_SOURCE_DIR}"
+ -silent
+ -recursive
+ -no-obsolete
+ -locations none
+ -no-ui-lines
+ -ts "${t}"
+ COMMAND "${CMAKE_COMMAND}" -E copy "${t}" "${t2}"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+ DEPENDS ${input}
+ COMMENT "Running lupdate for ${n}/${i}")
+ set_property(SOURCE ${input} PROPERTY GENERATED TRUE)
+ set(target-name "i18n-lang-${i}-module-${n}")
+ add_custom_target(${target-name} DEPENDS "${t2}")
+ set_property(GLOBAL APPEND PROPERTY "opentrack-ts-files-${i}" "${t2}")
+ endforeach()
+endfunction()
+
+function(otr_merge_translations)
+ install(CODE "file(REMOVE_RECURSE \"\${CMAKE_INSTALL_PREFIX}/i18n\")")
+
+ get_property(variant GLOBAL PROPERTY opentrack-variant)
+ if(NOT ".${variant}" STREQUAL ".default")
+ set(force-skip-update TRUE)
+ else()
+ set(force-skip-update FALSE)
+ endif()
+
+ set(all-qm-files "")
+
+ foreach(i ${opentrack_all-translations})
+ get_property(ts-files GLOBAL PROPERTY "opentrack-ts-files-${i}")
+ get_property(lrelease-binary TARGET "${Qt5_LRELEASE_EXECUTABLE}" PROPERTY IMPORTED_LOCATION)
+
+ set(qm-output "${CMAKE_CURRENT_BINARY_DIR}/${i}.qm")
+ list(APPEND all-qm-files "${qm-output}")
+ add_custom_command(OUTPUT "${qm-output}"
+ COMMAND "${lrelease-binary}" -nounfinished -silent ${ts-files} -qm "${qm-output}"
+ DEPENDS ${ts-files}
+ COMMENT "Running lrelease for ${i}")
+ otr_escape_string(esc-qm-output "${qm-output}")
+ otr_escape_string(esc-i18n-pfx "${opentrack-i18n-pfx}")
+ otr_escape_string(esc-perms "${opentrack-perms-file}")
+ otr_escape_string(esc-name "${i}")
+
+ # this is because with i18n update disabled,
+ # the file may not exist when running `make i18n-lang-foo_FOO'
+ install(CODE "
+ if(EXISTS \"${esc-qm-output}\")
+ file(INSTALL \"${esc-qm-output}\"
+ DESTINATION \"${esc-i18n-pfx}\"
+ FILE_PERMISSIONS ${esc-perms})
+ endif()
+ ")
+ endforeach()
+
+ add_custom_target(i18n ALL DEPENDS ${all-qm-files})
+endfunction()
diff --git a/cmake/opentrack-install.cmake b/cmake/opentrack-install.cmake
index 01f59722..43212109 100644
--- a/cmake/opentrack-install.cmake
+++ b/cmake/opentrack-install.cmake
@@ -47,6 +47,3 @@ otr_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/CONTRIBUTING.md"
otr_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/WARRANTY.txt")
otr_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/OPENTRACK-LICENSING.txt")
otr_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/AUTHORS.md")
-
-set(opentrack_disable-i18n-update FALSE CACHE BOOL "")
-