1 |
# This file is a placeholder. |
# CMakeLists.txt |
2 |
|
# |
3 |
|
# |
4 |
|
# This file allows building PCRE with the CMake configuration and build |
5 |
|
# tool. Download CMake in source or binary form from http://www.cmake.org/ |
6 |
|
# |
7 |
|
# Original listfile by Christian Ehrlicher <Ch.Ehrlicher@gmx.de> |
8 |
|
# Refined and expanded by Daniel Richard G. <skunk@iSKUNK.ORG> |
9 |
|
# 2007-09-14 mod by Sheri so 7.4 supported configuration options can be entered |
10 |
|
# 2007-09-19 Adjusted by PH to retain previous default settings |
11 |
|
# 2007-12-26 (a) On UNIX, use names libpcre instead of just pcre |
12 |
|
# (b) Ensure pcretest and pcregrep link with the local library, |
13 |
|
# not a previously-installed one. |
14 |
|
# (c) Add PCRE_SUPPORT_LIBREADLINE, PCRE_SUPPORT_LIBZ, and |
15 |
|
# PCRE_SUPPORT_LIBBZ2. |
16 |
|
# |
17 |
|
|
18 |
|
PROJECT(PCRE C CXX) |
19 |
|
|
20 |
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6) |
21 |
|
|
22 |
|
# Configuration checks |
23 |
|
|
24 |
|
INCLUDE(CheckIncludeFile) |
25 |
|
INCLUDE(CheckIncludeFileCXX) |
26 |
|
INCLUDE(CheckFunctionExists) |
27 |
|
INCLUDE(CheckTypeSize) |
28 |
|
|
29 |
|
CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H) |
30 |
|
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) |
31 |
|
CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H) |
32 |
|
CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H) |
33 |
|
|
34 |
|
CHECK_INCLUDE_FILE(bzlib.h HAVE_BZLIB_H) |
35 |
|
CHECK_INCLUDE_FILE(zlib.h HAVE_ZLIB_H) |
36 |
|
CHECK_INCLUDE_FILE(readline/history.h HAVE_READLINE_HISTORY_H) |
37 |
|
CHECK_INCLUDE_FILE(readline/readline.h HAVE_READLINE_READLINE_H) |
38 |
|
|
39 |
|
CHECK_INCLUDE_FILE_CXX(type_traits.h HAVE_TYPE_TRAITS_H) |
40 |
|
CHECK_INCLUDE_FILE_CXX(bits/type_traits.h HAVE_BITS_TYPE_TRAITS_H) |
41 |
|
|
42 |
|
CHECK_FUNCTION_EXISTS(bcopy HAVE_BCOPY) |
43 |
|
CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE) |
44 |
|
CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR) |
45 |
|
|
46 |
|
CHECK_TYPE_SIZE("long long" LONG_LONG) |
47 |
|
CHECK_TYPE_SIZE("unsigned long long" UNSIGNED_LONG_LONG) |
48 |
|
|
49 |
|
# User-configurable options |
50 |
|
# |
51 |
|
# (Note: CMakeSetup displays these in alphabetical order, regardless of |
52 |
|
# the order we use here) |
53 |
|
|
54 |
|
SET(BUILD_SHARED_LIBS OFF CACHE BOOL |
55 |
|
"Build shared libraries instead of static ones.") |
56 |
|
|
57 |
|
OPTION(PCRE_BUILD_PCRECPP "Build the PCRE C++ library (pcrecpp)." ON) |
58 |
|
|
59 |
|
SET(PCRE_EBCDIC OFF CACHE BOOL |
60 |
|
"Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems)") |
61 |
|
|
62 |
|
SET(PCRE_LINK_SIZE "2" CACHE STRING |
63 |
|
"Internal link size (2, 3 or 4 allowed). See LINK_SIZE in config.h.in for details.") |
64 |
|
|
65 |
|
SET(PCRE_MATCH_LIMIT "10000000" CACHE STRING |
66 |
|
"Default limit on internal looping. See MATCH_LIMIT in config.h.in for details.") |
67 |
|
|
68 |
|
SET(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT" CACHE STRING |
69 |
|
"Default limit on internal recursion. See MATCH_LIMIT_RECURSION in config.h.in for details.") |
70 |
|
|
71 |
|
SET(PCRE_NEWLINE "LF" CACHE STRING |
72 |
|
"What to recognize as a newline (one of CR, LF, CRLF, ANY, ANYCRLF).") |
73 |
|
|
74 |
|
SET(PCRE_NO_RECURSE OFF CACHE BOOL |
75 |
|
"If ON, then don't use stack recursion when matching. See NO_RECURSE in config.h.in for details.") |
76 |
|
|
77 |
|
SET(PCRE_POSIX_MALLOC_THRESHOLD "10" CACHE STRING |
78 |
|
"Threshold for malloc() usage. See POSIX_MALLOC_THRESHOLD in config.h.in for details.") |
79 |
|
|
80 |
|
SET(PCRE_SUPPORT_UNICODE_PROPERTIES OFF CACHE BOOL |
81 |
|
"Enable support for Unicode properties. (If set, UTF-8 support will be enabled as well)") |
82 |
|
|
83 |
|
SET(PCRE_SUPPORT_UTF8 OFF CACHE BOOL |
84 |
|
"Enable support for the Unicode UTF-8 encoding.") |
85 |
|
|
86 |
|
SET(PCRE_SUPPORT_BSR_ANYCRLF OFF CACHE BOOL |
87 |
|
"ON=Backslash-R matches only LF CR and CRLF, OFF=Backslash-R matches all Unicode Linebreaks") |
88 |
|
|
89 |
|
SET(PCRE_SUPPORT_LIBBZ2 OFF CACHE BOOL |
90 |
|
"Enable support for linking pcregrep with libbz2.") |
91 |
|
|
92 |
|
SET (PCRE_SUPPORT_LIBZ OFF CACHE BOOL |
93 |
|
"Enable support for linking pcregrep with libz.") |
94 |
|
|
95 |
|
SET (PCRE_SUPPORT_LIBREADLINE OFF CACHE BOOL |
96 |
|
"Enable support for linking pcretest with libreadline.") |
97 |
|
|
98 |
|
# Prepare build configuration |
99 |
|
|
100 |
|
SET(pcre_have_type_traits 0) |
101 |
|
SET(pcre_have_bits_type_traits 0) |
102 |
|
|
103 |
|
IF(HAVE_TYPE_TRAITS_H) |
104 |
|
SET(pcre_have_type_traits 1) |
105 |
|
ENDIF(HAVE_TYPE_TRAITS_H) |
106 |
|
|
107 |
|
IF(HAVE_BITS_TYPE_TRAITS_H) |
108 |
|
SET(pcre_have_bits_type_traits 1) |
109 |
|
ENDIF(HAVE_BITS_TYPE_TRAITS_H) |
110 |
|
|
111 |
|
SET(pcre_have_long_long 0) |
112 |
|
SET(pcre_have_ulong_long 0) |
113 |
|
|
114 |
|
IF(HAVE_LONG_LONG) |
115 |
|
SET(pcre_have_long_long 1) |
116 |
|
ENDIF(HAVE_LONG_LONG) |
117 |
|
|
118 |
|
IF(HAVE_UNSIGNED_LONG_LONG) |
119 |
|
SET(pcre_have_ulong_long 1) |
120 |
|
ENDIF(HAVE_UNSIGNED_LONG_LONG) |
121 |
|
|
122 |
|
IF(NOT BUILD_SHARED_LIBS) |
123 |
|
SET(PCRE_STATIC 1) |
124 |
|
ENDIF(NOT BUILD_SHARED_LIBS) |
125 |
|
|
126 |
|
IF(PCRE_SUPPORT_BSR_ANYCRLF) |
127 |
|
SET(BSR_ANYCRLF 1) |
128 |
|
ENDIF(PCRE_SUPPORT_BSR_ANYCRLF) |
129 |
|
|
130 |
|
IF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES) |
131 |
|
SET(SUPPORT_UTF8 1) |
132 |
|
ENDIF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES) |
133 |
|
|
134 |
|
IF(PCRE_SUPPORT_UNICODE_PROPERTIES) |
135 |
|
SET(SUPPORT_UCP 1) |
136 |
|
ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES) |
137 |
|
|
138 |
|
IF(PCRE_SUPPORT_LIBREADLINE) |
139 |
|
SET(SUPPORT_LIBREADLINE 1) |
140 |
|
SET(PCRETEST_LIBS readline) |
141 |
|
ENDIF(PCRE_SUPPORT_LIBREADLINE) |
142 |
|
|
143 |
|
IF(PCRE_SUPPORT_LIBZ) |
144 |
|
SET(SUPPORT_LIBZ 1) |
145 |
|
SET(PCREGREP_LIBS z) |
146 |
|
ENDIF(PCRE_SUPPORT_LIBZ) |
147 |
|
|
148 |
|
IF(PCRE_SUPPORT_LIBBZ2) |
149 |
|
SET(SUPPORT_LIBBZ2 1) |
150 |
|
SET(PCREGREP_LIBS ${PCREGREP_LIBS} bz2) |
151 |
|
ENDIF(PCRE_SUPPORT_LIBBZ2) |
152 |
|
|
153 |
|
SET(NEWLINE "") |
154 |
|
|
155 |
|
IF(PCRE_NEWLINE STREQUAL "LF") |
156 |
|
SET(NEWLINE "10") |
157 |
|
ENDIF(PCRE_NEWLINE STREQUAL "LF") |
158 |
|
IF(PCRE_NEWLINE STREQUAL "CR") |
159 |
|
SET(NEWLINE "13") |
160 |
|
ENDIF(PCRE_NEWLINE STREQUAL "CR") |
161 |
|
IF(PCRE_NEWLINE STREQUAL "CRLF") |
162 |
|
SET(NEWLINE "3338") |
163 |
|
ENDIF(PCRE_NEWLINE STREQUAL "CRLF") |
164 |
|
IF(PCRE_NEWLINE STREQUAL "ANY") |
165 |
|
SET(NEWLINE "-1") |
166 |
|
ENDIF(PCRE_NEWLINE STREQUAL "ANY") |
167 |
|
IF(PCRE_NEWLINE STREQUAL "ANYCRLF") |
168 |
|
SET(NEWLINE "-2") |
169 |
|
ENDIF(PCRE_NEWLINE STREQUAL "ANYCRLF") |
170 |
|
|
171 |
|
IF(NEWLINE STREQUAL "") |
172 |
|
MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".") |
173 |
|
ENDIF(NEWLINE STREQUAL "") |
174 |
|
|
175 |
|
IF(PCRE_EBCDIC) |
176 |
|
SET(EBCDIC 1) |
177 |
|
ENDIF(PCRE_EBCDIC) |
178 |
|
|
179 |
|
IF(PCRE_NO_RECURSE) |
180 |
|
SET(NO_RECURSE 1) |
181 |
|
ENDIF(PCRE_NO_RECURSE) |
182 |
|
|
183 |
|
# Output files |
184 |
|
|
185 |
|
CONFIGURE_FILE(config-cmake.h.in |
186 |
|
${CMAKE_BINARY_DIR}/config.h |
187 |
|
@ONLY) |
188 |
|
|
189 |
|
CONFIGURE_FILE(pcre.h.generic |
190 |
|
${CMAKE_BINARY_DIR}/pcre.h |
191 |
|
COPYONLY) |
192 |
|
|
193 |
|
# What about pcre-config and libpcre.pc? |
194 |
|
|
195 |
|
IF(PCRE_BUILD_PCRECPP) |
196 |
|
CONFIGURE_FILE(pcre_stringpiece.h.in |
197 |
|
${CMAKE_BINARY_DIR}/pcre_stringpiece.h |
198 |
|
@ONLY) |
199 |
|
|
200 |
|
CONFIGURE_FILE(pcrecpparg.h.in |
201 |
|
${CMAKE_BINARY_DIR}/pcrecpparg.h |
202 |
|
@ONLY) |
203 |
|
ENDIF(PCRE_BUILD_PCRECPP) |
204 |
|
|
205 |
|
# Character table generation |
206 |
|
|
207 |
|
ADD_EXECUTABLE(dftables dftables.c) |
208 |
|
|
209 |
|
GET_TARGET_PROPERTY(DFTABLES_EXE dftables LOCATION) |
210 |
|
|
211 |
|
ADD_CUSTOM_COMMAND( |
212 |
|
COMMENT "Generating character tables (pcre_chartables.c) for current locale" |
213 |
|
DEPENDS dftables |
214 |
|
COMMAND ${DFTABLES_EXE} |
215 |
|
ARGS ${CMAKE_BINARY_DIR}/pcre_chartables.c |
216 |
|
OUTPUT ${CMAKE_BINARY_DIR}/pcre_chartables.c |
217 |
|
) |
218 |
|
|
219 |
|
# Source code |
220 |
|
|
221 |
|
SET(PCRE_HEADERS ${CMAKE_BINARY_DIR}/pcre.h) |
222 |
|
|
223 |
|
SET(PCRE_SOURCES |
224 |
|
${CMAKE_BINARY_DIR}/pcre_chartables.c |
225 |
|
pcre_compile.c |
226 |
|
pcre_config.c |
227 |
|
pcre_dfa_exec.c |
228 |
|
pcre_exec.c |
229 |
|
pcre_fullinfo.c |
230 |
|
pcre_get.c |
231 |
|
pcre_globals.c |
232 |
|
pcre_info.c |
233 |
|
pcre_newline.c |
234 |
|
pcre_maketables.c |
235 |
|
pcre_ord2utf8.c |
236 |
|
pcre_refcount.c |
237 |
|
pcre_study.c |
238 |
|
pcre_tables.c |
239 |
|
pcre_try_flipped.c |
240 |
|
pcre_ucp_searchfuncs.c |
241 |
|
pcre_valid_utf8.c |
242 |
|
pcre_version.c |
243 |
|
pcre_xclass.c |
244 |
|
) |
245 |
|
|
246 |
|
SET(PCREPOSIX_HEADERS pcreposix.h) |
247 |
|
|
248 |
|
SET(PCREPOSIX_SOURCES pcreposix.c) |
249 |
|
|
250 |
|
SET(PCRECPP_HEADERS |
251 |
|
pcrecpp.h |
252 |
|
pcre_scanner.h |
253 |
|
${CMAKE_BINARY_DIR}/pcrecpparg.h |
254 |
|
${CMAKE_BINARY_DIR}/pcre_stringpiece.h |
255 |
|
) |
256 |
|
|
257 |
|
SET(PCRECPP_SOURCES |
258 |
|
pcrecpp.cc |
259 |
|
pcre_scanner.cc |
260 |
|
pcre_stringpiece.cc |
261 |
|
) |
262 |
|
|
263 |
|
# Build setup |
264 |
|
|
265 |
|
ADD_DEFINITIONS(-DHAVE_CONFIG_H) |
266 |
|
|
267 |
|
IF(WIN32) |
268 |
|
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) |
269 |
|
ENDIF(WIN32) |
270 |
|
|
271 |
|
SET(CMAKE_INCLUDE_CURRENT_DIR 1) |
272 |
|
|
273 |
|
#SET(CMAKE_DEBUG_POSTFIX "d") |
274 |
|
|
275 |
|
# Libraries |
276 |
|
|
277 |
|
ADD_LIBRARY(pcre ${PCRE_HEADERS} ${PCRE_SOURCES}) |
278 |
|
|
279 |
|
ADD_LIBRARY(pcreposix ${PCREPOSIX_HEADERS} ${PCREPOSIX_SOURCES}) |
280 |
|
TARGET_LINK_LIBRARIES(pcreposix pcre) |
281 |
|
|
282 |
|
IF(NOT UNIX) |
283 |
|
SET_TARGET_PROPERTIES(pcre pcreposix |
284 |
|
PROPERTIES PREFIX "" |
285 |
|
) |
286 |
|
ENDIF(NOT UNIX) |
287 |
|
|
288 |
|
IF(PCRE_BUILD_PCRECPP) |
289 |
|
ADD_LIBRARY(pcrecpp ${PCRECPP_HEADERS} ${PCRECPP_SOURCES}) |
290 |
|
TARGET_LINK_LIBRARIES(pcrecpp pcre) |
291 |
|
IF(MINGW) |
292 |
|
SET_TARGET_PROPERTIES(pcrecpp PROPERTIES PREFIX "mingw-") |
293 |
|
ENDIF(MINGW) |
294 |
|
ENDIF(PCRE_BUILD_PCRECPP) |
295 |
|
|
296 |
|
# Executables |
297 |
|
|
298 |
|
ADD_EXECUTABLE(pcretest pcretest.c) |
299 |
|
TARGET_LINK_LIBRARIES(pcretest pcreposix ${PCRETEST_LIBS}) |
300 |
|
|
301 |
|
ADD_EXECUTABLE(pcregrep pcregrep.c) |
302 |
|
TARGET_LINK_LIBRARIES(pcregrep pcreposix ${PCREGREP_LIBS}) |
303 |
|
|
304 |
|
IF(PCRE_BUILD_PCRECPP) |
305 |
|
ADD_EXECUTABLE(pcrecpp_unittest pcrecpp_unittest.cc) |
306 |
|
TARGET_LINK_LIBRARIES(pcrecpp_unittest pcrecpp) |
307 |
|
|
308 |
|
ADD_EXECUTABLE(pcre_scanner_unittest pcre_scanner_unittest.cc) |
309 |
|
TARGET_LINK_LIBRARIES(pcre_scanner_unittest pcrecpp) |
310 |
|
|
311 |
|
ADD_EXECUTABLE(pcre_stringpiece_unittest pcre_stringpiece_unittest.cc) |
312 |
|
TARGET_LINK_LIBRARIES(pcre_stringpiece_unittest pcrecpp) |
313 |
|
ENDIF(PCRE_BUILD_PCRECPP) |
314 |
|
|
315 |
|
# Testing |
316 |
|
|
317 |
|
ENABLE_TESTING() |
318 |
|
|
319 |
|
GET_TARGET_PROPERTY(PCREGREP_EXE pcregrep DEBUG_LOCATION) |
320 |
|
GET_TARGET_PROPERTY(PCRETEST_EXE pcretest DEBUG_LOCATION) |
321 |
|
|
322 |
|
# Write out a CTest configuration file that sets some needed environment |
323 |
|
# variables for the test scripts. |
324 |
|
# |
325 |
|
FILE(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.ctest |
326 |
|
"# This is a generated file. |
327 |
|
SET(ENV{srcdir} ${CMAKE_SOURCE_DIR}) |
328 |
|
SET(ENV{pcregrep} ${PCREGREP_EXE}) |
329 |
|
SET(ENV{pcretest} ${PCRETEST_EXE}) |
330 |
|
") |
331 |
|
|
332 |
|
IF(UNIX) |
333 |
|
ADD_TEST(pcre_test ${CMAKE_SOURCE_DIR}/RunTest) |
334 |
|
ADD_TEST(pcre_grep_test ${CMAKE_SOURCE_DIR}/RunGrepTest) |
335 |
|
ENDIF(UNIX) |
336 |
|
IF(WIN32) |
337 |
|
ADD_TEST(pcre_test cmd /C ${CMAKE_SOURCE_DIR}/RunTest.bat) |
338 |
|
ENDIF(WIN32) |
339 |
|
|
340 |
|
GET_TARGET_PROPERTY(PCRECPP_UNITTEST_EXE |
341 |
|
pcrecpp_unittest |
342 |
|
DEBUG_LOCATION) |
343 |
|
|
344 |
|
GET_TARGET_PROPERTY(PCRE_SCANNER_UNITTEST_EXE |
345 |
|
pcre_scanner_unittest |
346 |
|
DEBUG_LOCATION) |
347 |
|
|
348 |
|
GET_TARGET_PROPERTY(PCRE_STRINGPIECE_UNITTEST_EXE |
349 |
|
pcre_stringpiece_unittest |
350 |
|
DEBUG_LOCATION) |
351 |
|
|
352 |
|
ADD_TEST(pcrecpp_test ${PCRECPP_UNITTEST_EXE}) |
353 |
|
ADD_TEST(pcre_scanner_test ${PCRE_SCANNER_UNITTEST_EXE}) |
354 |
|
ADD_TEST(pcre_stringpiece_test ${PCRE_STRINGPIECE_UNITTEST_EXE}) |
355 |
|
|
356 |
|
# Installation |
357 |
|
|
358 |
|
SET(CMAKE_INSTALL_ALWAYS 1) |
359 |
|
|
360 |
|
INSTALL(TARGETS pcre pcreposix pcregrep pcretest |
361 |
|
RUNTIME DESTINATION bin |
362 |
|
LIBRARY DESTINATION lib |
363 |
|
ARCHIVE DESTINATION lib) |
364 |
|
|
365 |
|
INSTALL(FILES ${PCRE_HEADERS} ${PCREPOSIX_HEADERS} DESTINATION include) |
366 |
|
|
367 |
|
FILE(GLOB html ${CMAKE_SOURCE_DIR}/doc/html/*.html) |
368 |
|
FILE(GLOB man1 ${CMAKE_SOURCE_DIR}/doc/*.1) |
369 |
|
FILE(GLOB man3 ${CMAKE_SOURCE_DIR}/doc/*.3) |
370 |
|
|
371 |
|
IF(PCRE_BUILD_PCRECPP) |
372 |
|
INSTALL(TARGETS pcrecpp |
373 |
|
RUNTIME DESTINATION bin |
374 |
|
LIBRARY DESTINATION lib |
375 |
|
ARCHIVE DESTINATION lib) |
376 |
|
INSTALL(FILES ${PCRECPP_HEADERS} DESTINATION include) |
377 |
|
ELSE(PCRE_BUILD_PCRECPP) |
378 |
|
# Remove pcrecpp.3 |
379 |
|
FOREACH(man ${man3}) |
380 |
|
GET_FILENAME_COMPONENT(man_tmp ${man} NAME) |
381 |
|
IF(NOT man_tmp STREQUAL "pcrecpp.3") |
382 |
|
SET(man3_new ${man3} ${man}) |
383 |
|
ENDIF(NOT man_tmp STREQUAL "pcrecpp.3") |
384 |
|
ENDFOREACH(man ${man3}) |
385 |
|
SET(man3 ${man3_new}) |
386 |
|
ENDIF(PCRE_BUILD_PCRECPP) |
387 |
|
|
388 |
|
INSTALL(FILES ${man1} DESTINATION man/man1) |
389 |
|
INSTALL(FILES ${man3} DESTINATION man/man3) |
390 |
|
INSTALL(FILES ${html} DESTINATION share/doc/pcre/html) |
391 |
|
|
392 |
|
# end CMakeLists.txt |