Skip to content

Commit

Permalink
Merge pull request #79 from sharkwouter/build-translation-support-if-…
Browse files Browse the repository at this point in the history
…available

Build translation support by default if tinygettext is available
  • Loading branch information
sharkwouter authored Oct 8, 2024
2 parents 588ab93 + caacbb6 commit dde5e7c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ pkg_search_module(SDL2_IMAGE REQUIRED SDL2_image)
pkg_search_module(SDL2_MIXER REQUIRED SDL2_mixer)
pkg_search_module(SDL2_TTF REQUIRED SDL2_ttf)
pkg_search_module(JSONCPP REQUIRED jsoncpp)
pkg_search_module(TINYGETTEXT QUIET tinygettext)

# Enable translation support by default if the tinygettext library is found
set(TRANSLATION_SUPPORT_DEFAULT OFF)
if(TINYGETTEXT_FOUND)
message("-- Found tinygettext library")
set(TRANSLATION_SUPPORT_DEFAULT ON)
endif()
option(TRANSLATION_SUPPORT "Add support for loading translations, requires tinygettext" ${TRANSLATION_SUPPORT_DEFAULT})

# Link libraries
if(BUILD_STATIC)
Expand Down Expand Up @@ -63,18 +71,17 @@ include_directories(
${JSONCPP_INCLUDE_DIRS}
)

option(TRANSLATION_SUPPORT "Add support for loading translations, requires tinygettext" OFF)

# Create translations
if(TRANSLATION_SUPPORT)
pkg_search_module(TINYGETTEXT REQUIRED tinygettext)
message("-- Building with translation support")
if(BUILD_STATIC)
target_link_libraries(${PROJECT_NAME} PRIVATE ${TINYGETTEXT_STATIC_LIBRARIES})
else()
target_link_libraries(${PROJECT_NAME} PRIVATE ${TINYGETTEXT_LIBRARIES})
endif()

add_compile_definitions(TRANSLATION_SUPPORT=1)
else()
message("-- Building without translation support")
endif()

# Set asset paths
Expand Down

0 comments on commit dde5e7c

Please sign in to comment.