New sound effects
[supertux.git] / external / tinygettext / CMakeLists.txt
1 #
2 # TinyGetText build script
3 # Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 #
19
20
21 #
22 # INSTRUCTIONS:
23 # -------------
24 #
25 # Create a directory build/ and change to it. Run
26 #
27 #   cmake ..
28 #
29 # This creates a set of Makefiles to build the project. Run
30 #
31 #   make
32 #
33
34
35 CMAKE_POLICY(SET CMP0005 NEW)
36
37 ## Project name to use as command prefix
38
39 PROJECT(tinygettext)
40 SET(VERSION "0.1")
41
42 ### CMake configuration
43
44 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
45 IF(COMMAND cmake_policy)
46         CMAKE_POLICY(SET CMP0003 NEW)
47 ENDIF(COMMAND cmake_policy)
48 SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${tinygettext_SOURCE_DIR})
49
50 # move some config clutter to the advanced section
51 MARK_AS_ADVANCED(
52         CMAKE_BACKWARDS_COMPATIBILITY
53         CMAKE_BUILD_TYPE
54         CMAKE_INSTALL_PREFIX
55         EXECUTABLE_OUTPUT_PATH
56         CMAKE_OSX_ARCHITECTURES
57         CMAKE_OSX_SYSROOT
58 )
59
60 ## Reveal library type choice to users
61 OPTION(BUILD_SHARED_LIBS "Produce dynamic library instead of static archive" ON)
62
63 ## Add iconv to include directories
64
65 FIND_PACKAGE(ICONV REQUIRED)
66 INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
67
68 ## Check iconv_const
69
70 INCLUDE(CheckCXXSourceCompiles)
71
72 SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ICONV_INCLUDE_DIR})
73 CHECK_CXX_SOURCE_COMPILES(
74         "
75         #include <iconv.h>
76         // this declaration will fail when there already exists a non const char** version which returns size_t
77         double iconv(iconv_t cd,  char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
78         int main() { return 0; }
79         "
80         HAVE_ICONV_CONST
81 )
82
83 # TODO: better way of config
84
85 IF(HAVE_ICONV_CONST)
86   ADD_DEFINITIONS(-DHAVE_ICONV_CONST)
87 ELSE(HAVE_ICONV_CONST)
88   REMOVE_DEFINITIONS(-DHAVE_ICONV_CONST)
89 ENDIF(HAVE_ICONV_CONST)
90
91 ## TinyGetText library compilation
92
93 ## build list of source files
94
95 FILE(GLOB TINYGETTEXT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/*.cpp)
96 FILE(GLOB TINYGETTEXT_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} include/tinygettext/*.hpp)
97
98 ## define a target for building the library
99
100 ADD_LIBRARY(tinygettext ${TINYGETTEXT_SOURCES})
101
102 ## Add tinygettext dir to search path
103
104 INCLUDE_DIRECTORIES(include/)
105
106 ## Debug options
107
108 OPTION(WERROR "Stops on first compiler warning in debug mode" OFF)
109 IF(CMAKE_COMPILER_IS_GNUCC)
110   ADD_DEFINITIONS(-std=c++0x -O3 -Wall -Wextra -Weffc++ -pedantic)
111   # -ansi fails in MinGW
112   OPTION(WARNINGS "Enable long list of warnings for compiler to check" ON)
113   IF(WARNINGS)
114     ADD_DEFINITIONS(
115           -Wabi  -Wctor-dtor-privacy
116           -Wstrict-null-sentinel
117           -Wold-style-cast
118           -Woverloaded-virtual
119           -Wsign-promo -Wswitch-enum
120           -Wcast-align  -Wcast-qual
121           -Wdisabled-optimization
122           -Wfloat-equal
123           -Wformat=2
124           -Winit-self
125           -Winvalid-pch  -Wunsafe-loop-optimizations
126           -Wlogical-op
127           -Wmissing-format-attribute  -Wmissing-include-dirs -Wmissing-noreturn
128           -Wpacked
129           -Wredundant-decls
130           -Wshadow
131           -Wsign-conversion  -Wstack-protector
132           -Wstrict-overflow=5
133           -Wswitch-default  -Wswitch-enum
134           -Wundef)
135         # Still left:
136         # -Wconversion  (find alternative to using toupper(int) on char)
137         # -Wpadded      (DictionaryManager has a bool that sticks out)
138   ENDIF(WARNINGS)
139   IF(WERROR)
140     ADD_DEFINITIONS(-Werror)
141   ENDIF(WERROR)
142 ENDIF(CMAKE_COMPILER_IS_GNUCC)
143
144 ## Extra definitions
145
146 ADD_DEFINITIONS(-DVERSION=${VERSION})
147
148 ## Generate test executables in the right place
149
150 SET(EXECUTABLE_OUTPUT_PATH ${tinygettext_BINARY_DIR}/test)
151
152 ## Build tinygettext tests
153
154 FOREACH(TEST tinygettext_test po_parser_test)
155   ## Add target for tinygettext test
156   ADD_EXECUTABLE(${TEST} test/${TEST}.cpp)
157   ## Link with tinygettext library
158   TARGET_LINK_LIBRARIES(${TEST} tinygettext)
159   TARGET_LINK_LIBRARIES(${TEST} ${ICONV_LIBRARY})
160 ENDFOREACH(TEST)
161
162 ## Install tinygettext
163
164 # use standardized variable name
165 SET(LIB_SUBDIR "lib${LIB_SUFFIX}"
166         CACHE STRING "Subdirectory of prefix into which libraries are installed (e.g., lib32, lib64)")
167
168 ## prepare tinygettext.pc
169 CONFIGURE_FILE(tinygettext.pc.in tinygettext.pc @ONLY)
170
171 INSTALL(TARGETS tinygettext
172         ARCHIVE DESTINATION ${LIB_SUBDIR}
173         LIBRARY DESTINATION ${LIB_SUBDIR})
174 INSTALL(FILES ${TINYGETTEXT_HEADERS}
175         DESTINATION include/tinygettext)
176 INSTALL(FILES ${tinygettext_BINARY_DIR}/tinygettext.pc
177         DESTINATION ${LIB_SUBDIR}/pkgconfig)
178
179 # EOF #