mirror of
https://github.com/weechat/weechat.git
synced 2026-06-12 14:14:48 +02:00
core: fix build error if CMake option ENABLE_NLS is turned to off or if required dependencies are not found (closes #2026)
This commit is contained in:
+8
-14
@@ -201,20 +201,6 @@ if(ENABLE_LARGEFILE)
|
||||
add_definitions(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -D_LARGE_FILES)
|
||||
endif()
|
||||
|
||||
# Check for Gettext
|
||||
if(ENABLE_NLS)
|
||||
find_package(Gettext)
|
||||
if(GETTEXT_FOUND)
|
||||
add_definitions(-DENABLE_NLS)
|
||||
find_package(Intl)
|
||||
if(Intl_FOUND)
|
||||
list(APPEND EXTRA_LIBS "${Intl_LIBRARIES}")
|
||||
endif()
|
||||
else()
|
||||
message(SEND_ERROR "Gettext not found")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Check for libgcrypt
|
||||
find_package(GCRYPT REQUIRED)
|
||||
add_definitions(-DHAVE_GCRYPT)
|
||||
@@ -262,7 +248,15 @@ endif()
|
||||
add_subdirectory(icons)
|
||||
|
||||
if(ENABLE_NLS)
|
||||
find_package(Gettext REQUIRED)
|
||||
add_definitions(-DENABLE_NLS)
|
||||
find_package(Intl)
|
||||
if(Intl_FOUND)
|
||||
list(APPEND EXTRA_LIBS "${Intl_LIBRARIES}")
|
||||
endif()
|
||||
add_subdirectory(po)
|
||||
else()
|
||||
add_custom_target(translations COMMAND true)
|
||||
endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
@@ -75,6 +75,7 @@ Tests::
|
||||
|
||||
Build::
|
||||
|
||||
* core: fix build error if CMake option ENABLE_NLS is turned to off or if required dependencies are not found (issue #2026)
|
||||
* core, logger, relay: make zstd dependency optional (issue #2024)
|
||||
|
||||
[[v4.0.5]]
|
||||
|
||||
+52
-56
@@ -17,6 +17,11 @@
|
||||
# along with WeeChat. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
# Check for programs xgettext, msgmerge and msgfmt
|
||||
find_program(XGETTEXT_EXECUTABLE xgettext REQUIRED)
|
||||
find_program(MSGMERGE_EXECUTABLE msgmerge REQUIRED)
|
||||
find_program(MSGFMT_EXECUTABLE msgfmt REQUIRED)
|
||||
|
||||
set(PO_FILES
|
||||
cs.po
|
||||
de.po
|
||||
@@ -39,70 +44,61 @@ set(POT_FILE_PATH "${CMAKE_CURRENT_BINARY_DIR}/${POT_FILE}")
|
||||
|
||||
include(srcfiles.cmake)
|
||||
|
||||
# Looking for xgettext, msgmerge and msgfmt
|
||||
find_program(XGETTEXT_EXECUTABLE xgettext)
|
||||
find_program(MSGMERGE_EXECUTABLE msgmerge)
|
||||
find_program(MSGFMT_EXECUTABLE msgfmt)
|
||||
# Create PO template file weechat.pot
|
||||
set(SRC_FILES)
|
||||
set(POT_DEPENDS)
|
||||
|
||||
if(XGETTEXT_EXECUTABLE AND MSGMERGE_EXECUTABLE AND MSGFMT_EXECUTABLE)
|
||||
foreach(srcfile ${WEECHAT_SOURCES})
|
||||
set(SRC_FILES ${SRC_FILES} ${srcfile})
|
||||
set(POT_DEPENDS ${POT_DEPENDS} "${CMAKE_SOURCE_DIR}/${srcfile}")
|
||||
endforeach()
|
||||
|
||||
# Create PO template file weechat.pot
|
||||
set(SRC_FILES)
|
||||
set(POT_DEPENDS)
|
||||
add_custom_command(
|
||||
OUTPUT "${POT_FILE_PATH}"
|
||||
COMMAND "${XGETTEXT_EXECUTABLE}"
|
||||
ARGS -o "${POT_FILE_PATH}" --add-comments='TRANSLATORS:' --keyword='_' --keyword='weechat_gettext' --keyword='N_' --keyword='NG_:1,2' --keyword='weechat_ngettext:1,2' --no-location --from-code=UTF-8 --directory="${CMAKE_SOURCE_DIR}" --package-name='WeeChat' --package-version=${VERSION} --msgid-bugs-address=${BUGS_ADDRESS} --copyright-holder='NAME' ${SRC_FILES}
|
||||
DEPENDS ${POT_DEPENDS}
|
||||
COMMENT "Generating ${POT_FILE}"
|
||||
)
|
||||
|
||||
foreach(srcfile ${WEECHAT_SOURCES})
|
||||
set(SRC_FILES ${SRC_FILES} ${srcfile})
|
||||
set(POT_DEPENDS ${POT_DEPENDS} "${CMAKE_SOURCE_DIR}/${srcfile}")
|
||||
endforeach()
|
||||
set(MO_FILES)
|
||||
set(UPDATE_PO_TARGETS)
|
||||
foreach(pofile ${PO_FILES})
|
||||
get_filename_component(polang ${pofile} NAME_WE)
|
||||
|
||||
# Compile .po files in build directory (to binary .mo files)
|
||||
set(modir "${CMAKE_CURRENT_BINARY_DIR}/${polang}/LC_MESSAGES")
|
||||
file(MAKE_DIRECTORY "${modir}")
|
||||
set(mofile "${modir}/${PROJECT_NAME}.mo")
|
||||
add_custom_command(
|
||||
OUTPUT "${POT_FILE_PATH}"
|
||||
COMMAND "${XGETTEXT_EXECUTABLE}"
|
||||
ARGS -o "${POT_FILE_PATH}" --add-comments='TRANSLATORS:' --keyword='_' --keyword='weechat_gettext' --keyword='N_' --keyword='NG_:1,2' --keyword='weechat_ngettext:1,2' --no-location --from-code=UTF-8 --directory="${CMAKE_SOURCE_DIR}" --package-name='WeeChat' --package-version=${VERSION} --msgid-bugs-address=${BUGS_ADDRESS} --copyright-holder='NAME' ${SRC_FILES}
|
||||
DEPENDS ${POT_DEPENDS}
|
||||
COMMENT "Generating ${POT_FILE}"
|
||||
OUTPUT "${mofile}"
|
||||
COMMAND "${MSGMERGE_EXECUTABLE}" ARGS --quiet -o "${CMAKE_CURRENT_BINARY_DIR}/${pofile}" "${CMAKE_CURRENT_SOURCE_DIR}/${pofile}" ${POT_FILE_PATH}
|
||||
COMMAND "${MSGFMT_EXECUTABLE}" ARGS -o "${mofile}" "${CMAKE_CURRENT_BINARY_DIR}/${pofile}"
|
||||
COMMAND "${MSGFMT_EXECUTABLE}" ARGS -c --statistics --verbose --output-file=/dev/null "${CMAKE_CURRENT_BINARY_DIR}/${pofile}"
|
||||
DEPENDS "${POT_FILE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/${pofile}"
|
||||
COMMENT "Compiling ${polang}.po"
|
||||
)
|
||||
|
||||
set(MO_FILES)
|
||||
set(UPDATE_PO_TARGETS)
|
||||
foreach(pofile ${PO_FILES})
|
||||
get_filename_component(polang ${pofile} NAME_WE)
|
||||
|
||||
# Compile .po files in build directory (to binary .mo files)
|
||||
set(modir "${CMAKE_CURRENT_BINARY_DIR}/${polang}/LC_MESSAGES")
|
||||
file(MAKE_DIRECTORY "${modir}")
|
||||
set(mofile "${modir}/${PROJECT_NAME}.mo")
|
||||
add_custom_command(
|
||||
OUTPUT "${mofile}"
|
||||
COMMAND "${MSGMERGE_EXECUTABLE}" ARGS --quiet -o "${CMAKE_CURRENT_BINARY_DIR}/${pofile}" "${CMAKE_CURRENT_SOURCE_DIR}/${pofile}" ${POT_FILE_PATH}
|
||||
COMMAND "${MSGFMT_EXECUTABLE}" ARGS -o "${mofile}" "${CMAKE_CURRENT_BINARY_DIR}/${pofile}"
|
||||
COMMAND "${MSGFMT_EXECUTABLE}" ARGS -c --statistics --verbose --output-file=/dev/null "${CMAKE_CURRENT_BINARY_DIR}/${pofile}"
|
||||
DEPENDS "${POT_FILE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/${pofile}"
|
||||
COMMENT "Compiling ${polang}.po"
|
||||
)
|
||||
|
||||
# Update .po files in source directory (if needed)
|
||||
add_custom_target(
|
||||
update-${pofile}
|
||||
COMMAND "${MSGMERGE_EXECUTABLE}" --quiet --update --previous --backup=none "${CMAKE_CURRENT_SOURCE_DIR}/${pofile}" "${POT_FILE_PATH}"
|
||||
COMMENT "Updating ${polang}.po"
|
||||
)
|
||||
set(UPDATE_PO_TARGETS ${UPDATE_PO_TARGETS} update-${pofile})
|
||||
|
||||
install(FILES "${mofile}" DESTINATION "${LOCALEDIR}/${polang}/LC_MESSAGES")
|
||||
set(MO_FILES ${MO_FILES} ${mofile})
|
||||
endforeach()
|
||||
|
||||
add_custom_target(translations ALL DEPENDS ${MO_FILES})
|
||||
|
||||
# Update weechat.pot in source directory (if needed)
|
||||
# Update .po files in source directory (if needed)
|
||||
add_custom_target(
|
||||
update-${POT_FILE}
|
||||
COMMAND "${MSGMERGE_EXECUTABLE}" --quiet --update --backup=none "${CMAKE_CURRENT_SOURCE_DIR}/${POT_FILE}" "${POT_FILE_PATH}"
|
||||
COMMENT "Updating ${POT_FILE}"
|
||||
update-${pofile}
|
||||
COMMAND "${MSGMERGE_EXECUTABLE}" --quiet --update --previous --backup=none "${CMAKE_CURRENT_SOURCE_DIR}/${pofile}" "${POT_FILE_PATH}"
|
||||
COMMENT "Updating ${polang}.po"
|
||||
)
|
||||
set(UPDATE_PO_TARGETS ${UPDATE_PO_TARGETS} update-${pofile})
|
||||
|
||||
# Update all .po and weechat.pot in source directory (if needed)
|
||||
add_custom_target(update-po DEPENDS update-${POT_FILE} ${UPDATE_PO_TARGETS})
|
||||
install(FILES "${mofile}" DESTINATION "${LOCALEDIR}/${polang}/LC_MESSAGES")
|
||||
set(MO_FILES ${MO_FILES} ${mofile})
|
||||
endforeach()
|
||||
|
||||
endif()
|
||||
add_custom_target(translations ALL DEPENDS ${MO_FILES})
|
||||
|
||||
# Update weechat.pot in source directory (if needed)
|
||||
add_custom_target(
|
||||
update-${POT_FILE}
|
||||
COMMAND "${MSGMERGE_EXECUTABLE}" --quiet --update --backup=none "${CMAKE_CURRENT_SOURCE_DIR}/${POT_FILE}" "${POT_FILE_PATH}"
|
||||
COMMENT "Updating ${POT_FILE}"
|
||||
)
|
||||
|
||||
# Update all .po and weechat.pot in source directory (if needed)
|
||||
add_custom_target(update-po DEPENDS update-${POT_FILE} ${UPDATE_PO_TARGETS})
|
||||
|
||||
Reference in New Issue
Block a user