Skip to content

Commit

Permalink
Reduce cmake bloat
Browse files Browse the repository at this point in the history
  • Loading branch information
rilian-la-te committed Jan 10, 2018
1 parent 74a7557 commit 99b58c4
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 124 deletions.
93 changes: 1 addition & 92 deletions cmake/Translations.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ macro (add_translations_directory NLS_PACKAGE)
# be sure that all languages are present
# Using all usual languages code from https://www.gnu.org/software/gettext/manual/html_node/Language-Codes.html#Language-Codes
# Rare language codes should be added on-demand.
set (LANGUAGES_NEEDED en ru)
string (REPLACE ";" " " LINGUAS "${LANGUAGES_NEEDED}")
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/LINGUAS.in ${CMAKE_CURRENT_BINARY_DIR}/LINGUAS)
file(STRINGS LINGUAS LANGUAGES_NEEDED)
foreach (LANGUAGE_NEEDED ${LANGUAGES_NEEDED})
create_po_file (${LANGUAGE_NEEDED})
endforeach (LANGUAGE_NEEDED ${LANGUAGES_NEEDED})
Expand All @@ -26,31 +24,6 @@ macro (add_translations_directory NLS_PACKAGE)
RENAME ${NLS_PACKAGE}.mo
COMPONENT ${ARGV1})
endforeach (PO_INPUT ${PO_FILES})
#Create *.desktop files
file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_SOURCE_DIR}/ ${CMAKE_SOURCE_DIR}/*.desktop.plugin.in)
foreach(PLUGIN_DESKTOP_IN_FILE ${SOURCE_FILES})
get_filename_component( BASE_NAME ${PLUGIN_DESKTOP_IN_FILE} NAME )
string(REGEX REPLACE ".desktop.plugin.in$" "" PLUGIN_FILE ${BASE_NAME})
get_filename_component( BASE_DIRECTORY ${PLUGIN_DESKTOP_IN_FILE} PATH )
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${BASE_DIRECTORY})
add_custom_command (TARGET i18n COMMAND ${MSGFMT_EXECUTABLE} --desktop --keyword=Name --keyword=Description --keyword=Help -d ${CMAKE_CURRENT_BINARY_DIR} --template ${CMAKE_SOURCE_DIR}/${PLUGIN_DESKTOP_IN_FILE} -o ${CMAKE_BINARY_DIR}/${BASE_DIRECTORY}/${PLUGIN_FILE}.plugin)
endforeach()
file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_SOURCE_DIR}/ ${CMAKE_SOURCE_DIR}/*.desktop.in)
foreach(DESKTOP_IN_FILE ${SOURCE_FILES})
get_filename_component( BASE_NAME ${DESKTOP_IN_FILE} NAME )
string(REGEX REPLACE ".desktop.in$" "" PLUGIN_FILE ${BASE_NAME})
get_filename_component( BASE_DIRECTORY ${DESKTOP_IN_FILE} PATH )
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${BASE_DIRECTORY})
add_custom_command (TARGET i18n COMMAND ${MSGFMT_EXECUTABLE} --desktop -d ${CMAKE_CURRENT_BINARY_DIR} --template ${CMAKE_SOURCE_DIR}/${DESKTOP_IN_FILE} -o ${CMAKE_BINARY_DIR}/${BASE_DIRECTORY}/${PLUGIN_FILE}.desktop)
endforeach()
file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_SOURCE_DIR}/ ${CMAKE_SOURCE_DIR}/*.desktop.xfce.in)
foreach(XFCE_DESKTOP_IN_FILE ${SOURCE_FILES})
get_filename_component( BASE_NAME ${XFCE_DESKTOP_IN_FILE} NAME )
string(REGEX REPLACE ".desktop.xfce.in$" "" PLUGIN_FILE ${BASE_NAME})
get_filename_component( BASE_DIRECTORY ${XFCE_DESKTOP_IN_FILE} PATH )
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${BASE_DIRECTORY})
add_custom_command (TARGET i18n COMMAND ${MSGFMT_EXECUTABLE} --desktop --keyword=Name --keyword=Comment --keyword=Help -d ${CMAKE_CURRENT_BINARY_DIR} --template ${CMAKE_SOURCE_DIR}/${XFCE_DESKTOP_IN_FILE} -o ${CMAKE_BINARY_DIR}/${BASE_DIRECTORY}/${PLUGIN_FILE}.desktop)
endforeach()
endmacro (add_translations_directory)

# Apply the right default template.
Expand Down Expand Up @@ -120,11 +93,6 @@ macro (add_translations_catalog NLS_PACKAGE)
find_program (XGETTEXT_EXECUTABLE xgettext)

set(C_SOURCE "")
set(VALA_SOURCE "")
set(GLADE_SOURCE "")
set(PLUGIN_DESKTOP_SOURCE "")
set(DESKTOP_SOURCE "")
set(XML_SOURCE "")

foreach(FILES_INPUT ${ARGN})
set(BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT})
Expand All @@ -133,36 +101,6 @@ macro (add_translations_catalog NLS_PACKAGE)
foreach(C_FILE ${SOURCE_FILES})
set(C_SOURCE ${C_SOURCE} ${C_FILE})
endforeach()

file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.vala)
foreach(VALA_C_FILE ${SOURCE_FILES})
set(VALA_SOURCE ${VALA_SOURCE} ${VALA_C_FILE})
endforeach()

file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.ui)
foreach(GLADE_C_FILE ${SOURCE_FILES})
set(GLADE_SOURCE ${GLADE_SOURCE} ${GLADE_C_FILE})
endforeach()

file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.desktop.plugin.in)
foreach(PLUGIN_DESKTOP_IN_FILE ${SOURCE_FILES})
set(PLUGIN_DESKTOP_SOURCE ${PLUGIN_DESKTOP_SOURCE} ${PLUGIN_DESKTOP_IN_FILE})
endforeach()

file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.desktop.xfce.in)
foreach(XFCE_DESKTOP_IN_FILE ${SOURCE_FILES})
set(XFCE_DESKTOP_SOURCE ${XFCE_DESKTOP_SOURCE} ${XFCE_DESKTOP_IN_FILE})
endforeach()

file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.xml.in)
foreach(XML_IN_FILE ${SOURCE_FILES})
set(XML_SOURCE ${PLUGIN_DESKTOP_SOURCE} ${XML_IN_FILE})
endforeach()

file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.desktop.in)
foreach(DESKTOP_IN_FILE ${SOURCE_FILES})
set(DESKTOP_SOURCE ${DESKTOP_SOURCE} ${DESKTOP_IN_FILE})
endforeach()
endforeach()

set(BASE_XGETTEXT_COMMAND
Expand All @@ -176,33 +114,4 @@ macro (add_translations_catalog NLS_PACKAGE)
add_custom_command(TARGET pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${C_SOURCE})
set(CONTINUE_FLAG "-j")
ENDIF()

IF(NOT "${VALA_SOURCE}" STREQUAL "")
add_custom_command(TARGET pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -LC\# ${VALA_SOURCE})
set(CONTINUE_FLAG "-j")
ENDIF()

IF(NOT "${GLADE_SOURCE}" STREQUAL "")
add_custom_command (TARGET pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -LGlade ${GLADE_SOURCE})
set(CONTINUE_FLAG "-j")
ENDIF()

IF(NOT "${PLUGIN_DESKTOP_SOURCE}" STREQUAL "")
add_custom_command (TARGET pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -Ldesktop -kName -kDescription -kHelp ${PLUGIN_DESKTOP_SOURCE})
set(CONTINUE_FLAG "-j")
ENDIF()

IF(NOT "${XFCE_DESKTOP_SOURCE}" STREQUAL "")
add_custom_command (TARGET pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -Ldesktop -kName -kComment -kHelp ${XFCE_DESKTOP_SOURCE})
set(CONTINUE_FLAG "-j")
ENDIF()

IF(NOT "${DESKTOP_SOURCE}" STREQUAL "")
add_custom_command (TARGET pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -Ldesktop ${DESKTOP_SOURCE})
set(CONTINUE_FLAG "-j")
ENDIF()

IF(NOT "${XML_SOURCE}" STREQUAL "")
add_custom_command (TARGET pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${CONTINUE_FLAG} -LGsettings ${XML_SOURCE})
ENDIF()
endmacro ()
31 changes: 0 additions & 31 deletions cmake/TranslationsMusl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ macro (add_musl_translations_directory NLS_PACKAGE LOCPATH)
# Using all usual languages code from https://www.gnu.org/software/gettext/manual/html_node/Language-Codes.html#Language-Codes
# Rare language codes should be added on-demand.
file(STRINGS LOCALES LANGUAGES_NEEDED)
# set (LANGUAGES_NEEDED aa ab ae af ak am an ar as ast av ay az ba be bg bh bi bm bn bo br bs ca ce ch ckb co cr cs cu cv cy da de dv dz ee el en_AU en_CA en_GB eo es et eu fa ff fi fj fo fr fr_CA fy ga gd gl gn gu gv ha he hi ho hr ht hu hy hz ia id ie ig ii ik io is it iu ja jv ka kg ki kj kk kl km kn ko kr ks ku kv kw ky la lb lg li ln lo lt lu lv mg mh mi mk ml mn mo mr ms mt my na nb nd ne ng nl nn nb nr nv ny oc oj om or os pa pi pl ps pt pt_BR qu rm rn ro ru rue rw sa sc sd se sg si sk sl sm sma sn so sq sr ss st su sv sw ta te tg th ti tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa wo xh yi yo za zh zh_CN zh_HK zh_TW zu)
# string (REPLACE ";" " " LINGUAS "${LANGUAGES_NEEDED}")
# configure_file (${CMAKE_CURRENT_SOURCE_DIR}/LINGUAS.in ${CMAKE_CURRENT_BINARY_DIR}/LINGUAS)
foreach (LANGUAGE_NEEDED ${LANGUAGES_NEEDED})
create_po_file (${LANGUAGE_NEEDED})
endforeach (LANGUAGE_NEEDED ${LANGUAGES_NEEDED})
Expand All @@ -26,31 +23,3 @@ macro (add_musl_translations_directory NLS_PACKAGE LOCPATH)
${LOCPATH})
endforeach (PO_INPUT ${PO_FILES})
endmacro (add_musl_translations_directory)

macro (add_musl_translations_catalog NLS_PACKAGE)
add_custom_target (musl-pot COMMENT ?Building translation catalog for C library.?)
find_program (XGETTEXT_EXECUTABLE xgettext)

set(C_SOURCE "")

foreach(FILES_INPUT ${ARGN})
set(BASE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${FILES_INPUT})

file (GLOB_RECURSE SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/ ${BASE_DIRECTORY}/*.c)
foreach(C_FILE ${SOURCE_FILES})
set(C_SOURCE ${C_SOURCE} ${C_FILE})
endforeach()
endforeach()

set(BASE_XGETTEXT_COMMAND
${XGETTEXT_EXECUTABLE} -d ${NLS_PACKAGE}
-o ${CMAKE_CURRENT_SOURCE_DIR}/${NLS_PACKAGE}.pot
--add-comments="/" --extract-all --from-code=UTF-8)

set(CONTINUE_FLAG "")

IF(NOT "${C_SOURCE}" STREQUAL "")
add_custom_command(TARGET musl-pot WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND ${BASE_XGETTEXT_COMMAND} ${C_SOURCE})
set(CONTINUE_FLAG "-j")
ENDIF()
endmacro (add_musl_translations_catalog)
Empty file modified locale.in
100644 → 100755
Empty file.
2 changes: 2 additions & 0 deletions po/LINGUAS
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
en_US
ru_RU
1 change: 0 additions & 1 deletion po/LINGUAS.in

This file was deleted.

0 comments on commit 99b58c4

Please sign in to comment.