Skip to content

Commit

Permalink
Build translation support by default if tinygettext is available
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkwouter committed Oct 8, 2024
1 parent 588ab93 commit caacbb6
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 caacbb6

Please sign in to comment.