Skip to content

Commit

Permalink
add static import of tinygettext
Browse files Browse the repository at this point in the history
  • Loading branch information
sommer committed Jan 21, 2012
1 parent d67e254 commit adc1067
Show file tree
Hide file tree
Showing 39 changed files with 6,052 additions and 0 deletions.
177 changes: 177 additions & 0 deletions external/tinygettext/CMakeLists.txt
@@ -0,0 +1,177 @@
#
# TinyGetText build script
# Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#


#
# INSTRUCTIONS:
# -------------
#
# Create a directory build/ and change to it. Run
#
# cmake ..
#
# This creates a set of Makefiles to build the project. Run
#
# make
#


CMAKE_POLICY(SET CMP0005 NEW)

## Project name to use as command prefix

PROJECT(tinygettext)
SET(VERSION "0.1")

### CMake configuration

CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
IF(COMMAND cmake_policy)
CMAKE_POLICY(SET CMP0003 NEW)
ENDIF(COMMAND cmake_policy)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${tinygettext_SOURCE_DIR})

# move some config clutter to the advanced section
MARK_AS_ADVANCED(
CMAKE_BACKWARDS_COMPATIBILITY
CMAKE_BUILD_TYPE
CMAKE_INSTALL_PREFIX
EXECUTABLE_OUTPUT_PATH
CMAKE_OSX_ARCHITECTURES
CMAKE_OSX_SYSROOT
)

## Reveal library type choice to users
OPTION(BUILD_SHARED_LIBS "Produce dynamic library instead of static archive" ON)

## Add iconv to include directories

FIND_PACKAGE(ICONV REQUIRED)
INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})

## Check iconv_const

INCLUDE(CheckCXXSourceCompiles)

SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ICONV_INCLUDE_DIR})
CHECK_CXX_SOURCE_COMPILES(
"
#include <iconv.h>
// this declaration will fail when there already exists a non const char** version which returns size_t
double iconv(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
int main() { return 0; }
"
HAVE_ICONV_CONST
)

# TODO: better way of config

IF(HAVE_ICONV_CONST)
ADD_DEFINITIONS(-DHAVE_ICONV_CONST)
ELSE(HAVE_ICONV_CONST)
REMOVE_DEFINITIONS(-DHAVE_ICONV_CONST)
ENDIF(HAVE_ICONV_CONST)

## TinyGetText library compilation

## build list of source files

FILE(GLOB TINYGETTEXT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} tinygettext/*.cpp)
FILE(GLOB TINYGETTEXT_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} tinygettext/*.hpp)

## define a target for building the library

ADD_LIBRARY(tinygettext ${TINYGETTEXT_SOURCES})

## Add tinygettext dir to search path

INCLUDE_DIRECTORIES(${tinygettext_SOURCE_DIR})

## Debug options

OPTION(WERROR "Stops on first compiler warning in debug mode" OFF)
IF(CMAKE_COMPILER_IS_GNUCC)
ADD_DEFINITIONS(-O3 -Wall -Wextra -Weffc++ -pedantic)
# -ansi fails in MinGW
OPTION(WARNINGS "Enable long list of warnings for compiler to check" ON)
IF(WARNINGS)
ADD_DEFINITIONS(
-Wabi -Wctor-dtor-privacy
-Wstrict-null-sentinel
-Wold-style-cast
-Woverloaded-virtual
-Wsign-promo -Wswitch-enum
-Wcast-align -Wcast-qual
-Wdisabled-optimization
-Wfloat-equal
-Wformat=2
-Winit-self
-Winvalid-pch -Wunsafe-loop-optimizations
-Wlogical-op
-Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn
-Wpacked
-Wredundant-decls
-Wshadow
-Wsign-conversion -Wstack-protector
-Wstrict-overflow=5
-Wswitch-default -Wswitch-enum
-Wundef)
# Still left:
# -Wconversion (find alternative to using toupper(int) on char)
# -Wpadded (DictionaryManager has a bool that sticks out)
ENDIF(WARNINGS)
IF(WERROR)
ADD_DEFINITIONS(-Werror)
ENDIF(WERROR)
ENDIF(CMAKE_COMPILER_IS_GNUCC)

## Extra definitions

ADD_DEFINITIONS(-DVERSION=\\\"${VERSION}\\\")

## Generate test executables in the right place

SET(EXECUTABLE_OUTPUT_PATH ${tinygettext_BINARY_DIR}/test)

## Build tinygettext tests

FOREACH(TEST tinygettext_test po_parser_test)
## Add target for tinygettext test
ADD_EXECUTABLE(${TEST} test/${TEST}.cpp)
## Link with tinygettext library
TARGET_LINK_LIBRARIES(${TEST} tinygettext)
TARGET_LINK_LIBRARIES(${TEST} ${ICONV_LIBRARY})
ENDFOREACH(TEST)

## Install tinygettext

# use standardized variable name
SET(LIB_SUBDIR "lib${LIB_SUFFIX}"
CACHE STRING "Subdirectory of prefix into which libraries are installed (e.g., lib32, lib64)")

## prepare tinygettext.pc
CONFIGURE_FILE(tinygettext.pc.in tinygettext.pc @ONLY)

INSTALL(TARGETS tinygettext
ARCHIVE DESTINATION ${LIB_SUBDIR}
LIBRARY DESTINATION ${LIB_SUBDIR})
INSTALL(FILES ${TINYGETTEXT_HEADERS}
DESTINATION include/tinygettext)
INSTALL(FILES ${tinygettext_BINARY_DIR}/tinygettext.pc
DESTINATION ${LIB_SUBDIR}/pkgconfig)
100 changes: 100 additions & 0 deletions external/tinygettext/FindICONV.cmake
@@ -0,0 +1,100 @@
#
# Copyright (c) 2006, Peter Kümmel, <syntheticpp@gmx.net>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)

if (ICONV_INCLUDE_DIR)
# Already in cache, be silent
set(ICONV_FIND_QUIETLY TRUE)
endif()

find_path(ICONV_INCLUDE_DIR iconv.h
/usr/include
/usr/local/include)

set(POTENTIAL_ICONV_LIBS iconv libiconv libiconv2)

find_library(ICONV_LIBRARY NAMES ${POTENTIAL_ICONV_LIBS}
PATHS /usr/lib /usr/local/lib)

if(WIN32)
set(ICONV_DLL_NAMES iconv.dll libiconv.dll libiconv2.dll)
find_file(ICONV_DLL
NAMES ${ICONV_DLL_NAMES}
PATHS ENV PATH
NO_DEFAULT_PATH)
find_file(ICONV_DLL_HELP
NAMES ${ICONV_DLL_NAMES}
PATHS ENV PATH
${ICONV_INCLUDE_DIR}/../bin)
if(ICONV_FIND_REQUIRED)
if(NOT ICONV_DLL AND NOT ICONV_DLL_HELP)
message(FATAL_ERROR "Could not find iconv.dll, please add correct your PATH environment variable")
endif()
if(NOT ICONV_DLL AND ICONV_DLL_HELP)
get_filename_component(ICONV_DLL_HELP ${ICONV_DLL_HELP} PATH)
message(STATUS)
message(STATUS "Could not find iconv.dll in standard search path, please add ")
message(STATUS "${ICONV_DLL_HELP}")
message(STATUS "to your PATH environment variable.")
message(STATUS)
message(FATAL_ERROR "exit cmake")
endif()
endif()
if(ICONV_INCLUDE_DIR AND ICONV_LIBRARY AND ICONV_DLL)
set(ICONV_FOUND TRUE)
endif()
else()
include(CheckFunctionExists)
check_function_exists(iconv HAVE_ICONV_IN_LIBC)
if(ICONV_INCLUDE_DIR AND HAVE_ICONV_IN_LIBC)
set(ICONV_FOUND TRUE)
set(ICONV_LIBRARY CACHE TYPE STRING FORCE)
endif()
if(ICONV_INCLUDE_DIR AND ICONV_LIBRARY)
set(ICONV_FOUND TRUE)
endif()
endif()



if(ICONV_FOUND)
if(NOT ICONV_FIND_QUIETLY)
message(STATUS "Found iconv library: ${ICONV_LIBRARY}")
#message(STATUS "Found iconv dll : ${ICONV_DLL}")
endif()
else()
if(ICONV_FIND_REQUIRED)
message(STATUS "Looked for iconv library named ${POTENTIAL_ICONV_LIBS}.")
message(STATUS "Found no acceptable iconv library. This is fatal.")
message(STATUS "iconv header: ${ICONV_INCLUDE_DIR}")
message(STATUS "iconv lib : ${ICONV_LIBRARY}")
message(FATAL_ERROR "Could NOT find iconv library")
endif()
endif()

mark_as_advanced(ICONV_LIBRARY ICONV_INCLUDE_DIR)
6 changes: 6 additions & 0 deletions external/tinygettext/NEWS
@@ -0,0 +1,6 @@
tinygettext 0.0.1 - (??. Feb 2009)
==================================

* initial release

# EOF #
21 changes: 21 additions & 0 deletions external/tinygettext/README
@@ -0,0 +1,21 @@
tinygettext
===========

tinygettext is a minimal gettext() replacement written in C++. It can
read .po files directly and doesn't need .mo files generated from .po.
It also can read the .po files from arbitary locations, so its much
better suited for non-Unix systems and situations in which one wants
to store or distrubite .po files seperatly from the software itself.



Detecting the locale setting
============================

Different operating systems store the default locale in different
places; a portable way to find it is provided by FindLocale:

* http://icculus.org/~aspirin/findlocale/


# EOF #
37 changes: 37 additions & 0 deletions external/tinygettext/SConstruct
@@ -0,0 +1,37 @@
# -*- python -*-

env = Environment(CXXFLAGS=['-O0',
'-g3',
'-Wall',
'-Wcast-qual',
'-Wconversion',
'-Weffc++',
'-Werror',
'-Wextra',
'-Winit-self',
'-Wno-unused-parameter',
'-Wnon-virtual-dtor',
'-Wshadow',
'-ansi',
'-pedantic',
],
CPPPATH=['tinygettext', '.'])

# env.ParseConfig("sdl-config --cflags --libs")
# env['CPPDEFINES'] += HAVE_SDL

libtinygettext = env.StaticLibrary('tinygettext/tinygettext',
['tinygettext/tinygettext.cpp',
'tinygettext/language.cpp',
'tinygettext/plural_forms.cpp',
'tinygettext/dictionary.cpp',
'tinygettext/dictionary_manager.cpp',
'tinygettext/unix_file_system.cpp',
'tinygettext/po_parser.cpp',
'tinygettext/iconv.cpp',
'tinygettext/log.cpp'])

env.Program('test/tinygettext_test', ['test/tinygettext_test.cpp', libtinygettext])
env.Program('test/po_parser_test', ['test/po_parser_test.cpp', libtinygettext])

# EOF #

0 comments on commit adc1067

Please sign in to comment.