CMake: link with Intl when necessary for kfreebsd of non-glibc libs like alpine

* non Glibc system linking with Intl library may be needed whenGettext support is enabled.
* https://git.alpinelinux.org/aports/tree/community/minetest/0001-CMake-link-with-Intl-when-necessary.patch
* Fixes: clientlauncher.cpp:(.text+0xcac): undefined reference to `libintl_gettext'
stable-5.2-namespace
mckaygerhard 2021-11-22 00:58:43 -04:00
parent bdec7dde0b
commit df01036c3f
1 changed files with 10 additions and 1 deletions

View File

@ -70,6 +70,14 @@ if(ENABLE_GETTEXT)
endif()
set(USE_GETTEXT TRUE)
message(STATUS "GetText enabled; locales found: ${GETTEXT_AVAILABLE_LOCALES}")
# On some platforms, such as Linux with GNU libc, the gettext
# functions are present in the C standard library and libintl
# is not required. For other libc (uClibc-ng or musl or older debians)
# libintl may be required.
find_package(Intl)
if(NOT Intl_LIBRARIES STREQUAL "")
message(STATUS "GetText Intl : ${Intl_LIBRARIES}")
endif()
endif(GETTEXT_FOUND)
else()
mark_as_advanced(GETTEXT_ICONV_DLL GETTEXT_INCLUDE_DIR GETTEXT_LIBRARY GETTEXT_MSGFMT)
@ -559,6 +567,7 @@ if(BUILD_CLIENT)
if(USE_GETTEXT)
target_link_libraries(
${PROJECT_NAME}${VERSION_MAJOR}
${Intl_LIBRARIES}
${GETTEXT_LIBRARY}
)
endif()
@ -613,7 +622,7 @@ if(BUILD_SERVER)
set_target_properties(${PROJECT_NAME}${VERSION_MAJOR}server PROPERTIES
COMPILE_DEFINITIONS "SERVER")
if (USE_GETTEXT)
target_link_libraries(${PROJECT_NAME}${VERSION_MAJOR}server ${GETTEXT_LIBRARY})
target_link_libraries(${PROJECT_NAME}${VERSION_MAJOR}server ${Intl_LIBRARIES} ${GETTEXT_LIBRARY})
endif()
if (USE_CURSES)
target_link_libraries(${PROJECT_NAME}${VERSION_MAJOR}server ${CURSES_LIBRARIES})