Gettext rules updated.

This commit is contained in:
Kolan Sh 2015-10-19 18:27:24 +03:00
parent 16f08b6a98
commit dd44f3f616
6 changed files with 29 additions and 22 deletions

View File

@ -1,30 +1,24 @@
SET (GETTEXT_PACKAGE "${PROJECT_LOWERCASE_NAME}-${MAJOR}")
ADD_DEFINITIONS (-DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}")
# FIXME: Custom locale directory
IF (WIN32)
SET (LOCALEDIR "")
ELSE ()
SET (LOCALEDIR "${CMAKE_INSTALL_PREFIX}/share/locale")
ENDIF ()
SET (CUSTOM_LOCALEDIR "" CACHE STRING "Directory to install l10n files into")
IF (NOT CUSTOM_LOCALEDIR STREQUAL "")
SET (LOCALEDIR "${CUSTOM_LOCALEDIR}")
MESSAGE(STATUS "Using LOCALEDIR=${LOCALEDIR}")
ENDIF ()
ADD_DEFINITIONS (-DLOCALEDIR="${LOCALEDIR}")
SET (LOCALE_INSTALL_DIR "share/locale")
# by all langs
INCLUDE (MacroOptionalAddSubdirectory)
FIND_PACKAGE (Gettext REQUIRED)
MACRO_OPTIONAL_ADD_SUBDIRECTORY (langs)
# Custom locale directory
SET (LOCALEDIR "share/locale" CACHE STRING "Directory to install l10n files into")
MESSAGE(STATUS "Using LOCALEDIR=${LOCALEDIR}")
ADD_DEFINITIONS (-DLOCALEDIR="${LOCALEDIR}")
# for each language
INCLUDE (MacroSubdirList)
SUBDIRLIST (SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR})
FOREACH (subdir ${SUBDIRS})
ADD_SUBDIRECTORY (${subdir})
ENDFOREACH()
# configure a header file for Gettext
STRING (TOUPPER "${CMAKE_PROJECT_NAME}" GettextUniqueHeader)
CONFIGURE_FILE (
"gettext-config.h.in"
"${PROJECT_BINARY_DIR}/po/gettext-config.h"
"${CMAKE_CURRENT_BINARY_DIR}/gettext-config.h"
)
# check for msgmerge utility

3
GettextLangRules.cmake Normal file
View File

@ -0,0 +1,3 @@
FILE (GLOB _po_files *.po)
GET_FILENAME_COMPONENT (LANG "${CMAKE_CURRENT_SOURCE_DIR}" NAME)
GETTEXT_PROCESS_PO_FILES ("${LANG}" ALL INSTALL_DESTINATION ${LOCALEDIR} PO_FILES ${_po_files} )

10
MacroSubdirList.cmake Normal file
View File

@ -0,0 +1,10 @@
MACRO(SUBDIRLIST result curdir)
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
SET(dirlist "")
FOREACH(child ${children})
IF(IS_DIRECTORY ${curdir}/${child})
LIST(APPEND dirlist ${child})
ENDIF()
ENDFOREACH()
SET(${result} ${dirlist})
ENDMACRO()

View File

@ -13,7 +13,7 @@ VALA_PRECOMPILE (VALA_C ${BinSources}
GENERATE_HEADER
)
PKG_CHECK_MODULES (PKGS REQUIRED ${BinPkgModules})
INCLUDE_DIRECTORIES (${PKGS_INCLUDE_DIRS})
INCLUDE_DIRECTORIES (${PKGS_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}/po)
ADD_EXECUTABLE (${BinName} ${VALA_C} ${BinExtraSources})
ADD_DEFINITIONS (-DGETTEXT_PACKAGE="${PROJECT_LOWERCASE_NAME}-${MAJOR}")
TARGET_LINK_LIBRARIES (${BinName} ${PKGS_LIBRARIES} ${BinLinkLibs})

View File

@ -15,7 +15,7 @@ VALA_PRECOMPILE (VALA_C ${LibSources}
GENERATE_HEADER ${LibName}-${MAJOR}
)
PKG_CHECK_MODULES (PKGS REQUIRED ${LibPkgModules})
INCLUDE_DIRECTORIES (${PKGS_INCLUDE_DIRS})
INCLUDE_DIRECTORIES (${PKGS_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}/po)
ADD_LIBRARY (${LibName} SHARED ${VALA_C} ${LibExtraSources})
ADD_DEFINITIONS (-DGETTEXT_PACKAGE="${PROJECT_LOWERCASE_NAME}-${MAJOR}")
TARGET_LINK_LIBRARIES (${LibName} ${PKGS_LIBRARIES} ${LibLinkLibs})

View File

@ -11,7 +11,7 @@ VALA_PRECOMPILE (VALA_C ${PluginSources}
GENERATE_HEADER
)
PKG_CHECK_MODULES (PKGS REQUIRED ${PluginPkgModules})
INCLUDE_DIRECTORIES (${PKGS_INCLUDE_DIRS})
INCLUDE_DIRECTORIES (${PKGS_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}/po)
ADD_LIBRARY (${PluginName} SHARED ${VALA_C} ${PluginExtraSources})
ADD_DEFINITIONS (-DGETTEXT_PACKAGE="${PROJECT_LOWERCASE_NAME}-${MAJOR}")
TARGET_LINK_LIBRARIES (${PluginName} ${PKGS_LIBRARIES} ${PluginLinkLibs})