1 |
# CMakeLists.txt |
# CMakeLists.txt |
2 |
# |
# |
3 |
|
# |
4 |
# This file allows building PCRE with the CMake configuration and build |
# 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/ |
# tool. Download CMake in source or binary form from http://www.cmake.org/ |
6 |
# |
# |
7 |
# Original listfile by Christian Ehrlicher <Ch.Ehrlicher@gmx.de> |
# Original listfile by Christian Ehrlicher <Ch.Ehrlicher@gmx.de> |
8 |
# Refined and expanded by Daniel Richard G. <skunk@iSKUNK.ORG> |
# 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) |
PROJECT(PCRE C CXX) |
31 |
CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H) |
CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H) |
32 |
CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H) |
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) |
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) |
CHECK_INCLUDE_FILE_CXX(bits/type_traits.h HAVE_BITS_TYPE_TRAITS_H) |
41 |
|
|
51 |
# (Note: CMakeSetup displays these in alphabetical order, regardless of |
# (Note: CMakeSetup displays these in alphabetical order, regardless of |
52 |
# the order we use here) |
# the order we use here) |
53 |
|
|
54 |
SET(BUILD_SHARED_LIBS "SHARED" CACHE STRING |
SET(BUILD_SHARED_LIBS OFF CACHE BOOL |
55 |
"What type of libraries to build. Set to SHARED or STATIC.") |
"Build shared libraries instead of static ones.") |
56 |
|
|
57 |
OPTION(PCRE_BUILD_PCRECPP "Build the PCRE C++ library (pcrecpp)." ON) |
OPTION(PCRE_BUILD_PCRECPP "Build the PCRE C++ library (pcrecpp)." ON) |
58 |
|
|
59 |
SET(PCRE_EBCDIC FALSE CACHE BOOL |
SET(PCRE_EBCDIC OFF CACHE BOOL |
60 |
"Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems)") |
"Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems)") |
61 |
|
|
62 |
SET(PCRE_LINK_SIZE "2" CACHE STRING |
SET(PCRE_LINK_SIZE "2" CACHE STRING |
69 |
"Default limit on internal recursion. See MATCH_LIMIT_RECURSION in config.h.in for details.") |
"Default limit on internal recursion. See MATCH_LIMIT_RECURSION in config.h.in for details.") |
70 |
|
|
71 |
SET(PCRE_NEWLINE "LF" CACHE STRING |
SET(PCRE_NEWLINE "LF" CACHE STRING |
72 |
"What to recognize as a newline (one of CR, LF, CRLF, ANY).") |
"What to recognize as a newline (one of CR, LF, CRLF, ANY, ANYCRLF).") |
73 |
|
|
74 |
SET(PCRE_NO_RECURSE TRUE CACHE BOOL |
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.") |
"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 |
SET(PCRE_POSIX_MALLOC_THRESHOLD "10" CACHE STRING |
78 |
"Threshold for malloc() usage. See POSIX_MALLOC_THRESHOLD in config.h.in for details.") |
"Threshold for malloc() usage. See POSIX_MALLOC_THRESHOLD in config.h.in for details.") |
79 |
|
|
80 |
SET(PCRE_SUPPORT_UNICODE_PROPERTIES FALSE CACHE BOOL |
SET(PCRE_SUPPORT_UNICODE_PROPERTIES OFF CACHE BOOL |
81 |
"Enable support for Unicode properties. (If set, UTF-8 support will be enabled as well)") |
"Enable support for Unicode properties. (If set, UTF-8 support will be enabled as well)") |
82 |
|
|
83 |
SET(PCRE_SUPPORT_UTF8 FALSE CACHE BOOL |
SET(PCRE_SUPPORT_UTF8 OFF CACHE BOOL |
84 |
"Enable support for the Unicode UTF-8 encoding.") |
"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 |
# Prepare build configuration |
99 |
|
|
100 |
SET(pcre_have_type_traits 0) |
SET(pcre_have_type_traits 0) |
119 |
SET(pcre_have_ulong_long 1) |
SET(pcre_have_ulong_long 1) |
120 |
ENDIF(HAVE_UNSIGNED_LONG_LONG) |
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) |
IF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES) |
131 |
SET(SUPPORT_UTF8 1) |
SET(SUPPORT_UTF8 1) |
132 |
ENDIF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES) |
ENDIF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES) |
135 |
SET(SUPPORT_UCP 1) |
SET(SUPPORT_UCP 1) |
136 |
ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES) |
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") |
IF(PCRE_NEWLINE STREQUAL "LF") |
156 |
SET(NEWLINE "10") |
SET(NEWLINE "10") |
157 |
ELSEIF(PCRE_NEWLINE STREQUAL "CR") |
ENDIF(PCRE_NEWLINE STREQUAL "LF") |
158 |
|
IF(PCRE_NEWLINE STREQUAL "CR") |
159 |
SET(NEWLINE "13") |
SET(NEWLINE "13") |
160 |
ELSEIF(PCRE_NEWLINE STREQUAL "CRLF") |
ENDIF(PCRE_NEWLINE STREQUAL "CR") |
161 |
|
IF(PCRE_NEWLINE STREQUAL "CRLF") |
162 |
SET(NEWLINE "3338") |
SET(NEWLINE "3338") |
163 |
ELSEIF(PCRE_NEWLINE STREQUAL "ANY") |
ENDIF(PCRE_NEWLINE STREQUAL "CRLF") |
164 |
|
IF(PCRE_NEWLINE STREQUAL "ANY") |
165 |
SET(NEWLINE "-1") |
SET(NEWLINE "-1") |
166 |
ELSE(PCRE_NEWLINE STREQUAL "LF") |
ENDIF(PCRE_NEWLINE STREQUAL "ANY") |
167 |
MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\".") |
IF(PCRE_NEWLINE STREQUAL "ANYCRLF") |
168 |
ENDIF(PCRE_NEWLINE STREQUAL "LF") |
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) |
IF(PCRE_EBCDIC) |
176 |
SET(EBCDIC 1) |
SET(EBCDIC 1) |
194 |
|
|
195 |
IF(PCRE_BUILD_PCRECPP) |
IF(PCRE_BUILD_PCRECPP) |
196 |
CONFIGURE_FILE(pcre_stringpiece.h.in |
CONFIGURE_FILE(pcre_stringpiece.h.in |
197 |
${CMAKE_BINARY_DIR}/pcre_stringpiece.h |
${CMAKE_BINARY_DIR}/pcre_stringpiece.h |
198 |
@ONLY) |
@ONLY) |
199 |
|
|
200 |
CONFIGURE_FILE(pcrecpparg.h.in |
CONFIGURE_FILE(pcrecpparg.h.in |
201 |
${CMAKE_BINARY_DIR}/pcrecpparg.h |
${CMAKE_BINARY_DIR}/pcrecpparg.h |
202 |
@ONLY) |
@ONLY) |
203 |
ENDIF(PCRE_BUILD_PCRECPP) |
ENDIF(PCRE_BUILD_PCRECPP) |
204 |
|
|
205 |
# Character table generation |
# Character table generation |
212 |
COMMENT "Generating character tables (pcre_chartables.c) for current locale" |
COMMENT "Generating character tables (pcre_chartables.c) for current locale" |
213 |
DEPENDS dftables |
DEPENDS dftables |
214 |
COMMAND ${DFTABLES_EXE} |
COMMAND ${DFTABLES_EXE} |
215 |
ARGS ${CMAKE_BINARY_DIR}/pcre_chartables.c |
ARGS ${CMAKE_BINARY_DIR}/pcre_chartables.c |
216 |
OUTPUT ${CMAKE_BINARY_DIR}/pcre_chartables.c |
OUTPUT ${CMAKE_BINARY_DIR}/pcre_chartables.c |
217 |
) |
) |
218 |
|
|
219 |
# Source code |
# Source code |
265 |
ADD_DEFINITIONS(-DHAVE_CONFIG_H) |
ADD_DEFINITIONS(-DHAVE_CONFIG_H) |
266 |
|
|
267 |
IF(WIN32) |
IF(WIN32) |
|
# What about -DDLL_EXPORT? |
|
268 |
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) |
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE) |
269 |
ENDIF(WIN32) |
ENDIF(WIN32) |
270 |
|
|
279 |
ADD_LIBRARY(pcreposix ${PCREPOSIX_HEADERS} ${PCREPOSIX_SOURCES}) |
ADD_LIBRARY(pcreposix ${PCREPOSIX_HEADERS} ${PCREPOSIX_SOURCES}) |
280 |
TARGET_LINK_LIBRARIES(pcreposix pcre) |
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) |
IF(PCRE_BUILD_PCRECPP) |
289 |
ADD_LIBRARY(pcrecpp ${PCRECPP_HEADERS} ${PCRECPP_SOURCES}) |
ADD_LIBRARY(pcrecpp ${PCRECPP_HEADERS} ${PCRECPP_SOURCES}) |
290 |
TARGET_LINK_LIBRARIES(pcrecpp pcre) |
TARGET_LINK_LIBRARIES(pcrecpp pcre) |
296 |
# Executables |
# Executables |
297 |
|
|
298 |
ADD_EXECUTABLE(pcretest pcretest.c) |
ADD_EXECUTABLE(pcretest pcretest.c) |
299 |
TARGET_LINK_LIBRARIES(pcretest pcreposix) |
TARGET_LINK_LIBRARIES(pcretest pcreposix ${PCRETEST_LIBS}) |
300 |
|
|
301 |
ADD_EXECUTABLE(pcregrep pcregrep.c) |
ADD_EXECUTABLE(pcregrep pcregrep.c) |
302 |
TARGET_LINK_LIBRARIES(pcregrep pcreposix) |
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 |
# Testing |
316 |
|
|
317 |
ENABLE_TESTING() |
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) |
IF(UNIX) |
333 |
ADD_TEST(test1 ${CMAKE_SOURCE_DIR}/RunTest srcdir=${CMAKE_SOURCE_DIR}) |
ADD_TEST(pcre_test ${CMAKE_SOURCE_DIR}/RunTest) |
334 |
ELSEIF(WIN32) |
ADD_TEST(pcre_grep_test ${CMAKE_SOURCE_DIR}/RunGrepTest) |
|
ADD_TEST(test1 ${CMAKE_SOURCE_DIR}/RunTest.bat ${CMAKE_SOURCE_DIR}) |
|
335 |
ENDIF(UNIX) |
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 |
# Installation |
357 |
|
|
369 |
FILE(GLOB man3 ${CMAKE_SOURCE_DIR}/doc/*.3) |
FILE(GLOB man3 ${CMAKE_SOURCE_DIR}/doc/*.3) |
370 |
|
|
371 |
IF(PCRE_BUILD_PCRECPP) |
IF(PCRE_BUILD_PCRECPP) |
372 |
INSTALL(TARGETS pcrecpp DESTINATION lib) |
INSTALL(TARGETS pcrecpp |
373 |
|
RUNTIME DESTINATION bin |
374 |
|
LIBRARY DESTINATION lib |
375 |
|
ARCHIVE DESTINATION lib) |
376 |
INSTALL(FILES ${PCRECPP_HEADERS} DESTINATION include) |
INSTALL(FILES ${PCRECPP_HEADERS} DESTINATION include) |
377 |
ELSE(PCRE_BUILD_PCRECPP) |
ELSE(PCRE_BUILD_PCRECPP) |
378 |
# Remove pcrecpp.3 |
# Remove pcrecpp.3 |
387 |
|
|
388 |
INSTALL(FILES ${man1} DESTINATION man/man1) |
INSTALL(FILES ${man1} DESTINATION man/man1) |
389 |
INSTALL(FILES ${man3} DESTINATION man/man3) |
INSTALL(FILES ${man3} DESTINATION man/man3) |
390 |
INSTALL(FILES ${html} DESTINATION doc/html) |
INSTALL(FILES ${html} DESTINATION share/doc/pcre/html) |
391 |
|
|
392 |
# end CMakeLists.txt |
# end CMakeLists.txt |