Skip to content

Commit

Permalink
Adds FindIntl.cmake for supporting earlier versions of CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
anuragagarwal561994 committed Aug 18, 2016
1 parent e4b4c45 commit c61454f
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 7 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ if (${ONION_USE_SYSTEMD})
endif(${ONION_USE_SYSTEMD})

find_package(Intl)
if (Intl_FOUND)
if (INTL_FOUND)
set(GETTEXT_ENABLED true)
include_directories(${Intl_INCLUDE_DIRS})
include_directories(${INTL_INCLUDE_DIRS})
message(STATUS "gettext support is compiled in otemplate.")
else (Intl_FOUND)
else (INTL_FOUND)
message(STATUS "No gettext support.")
endif (Intl_FOUND)
endif (INTL_FOUND)

FIND_PROGRAM(MD2MAN md2man-roff)
if(MD2MAN)
Expand Down
64 changes: 64 additions & 0 deletions CMakeModules/FindIntl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#.rst:
# FindIntl
# --------
#
# Find the Gettext libintl headers and libraries.
#
# This module reports information about the Gettext libintl
# installation in several variables. General variables::
#
# INTL_FOUND - true if the libintl headers and libraries were found
# INTL_INCLUDE_DIRS - the directory containing the libintl headers
# INTL_LIBRARIES - libintl libraries to be linked
#
# The following cache variables may also be set::
#
# INTL_INCLUDE_DIR - the directory containing the libintl headers
# INTL_LIBRARY - the libintl library (if any)
#
# .. note::
# On some platforms, such as Linux with GNU libc, the gettext
# functions are present in the C standard library and libintl
# is not required. ``INTL_LIBRARIES`` will be empty in this
# case.
#
# .. note::
# If you wish to use the Gettext tools (``msgmerge``,
# ``msgfmt``, etc.), use :module:`FindGettext`.


# Written by Roger Leigh <[email protected]>

#=============================================================================
# Copyright 2014 Roger Leigh <[email protected]>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)

# Find include directory
find_path(INTL_INCLUDE_DIR
NAMES "libintl.h"
DOC "libintl include directory")
mark_as_advanced(INTL_INCLUDE_DIR)

# Find all INTL libraries
find_library(INTL_LIBRARY "intl"
DOC "libintl libraries (if not in the C library)")
mark_as_advanced(INTL_LIBRARY)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Intl
REQUIRED_VARS INTL_INCLUDE_DIR INTL_LIBRARY
FAIL_MESSAGE "Failed to find Gettext libintl")

if (INTL_FOUND)
set(INTL_INCLUDE_DIRS "${INTL_INCLUDE_DIR}")
set(INTL_LIBRARIES "${INTL_LIBRARY}")
endif ()
2 changes: 1 addition & 1 deletion examples/ofileserver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ add_executable(ofileserver fileserver.c fileserver_html.c)
target_link_libraries(ofileserver onion_static m)

if (GETTEXT_ENABLED)
target_link_libraries(ofileserver ${Intl_LIBRARIES})
target_link_libraries(ofileserver ${INTL_LIBRARIES})
endif (GETTEXT_ENABLED)

find_package(ZLIB)
Expand Down
2 changes: 1 addition & 1 deletion tests/01-internal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ add_custom_command(
)
target_link_libraries(13-otemplates onion)
if (GETTEXT_ENABLED)
target_link_libraries(13-otemplates ${Intl_LIBRARIES})
target_link_libraries(13-otemplates ${INTL_LIBRARIES})
endif (GETTEXT_ENABLED)
add_test(internal-otemplates 13-otemplates)
endif (OTEMPLATE)
Expand Down
2 changes: 1 addition & 1 deletion tests/07-tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ add_custom_command(
add_executable(01-otemplate 01-otemplate.c test_html.c external_html.c extended_html.c base_html.c)
target_link_libraries(01-otemplate onion_static)
if (GETTEXT_ENABLED)
target_link_libraries(01-otemplate ${Intl_LIBRARIES})
target_link_libraries(01-otemplate ${INTL_LIBRARIES})
endif (GETTEXT_ENABLED)

# add_executable(02-test 02-test.cpp test_html.c external_html.c extended_html.c base_html.c)
Expand Down

0 comments on commit c61454f

Please sign in to comment.