forked from tinygettext/tinygettext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
183 lines (144 loc) · 4.94 KB
/
CMakeLists.txt
File metadata and controls
183 lines (144 loc) · 4.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# tinygettext - A gettext replacement that works directly on .po files
# Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the authors be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgement in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
#
# 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_MACOSX_RPATH ON)
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} src/*.cpp)
file(GLOB TINYGETTEXT_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} include/tinygettext/*.hpp)
## define a target for building the library
add_library(tinygettext ${TINYGETTEXT_SOURCES})
## Add tinygettext dir to search path
include_directories(include/)
## Debug options
option(WERROR "Stops on first compiler warning in debug mode" OFF)
option(WARNINGS "Enable long list of warnings for compiler to check" ON)
add_definitions(-std=c++0x -O3 -Wall -Wextra -Weffc++ -pedantic)
if(WARNINGS)
add_definitions(
-Wabi -Wctor-dtor-privacy
-Wold-style-cast
-Woverloaded-virtual
-Wsign-promo -Wswitch-enum
-Wcast-align -Wcast-qual
-Wdisabled-optimization
-Wfloat-equal
-Wformat=2
-Winit-self
-Winvalid-pch
-Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn
-Wpacked
-Wredundant-decls
-Wshadow
-Wsign-conversion -Wstack-protector
-Wstrict-overflow=5
-Wswitch-default -Wswitch-enum
-Wundef
-Wconversion)
# Still left:
# -Wpadded (DictionaryManager has a bool that sticks out)
if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions(
-Wstrict-null-sentinel
-Wlogical-op
-Wunsafe-loop-optimizations)
endif()
endif(WARNINGS)
if(WERROR)
add_definitions(-Werror)
endif(WERROR)
## 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)
# EOF #