Skip to content

Commit

Permalink
Installing translations using cmake (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
buschmann23 committed Nov 30, 2021
1 parent ff75197 commit 73e246a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ project(libfuoten
LANGUAGES CXX)

find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Network Sql REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} 5.6.0 REQUIRED COMPONENTS Core Network Sql)
find_package(Qt${QT_VERSION_MAJOR} 5.6.0 REQUIRED COMPONENTS Core Network Sql LinguistTools)

# Include our cmake modules
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
Expand Down Expand Up @@ -40,6 +40,7 @@ option(BUILD_SHARED_LIBS "Enable the build of shared libraries" ON)
option(ENABLE_MAINTAINER_FLAGS "Enables some build flags used for development" OFF)
option(BUILD_DOCS "Enable the build of doxygen docs" OFF)
option(BUILD_DOCS_QUIET "Tell doxygen to be quiet while building the documentation." OFF)
set(I18NDIR "${CMAKE_INSTALL_FULL_DATADIR}/libFuotenQt${QT_VERSION_MAJOR}/translations" CACHE PATH "Directory to install translations")

configure_file(${CMAKE_MODULE_PATH}/fuoten-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/FuotenQt${QT_VERSION_MAJOR}Config.cmake
Expand Down Expand Up @@ -73,6 +74,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/FuotenQt${QT_VERSION_MAJOR}Core.pc
)

add_subdirectory(Fuoten)
add_subdirectory(translations)

if (BUILD_DOCS)
if (CMAKE_VERSION VERSION_LESS "3.12.3")
Expand Down
1 change: 1 addition & 0 deletions Fuoten/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ target_compile_definitions(FuotenQt${QT_VERSION_MAJOR}
QT_USE_FAST_OPERATOR_PLUS
QT_DISABLE_DEPRECATED_BEFORE=0x050500
FUOTEN_VERSION="${PROJECT_VERSION}"
FUOTEN_I18NDIR="${I18NDIR}"
)

if(ENABLE_MAINTAINER_FLAGS)
Expand Down
19 changes: 19 additions & 0 deletions translations/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set(TS_FILES libfuoten_da.ts
libfuoten_de.ts
libfuoten_el.ts
libfuoten_en_GB.ts
libfuoten_en_US.ts
libfuoten_fr.ts
libfuoten_it.ts
libfuoten_nl.ts
libfuoten_sv.ts
libfuoten_zh_CN.ts)

qt5_add_translation(QM_FILES ${TS_FILES})
add_custom_target(translations ALL
DEPENDS ${QM_FILES}
COMMENT "Compiles translation messages")

install(FILES ${QM_FILES}
DESTINATION ${I18NDIR}
COMPONENT runtime)

0 comments on commit 73e246a

Please sign in to comment.