Skip to content

Commit

Permalink
Revert "Try to get rid of explicit Gettext dependency"
Browse files Browse the repository at this point in the history
This reverts commit 8d26343.
  • Loading branch information
houz committed Feb 11, 2015
1 parent 35f8186 commit b1c9ec8
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 16 deletions.
31 changes: 17 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,21 +204,24 @@ endif(NOT EXTERNAL_PROGRAMS_FOUND)

#need to put here do setting LOCALE_DIR variable
if(USE_NLS)
if(NOT LOCALE_DIR)
find_package(Gettext)
if(Gettext_FOUND)
if(NOT LOCALE_DIR)
SET(LOCALE_DIR "${CMAKE_INSTALL_PREFIX}/share/locale")
endif(NOT LOCALE_DIR)

if(NOT LOCALE_DIR)
message(QUIET "Set LOCALE_DIR to path to get Gettext working")
else()
find_package(Msgfmt)
if(Msgfmt_FOUND)
message(STATUS "Found msgfmt to convert language file. Translation enabled")
add_subdirectory(po)
else()
message(STATUS "Cannot find msgfmt to convert language file. Translation won't be enabled")
endif()
endif(NOT LOCALE_DIR)
endif(NOT LOCALE_DIR)

if(NOT LOCALE_DIR)
message(QUIET "Set LOCALE_DIR to path to get Gettext working")
else()
find_package(Msgfmt)
if(Msgfmt_FOUND)
message(STATUS "Found msgfmt to convert language file. Translation enabled")
add_subdirectory(po)
else()
message(STATUS "Cannot find msgfmt to convert language file. Translation won't be enabled")
endif()
endif(NOT LOCALE_DIR)
endif(Gettext_FOUND)
endif(USE_NLS)

if(NOT DEFINED RUNTIME_LOCALE_DIR)
Expand Down
42 changes: 42 additions & 0 deletions cmake/modules/FindGettext.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# - Try to find Gettext
# Once done, this will define
#
# Gettext_FOUND - system has Gettext
# Gettext_INCLUDE_DIRS - the Gettext include directories
# Gettext_LIBRARIES - link these to use Gettext
#
# See documentation on how to write CMake scripts at
# http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries

include(LibFindMacros)

# On Linux there is no pkgconfig script, but with this we force Gettext_PKGCONF_INCLUDE_DIRS to ""
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(Gettext_PKGCONF_INCLUDE_DIRS "")
else(CMAKE_SYSTEM_NAME STREQUAL "Linux")
libfind_pkg_check_modules(Gettext_PKGCONF Gettext)
endif(CMAKE_SYSTEM_NAME STREQUAL "Linux")

if(WIN32 OR APPLE)
set(Gettext_LIBRARY_SEARCH_DIRS
/opt/local/lib
/sw/local/lib
)

find_library(Gettext_LIBRARY
NAMES intl
PATHS ${Gettext_LIBRARY_SEARCH_DIRS}
HINTS ${Gettext_PKGCONF_LIBRARY_DIRS}
)

set(Gettext_PROCESS_LIBS Gettext_LIBRARY)
endif()

find_path(Gettext_INCLUDE_DIR
NAMES libintl.h
HINTS ${Gettext_PKGCONF_INCLUDE_DIRS}
PATHS /opt/local/include
)

set(Gettext_PROCESS_INCLUDES Gettext_INCLUDE_DIR)
libfind_process(Gettext)
11 changes: 9 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,15 @@ foreach(lib ${OUR_LIBS} LensFun GIO GThread GModule PangoCairo PThread Rsvg2 Lib
endforeach(lib)

if(USE_NLS)
add_definitions("-DUSE_GETTEXT")
message(STATUS "Internationalization: Enabled")
find_package(Gettext)
if(Gettext_FOUND)
include_directories(SYSTEM ${Gettext_INCLUDE_DIRS})
list(APPEND LIBS ${Gettext_LIBRARIES})
add_definitions("-DUSE_GETTEXT")
message(STATUS "Internationalization: Enabled")
else()
message(STATUS "Internationalization: Disabled (libintl not found)")
endif()
endif(USE_NLS)

if(USE_FLICKR)
Expand Down
1 change: 1 addition & 0 deletions src/cli/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <sys/time.h>
#include <unistd.h>
#include <inttypes.h>
#include <libintl.h>

static void generate_thumbnail_cache()
{
Expand Down

0 comments on commit b1c9ec8

Please sign in to comment.