Files
@ r28769:123ae3cb0017
Branch filter:
Location: cpp/openttd-patchpack/source/src/lang/CMakeLists.txt
r28769:123ae3cb0017
5.3 KiB
text/plain
Codechange: Add support for number format and abbreviations pragmas/attributes to strgen
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | set(MASTER_LANG_FILE
${CMAKE_CURRENT_SOURCE_DIR}/english.txt
)
set(LANG_SOURCE_FILES
${MASTER_LANG_FILE}
${CMAKE_CURRENT_SOURCE_DIR}/afrikaans.txt
${CMAKE_CURRENT_SOURCE_DIR}/arabic_egypt.txt
${CMAKE_CURRENT_SOURCE_DIR}/basque.txt
${CMAKE_CURRENT_SOURCE_DIR}/belarusian.txt
${CMAKE_CURRENT_SOURCE_DIR}/brazilian_portuguese.txt
${CMAKE_CURRENT_SOURCE_DIR}/bulgarian.txt
${CMAKE_CURRENT_SOURCE_DIR}/catalan.txt
${CMAKE_CURRENT_SOURCE_DIR}/chuvash.txt
${CMAKE_CURRENT_SOURCE_DIR}/croatian.txt
${CMAKE_CURRENT_SOURCE_DIR}/czech.txt
${CMAKE_CURRENT_SOURCE_DIR}/danish.txt
${CMAKE_CURRENT_SOURCE_DIR}/dutch.txt
${CMAKE_CURRENT_SOURCE_DIR}/english_AU.txt
${CMAKE_CURRENT_SOURCE_DIR}/english_US.txt
${CMAKE_CURRENT_SOURCE_DIR}/esperanto.txt
${CMAKE_CURRENT_SOURCE_DIR}/estonian.txt
${CMAKE_CURRENT_SOURCE_DIR}/faroese.txt
${CMAKE_CURRENT_SOURCE_DIR}/finnish.txt
${CMAKE_CURRENT_SOURCE_DIR}/french.txt
${CMAKE_CURRENT_SOURCE_DIR}/frisian.txt
${CMAKE_CURRENT_SOURCE_DIR}/gaelic.txt
${CMAKE_CURRENT_SOURCE_DIR}/galician.txt
${CMAKE_CURRENT_SOURCE_DIR}/german.txt
${CMAKE_CURRENT_SOURCE_DIR}/greek.txt
${CMAKE_CURRENT_SOURCE_DIR}/hebrew.txt
${CMAKE_CURRENT_SOURCE_DIR}/hindi.txt
${CMAKE_CURRENT_SOURCE_DIR}/hungarian.txt
${CMAKE_CURRENT_SOURCE_DIR}/icelandic.txt
${CMAKE_CURRENT_SOURCE_DIR}/ido.txt
${CMAKE_CURRENT_SOURCE_DIR}/indonesian.txt
${CMAKE_CURRENT_SOURCE_DIR}/irish.txt
${CMAKE_CURRENT_SOURCE_DIR}/italian.txt
${CMAKE_CURRENT_SOURCE_DIR}/japanese.txt
${CMAKE_CURRENT_SOURCE_DIR}/korean.txt
${CMAKE_CURRENT_SOURCE_DIR}/latin.txt
${CMAKE_CURRENT_SOURCE_DIR}/latvian.txt
${CMAKE_CURRENT_SOURCE_DIR}/lithuanian.txt
${CMAKE_CURRENT_SOURCE_DIR}/luxembourgish.txt
${CMAKE_CURRENT_SOURCE_DIR}/macedonian.txt
${CMAKE_CURRENT_SOURCE_DIR}/malay.txt
${CMAKE_CURRENT_SOURCE_DIR}/maltese.txt
${CMAKE_CURRENT_SOURCE_DIR}/marathi.txt
${CMAKE_CURRENT_SOURCE_DIR}/norwegian_bokmal.txt
${CMAKE_CURRENT_SOURCE_DIR}/norwegian_nynorsk.txt
${CMAKE_CURRENT_SOURCE_DIR}/persian.txt
${CMAKE_CURRENT_SOURCE_DIR}/polish.txt
${CMAKE_CURRENT_SOURCE_DIR}/portuguese.txt
${CMAKE_CURRENT_SOURCE_DIR}/romanian.txt
${CMAKE_CURRENT_SOURCE_DIR}/russian.txt
${CMAKE_CURRENT_SOURCE_DIR}/serbian.txt
${CMAKE_CURRENT_SOURCE_DIR}/simplified_chinese.txt
${CMAKE_CURRENT_SOURCE_DIR}/slovak.txt
${CMAKE_CURRENT_SOURCE_DIR}/slovenian.txt
${CMAKE_CURRENT_SOURCE_DIR}/spanish.txt
${CMAKE_CURRENT_SOURCE_DIR}/spanish_MX.txt
${CMAKE_CURRENT_SOURCE_DIR}/swedish.txt
${CMAKE_CURRENT_SOURCE_DIR}/tamil.txt
${CMAKE_CURRENT_SOURCE_DIR}/thai.txt
${CMAKE_CURRENT_SOURCE_DIR}/traditional_chinese.txt
${CMAKE_CURRENT_SOURCE_DIR}/turkish.txt
${CMAKE_CURRENT_SOURCE_DIR}/urdu.txt
${CMAKE_CURRENT_SOURCE_DIR}/ukrainian.txt
${CMAKE_CURRENT_SOURCE_DIR}/vietnamese.txt
${CMAKE_CURRENT_SOURCE_DIR}/welsh.txt
)
set(LANG_BINARY_DIR ${CMAKE_BINARY_DIR}/lang)
if (HOST_BINARY_DIR)
include(${HOST_BINARY_DIR}/strgen.cmake)
endif()
# Walk over all the (finished) language files, and generate a command to compile them
foreach(LANG_SOURCE_FILE IN LISTS LANG_SOURCE_FILES)
get_filename_component(LANG_SOURCE_FILE_NAME_WE ${LANG_SOURCE_FILE} NAME_WE)
set(LANG_BINARY_FILE ${LANG_BINARY_DIR}/${LANG_SOURCE_FILE_NAME_WE}.lng)
add_custom_command(OUTPUT ${LANG_BINARY_FILE}
COMMAND ${CMAKE_COMMAND} -E make_directory ${LANG_BINARY_DIR}
COMMAND strgen
-s ${CMAKE_CURRENT_SOURCE_DIR}
-d ${LANG_BINARY_DIR}
${LANG_SOURCE_FILE}
DEPENDS strgen ${MASTER_LANG_FILE}
MAIN_DEPENDENCY ${LANG_SOURCE_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Compiling language ${LANG_SOURCE_FILE_NAME_WE}"
)
list(APPEND LANG_BINARY_FILES ${LANG_BINARY_FILE})
endforeach()
# Create a new target which compiles all language files
add_custom_target(language_files
DEPENDS
${LANG_BINARY_FILES}
)
set_target_properties(language_files
PROPERTIES LANG_SOURCE_FILES "${LANG_SOURCE_FILES}"
)
set(GENERATED_BINARY_DIR ${CMAKE_BINARY_DIR}/generated)
set(TABLE_BINARY_DIR ${GENERATED_BINARY_DIR}/table)
# Generate a command and target to create the strings table
add_custom_command_timestamp(OUTPUT ${TABLE_BINARY_DIR}/strings.h
COMMAND ${CMAKE_COMMAND} -E make_directory ${TABLE_BINARY_DIR}
COMMAND strgen
-s ${CMAKE_CURRENT_SOURCE_DIR}
-d ${TABLE_BINARY_DIR}
DEPENDS strgen ${MASTER_LANG_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating table/strings.h"
)
add_custom_target_timestamp(table_strings
DEPENDS
${TABLE_BINARY_DIR}/strings.h
)
add_library(languages
INTERFACE
)
target_include_directories(languages
INTERFACE
${GENERATED_BINARY_DIR}
)
add_dependencies(languages
language_files
table_strings
)
add_library(openttd::languages ALIAS languages)
|