From 1bc6bf59fef1a7a58a519feb471527c52ef7c767 Mon Sep 17 00:00:00 2001 From: Snaipe Date: Tue, 28 Jul 2015 22:44:28 +0200 Subject: [PATCH] Integrated gettext into the build system --- ...indGettext.cmake => GettextTranslate.cmake} | 0 CMakeLists.txt | 18 +++++++++++++++--- po/CMakeLists.txt | 1 + po/Makevars | 2 +- po/fr.po | 2 +- src/config.h.in | 6 +++++- 6 files changed, 23 insertions(+), 6 deletions(-) rename .cmake/Modules/{FindGettext.cmake => GettextTranslate.cmake} (100%) create mode 100644 po/CMakeLists.txt diff --git a/.cmake/Modules/FindGettext.cmake b/.cmake/Modules/GettextTranslate.cmake similarity index 100% rename from .cmake/Modules/FindGettext.cmake rename to .cmake/Modules/GettextTranslate.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 730257c..b16eb48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,17 +2,30 @@ cmake_minimum_required(VERSION 3.2.2) cmake_policy(SET CMP0048 NEW) project(Criterion VERSION 1.2.2) +get_cmake_property(_variableNames VARIABLES) +foreach (_variableName ${_variableNames}) + message(STATUS "${_variableName}=${${_variableName}}") +endforeach() +set(LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale) +set(GettextTranslate_ALL) +set(GettextTranslate_GMO_BINARY) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/.cmake/Modules/") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -g -std=gnu11") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-no-undefined") +find_package(Gettext) +if (GETTEXT_FOUND) + include(GettextTranslate) + add_subdirectory(po) + set(ENABLE_NLS 1) +endif () + include(CheckLibraryExists) CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME) find_package(PCRE) -find_package(Gettext REQUIRED) find_package(Libcsptr) configure_file( @@ -63,7 +76,6 @@ set(INTERFACE_FILES ) add_subdirectory(samples) -#add_subdirectory(po) include_directories(include src) add_library(criterion SHARED ${SOURCE_FILES} ${INTERFACE_FILES}) @@ -80,7 +92,7 @@ if (PCRE_FOUND) target_link_libraries(criterion pcre) endif() -install(FILES ${INTERFACE_FILES} DESTINATION include/insight) +install(FILES ${INTERFACE_FILES} DESTINATION include/criterion) install(TARGETS criterion LIBRARY DESTINATION lib ) diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt new file mode 100644 index 0000000..892654a --- /dev/null +++ b/po/CMakeLists.txt @@ -0,0 +1 @@ +GettextTranslate() diff --git a/po/Makevars b/po/Makevars index 70daf30..036417c 100644 --- a/po/Makevars +++ b/po/Makevars @@ -1,7 +1,7 @@ # Makefile variables for PO directory in any package using GNU gettext. # Usually the message domain is the same as the package name. -DOMAIN = $(PACKAGE) +DOMAIN = Criterion # These two variables depend on the location of this directory. subdir = po diff --git a/po/fr.po b/po/fr.po index f9627f7..7727e40 100644 --- a/po/fr.po +++ b/po/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: criterion 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-06-30 12:07+0200\n" +"POT-Creation-Date: 2015-07-28 22:17+0200\n" "PO-Revision-Date: 2015-04-03 17:58+0200\n" "Last-Translator: \n" "Language-Team: French\n" diff --git a/src/config.h.in b/src/config.h.in index 881c4b5..194430a 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -1,6 +1,10 @@ #ifndef CONFIG_H_IN_ # define CONFIG_H_IN_ -# define VERSION "${PACKAGE_VERSION}" +#cmakedefine ENABLE_NLS @ENABLE_NLS@ + +# define LOCALEDIR "${LOCALEDIR}" +# define PACKAGE "${PROJECT_NAME}" +# define VERSION "${PROJECT_VERSION}" #endif /* !CONFIG_H_IN_ */