1 |
# This file is a placeholder. |
# CMakeLists.txt |
2 |
|
# |
3 |
|
# This file allows building PCRE with the CMake configuration and build |
4 |
|
# tool. Download CMake in source or binary form from http://www.cmake.org/ |
5 |
|
# |
6 |
|
# Original listfile by Christian Ehrlicher <Ch.Ehrlicher@gmx.de> |
7 |
|
# Refined and expanded by Daniel Richard G. <skunk@iSKUNK.ORG> |
8 |
|
# |
9 |
|
|
10 |
|
PROJECT(PCRE C CXX) |
11 |
|
|
12 |
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6) |
13 |
|
|
14 |
|
# Configuration checks |
15 |
|
|
16 |
|
INCLUDE(CheckIncludeFile) |
17 |
|
INCLUDE(CheckIncludeFileCXX) |
18 |
|
INCLUDE(CheckFunctionExists) |
19 |
|
INCLUDE(CheckTypeSize) |
20 |
|
|
21 |
|
CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H) |
22 |
|
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) |
23 |
|
CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H) |
24 |
|
CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H) |
25 |
|
|
26 |
|
CHECK_INCLUDE_FILE_CXX(type_traits.h HAVE_TYPE_TRAITS_H) |
27 |
|
CHECK_INCLUDE_FILE_CXX(bits/type_traits.h HAVE_BITS_TYPE_TRAITS_H) |
28 |
|
|
29 |
|
CHECK_FUNCTION_EXISTS(bcopy HAVE_BCOPY) |
30 |
|
CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE) |
31 |
|
CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR) |
32 |
|
|
33 |
|
CHECK_TYPE_SIZE("long long" LONG_LONG) |
34 |
|
CHECK_TYPE_SIZE("unsigned long long" UNSIGNED_LONG_LONG) |
35 |
|
|
36 |
|
# User-configurable options |
37 |
|
# |
38 |
|
# (Note: CMakeSetup displays these in alphabetical order, regardless of |
39 |
|
# the order we use here) |
40 |
|
|
41 |
|
SET(BUILD_SHARED_LIBS "SHARED" CACHE STRING |
42 |
|
"What type of libraries to build. Set to SHARED or STATIC.") |
43 |
|
|
44 |
|
OPTION(PCRE_BUILD_PCRECPP "Build the PCRE C++ library (pcrecpp)." ON) |
45 |
|
|
46 |
|
SET(PCRE_EBCDIC FALSE CACHE BOOL |
47 |
|
"Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems)") |
48 |
|
|
49 |
|
SET(PCRE_LINK_SIZE "2" CACHE STRING |
50 |
|
"Internal link size (2, 3 or 4 allowed). See LINK_SIZE in config.h.in for details.") |
51 |
|
|
52 |
|
SET(PCRE_MATCH_LIMIT "10000000" CACHE STRING |
53 |
|
"Default limit on internal looping. See MATCH_LIMIT in config.h.in for details.") |
54 |
|
|
55 |
|
SET(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT" CACHE STRING |
56 |
|
"Default limit on internal recursion. See MATCH_LIMIT_RECURSION in config.h.in for details.") |
57 |
|
|
58 |
|
SET(PCRE_NEWLINE "LF" CACHE STRING |
59 |
|
"What to recognize as a newline (one of CR, LF, CRLF, ANY).") |
60 |
|
|
61 |
|
SET(PCRE_NO_RECURSE TRUE CACHE BOOL |
62 |
|
"If ON, then don't use stack recursion when matching. See NO_RECURSE in config.h.in for details.") |
63 |
|
|
64 |
|
SET(PCRE_POSIX_MALLOC_THRESHOLD "10" CACHE STRING |
65 |
|
"Threshold for malloc() usage. See POSIX_MALLOC_THRESHOLD in config.h.in for details.") |
66 |
|
|
67 |
|
SET(PCRE_SUPPORT_UNICODE_PROPERTIES FALSE CACHE BOOL |
68 |
|
"Enable support for Unicode properties. (If set, UTF-8 support will be enabled as well)") |
69 |
|
|
70 |
|
SET(PCRE_SUPPORT_UTF8 FALSE CACHE BOOL |
71 |
|
"Enable support for the Unicode UTF-8 encoding.") |
72 |
|
|
73 |
|
# Prepare build configuration |
74 |
|
|
75 |
|
SET(pcre_have_type_traits 0) |
76 |
|
SET(pcre_have_bits_type_traits 0) |
77 |
|
|
78 |
|
IF(HAVE_TYPE_TRAITS_H) |
79 |
|
SET(pcre_have_type_traits 1) |
80 |
|
ENDIF(HAVE_TYPE_TRAITS_H) |
81 |
|
|
82 |
|
IF(HAVE_BITS_TYPE_TRAITS_H) |
83 |
|
SET(pcre_have_bits_type_traits 1) |
84 |
|
ENDIF(HAVE_BITS_TYPE_TRAITS_H) |
85 |
|
|
86 |
|
SET(pcre_have_long_long 0) |
87 |
|
SET(pcre_have_ulong_long 0) |
88 |
|
|
89 |
|
IF(HAVE_LONG_LONG) |
90 |
|
SET(pcre_have_long_long 1) |
91 |
|
ENDIF(HAVE_LONG_LONG) |
92 |
|
|
93 |
|
IF(HAVE_UNSIGNED_LONG_LONG) |
94 |
|
SET(pcre_have_ulong_long 1) |
95 |
|
ENDIF(HAVE_UNSIGNED_LONG_LONG) |
96 |
|
|
97 |
|
IF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES) |
98 |
|
SET(SUPPORT_UTF8 1) |
99 |
|
ENDIF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES) |
100 |
|
|
101 |
|
IF(PCRE_SUPPORT_UNICODE_PROPERTIES) |
102 |
|
SET(SUPPORT_UCP 1) |
103 |
|
ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES) |
104 |
|
|
105 |
|
IF(PCRE_NEWLINE STREQUAL "LF") |
106 |
|
SET(NEWLINE "10") |
107 |
|
ELSEIF(PCRE_NEWLINE STREQUAL "CR") |
108 |
|
SET(NEWLINE "13") |
109 |
|
ELSEIF(PCRE_NEWLINE STREQUAL "CRLF") |
110 |
|
SET(NEWLINE "3338") |
111 |
|
ELSEIF(PCRE_NEWLINE STREQUAL "ANY") |
112 |
|
SET(NEWLINE "-1") |
113 |
|
ELSE(PCRE_NEWLINE STREQUAL "LF") |
114 |
|
MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\".") |
115 |
|
ENDIF(PCRE_NEWLINE STREQUAL "LF") |
116 |
|
|
117 |
|
IF(PCRE_EBCDIC) |
118 |
|
SET(EBCDIC 1) |
119 |
|
ENDIF(PCRE_EBCDIC) |
120 |
|
|
121 |
|
IF(PCRE_NO_RECURSE) |
122 |
|
SET(NO_RECURSE 1) |
123 |
|
ENDIF(PCRE_NO_RECURSE) |
124 |
|
|
125 |
|
# Output files |
126 |
|
|
127 |
|
CONFIGURE_FILE(config-cmake.h.in |
128 |
|
${CMAKE_BINARY_DIR}/config.h |
129 |
|
@ONLY) |
130 |
|
|
131 |
|
CONFIGURE_FILE(pcre.h.generic |
132 |
|
${CMAKE_BINARY_DIR}/pcre.h |
133 |
|
COPYONLY) |
134 |
|
|
135 |
|
# What about pcre-config and libpcre.pc? |
136 |
|
|
137 |
|
IF(PCRE_BUILD_PCRECPP) |
138 |
|
CONFIGURE_FILE(pcre_stringpiece.h.in |
139 |
|
${CMAKE_BINARY_DIR}/pcre_stringpiece.h |
140 |
|
@ONLY) |
141 |
|
|
142 |
|
CONFIGURE_FILE(pcrecpparg.h.in |
143 |
|
${CMAKE_BINARY_DIR}/pcrecpparg.h |
144 |
|
@ONLY) |
145 |
|
ENDIF(PCRE_BUILD_PCRECPP) |
146 |
|
|
147 |
|
# Character table generation |
148 |
|
|
149 |
|
ADD_EXECUTABLE(dftables dftables.c) |
150 |
|
|
151 |
|
GET_TARGET_PROPERTY(DFTABLES_EXE dftables LOCATION) |
152 |
|
|
153 |
|
ADD_CUSTOM_COMMAND( |
154 |
|
COMMENT "Generating character tables (pcre_chartables.c) for current locale" |
155 |
|
DEPENDS dftables |
156 |
|
COMMAND ${DFTABLES_EXE} |
157 |
|
ARGS ${CMAKE_BINARY_DIR}/pcre_chartables.c |
158 |
|
OUTPUT ${CMAKE_BINARY_DIR}/pcre_chartables.c |
159 |
|
) |
160 |
|
|
161 |
|
# Source code |
162 |
|
|
163 |
|
SET(PCRE_HEADERS ${CMAKE_BINARY_DIR}/pcre.h) |
164 |
|
|
165 |
|
SET(PCRE_SOURCES |
166 |
|
${CMAKE_BINARY_DIR}/pcre_chartables.c |
167 |
|
pcre_compile.c |
168 |
|
pcre_config.c |
169 |
|
pcre_dfa_exec.c |
170 |
|
pcre_exec.c |
171 |
|
pcre_fullinfo.c |
172 |
|
pcre_get.c |
173 |
|
pcre_globals.c |
174 |
|
pcre_info.c |
175 |
|
pcre_newline.c |
176 |
|
pcre_maketables.c |
177 |
|
pcre_ord2utf8.c |
178 |
|
pcre_refcount.c |
179 |
|
pcre_study.c |
180 |
|
pcre_tables.c |
181 |
|
pcre_try_flipped.c |
182 |
|
pcre_ucp_searchfuncs.c |
183 |
|
pcre_valid_utf8.c |
184 |
|
pcre_version.c |
185 |
|
pcre_xclass.c |
186 |
|
) |
187 |
|
|
188 |
|
SET(PCREPOSIX_HEADERS pcreposix.h) |
189 |
|
|
190 |
|
SET(PCREPOSIX_SOURCES pcreposix.c) |
191 |
|
|
192 |
|
SET(PCRECPP_HEADERS |
193 |
|
pcrecpp.h |
194 |
|
pcre_scanner.h |
195 |
|
${CMAKE_BINARY_DIR}/pcrecpparg.h |
196 |
|
${CMAKE_BINARY_DIR}/pcre_stringpiece.h |
197 |
|
) |
198 |
|
|
199 |
|
SET(PCRECPP_SOURCES |
200 |
|
pcrecpp.cc |
201 |
|
pcre_scanner.cc |
202 |
|
pcre_stringpiece.cc |
203 |
|
) |
204 |
|
|
205 |
|
# Build setup |
206 |
|
|
207 |
|
ADD_DEFINITIONS(-DHAVE_CONFIG_H) |
208 |
|
|
209 |
|
IF(WIN32) |
210 |
|
# What about -DDLL_EXPORT? |
211 |
|
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) |
212 |
|
ENDIF(WIN32) |
213 |
|
|
214 |
|
SET(CMAKE_INCLUDE_CURRENT_DIR 1) |
215 |
|
|
216 |
|
#SET(CMAKE_DEBUG_POSTFIX "d") |
217 |
|
|
218 |
|
# Libraries |
219 |
|
|
220 |
|
ADD_LIBRARY(pcre ${PCRE_HEADERS} ${PCRE_SOURCES}) |
221 |
|
|
222 |
|
ADD_LIBRARY(pcreposix ${PCREPOSIX_HEADERS} ${PCREPOSIX_SOURCES}) |
223 |
|
TARGET_LINK_LIBRARIES(pcreposix pcre) |
224 |
|
|
225 |
|
IF(PCRE_BUILD_PCRECPP) |
226 |
|
ADD_LIBRARY(pcrecpp ${PCRECPP_HEADERS} ${PCRECPP_SOURCES}) |
227 |
|
TARGET_LINK_LIBRARIES(pcrecpp pcre) |
228 |
|
IF(MINGW) |
229 |
|
SET_TARGET_PROPERTIES(pcrecpp PROPERTIES PREFIX "mingw-") |
230 |
|
ENDIF(MINGW) |
231 |
|
ENDIF(PCRE_BUILD_PCRECPP) |
232 |
|
|
233 |
|
# Executables |
234 |
|
|
235 |
|
ADD_EXECUTABLE(pcretest pcretest.c) |
236 |
|
TARGET_LINK_LIBRARIES(pcretest pcreposix) |
237 |
|
|
238 |
|
ADD_EXECUTABLE(pcregrep pcregrep.c) |
239 |
|
TARGET_LINK_LIBRARIES(pcregrep pcreposix) |
240 |
|
|
241 |
|
# Testing |
242 |
|
|
243 |
|
ENABLE_TESTING() |
244 |
|
|
245 |
|
IF(UNIX) |
246 |
|
ADD_TEST(test1 ${CMAKE_SOURCE_DIR}/RunTest srcdir=${CMAKE_SOURCE_DIR}) |
247 |
|
ELSEIF(WIN32) |
248 |
|
ADD_TEST(test1 ${CMAKE_SOURCE_DIR}/RunTest.bat ${CMAKE_SOURCE_DIR}) |
249 |
|
ENDIF(UNIX) |
250 |
|
|
251 |
|
# Installation |
252 |
|
|
253 |
|
SET(CMAKE_INSTALL_ALWAYS 1) |
254 |
|
|
255 |
|
INSTALL(TARGETS pcre pcreposix pcregrep pcretest |
256 |
|
RUNTIME DESTINATION bin |
257 |
|
LIBRARY DESTINATION lib |
258 |
|
ARCHIVE DESTINATION lib) |
259 |
|
|
260 |
|
INSTALL(FILES ${PCRE_HEADERS} ${PCREPOSIX_HEADERS} DESTINATION include) |
261 |
|
|
262 |
|
FILE(GLOB html ${CMAKE_SOURCE_DIR}/doc/html/*.html) |
263 |
|
FILE(GLOB man1 ${CMAKE_SOURCE_DIR}/doc/*.1) |
264 |
|
FILE(GLOB man3 ${CMAKE_SOURCE_DIR}/doc/*.3) |
265 |
|
|
266 |
|
IF(PCRE_BUILD_PCRECPP) |
267 |
|
INSTALL(TARGETS pcrecpp DESTINATION lib) |
268 |
|
INSTALL(FILES ${PCRECPP_HEADERS} DESTINATION include) |
269 |
|
ELSE(PCRE_BUILD_PCRECPP) |
270 |
|
# Remove pcrecpp.3 |
271 |
|
FOREACH(man ${man3}) |
272 |
|
GET_FILENAME_COMPONENT(man_tmp ${man} NAME) |
273 |
|
IF(NOT man_tmp STREQUAL "pcrecpp.3") |
274 |
|
SET(man3_new ${man3} ${man}) |
275 |
|
ENDIF(NOT man_tmp STREQUAL "pcrecpp.3") |
276 |
|
ENDFOREACH(man ${man3}) |
277 |
|
SET(man3 ${man3_new}) |
278 |
|
ENDIF(PCRE_BUILD_PCRECPP) |
279 |
|
|
280 |
|
INSTALL(FILES ${man1} DESTINATION man/man1) |
281 |
|
INSTALL(FILES ${man3} DESTINATION man/man3) |
282 |
|
INSTALL(FILES ${html} DESTINATION doc/html) |
283 |
|
|
284 |
|
# end CMakeLists.txt |