/[pcre]/code/trunk/CMakeLists.txt
ViewVC logotype

Contents of /code/trunk/CMakeLists.txt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1028 - (show annotations)
Thu Sep 6 16:55:38 2012 UTC (7 years, 1 month ago) by ph10
File MIME type: text/plain
File size: 30140 byte(s)
Error occurred while calculating annotation data.
Set config.h NEWLINE values appropriately for EBCDIC, adding 
--enable-ebcdic-nl25 (and CMake equivalent) for the alternate NL encoding.
1 # 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 # 2008-01-20 Brought up to date to include several new features by Christian
17 # Ehrlicher.
18 # 2008-01-22 Sheri added options for backward compatibility of library names
19 # when building with minGW:
20 # if "ON", NON_STANDARD_LIB_PREFIX causes shared libraries to
21 # be built without "lib" as prefix. (The libraries will be named
22 # pcre.dll, pcreposix.dll and pcrecpp.dll).
23 # if "ON", NON_STANDARD_LIB_SUFFIX causes shared libraries to
24 # be built with suffix of "-0.dll". (The libraries will be named
25 # libpcre-0.dll, libpcreposix-0.dll and libpcrecpp-0.dll - same names
26 # built by default with Configure and Make.
27 # 2008-01-23 PH removed the automatic build of pcredemo.
28 # 2008-04-22 PH modified READLINE support so it finds NCURSES when needed.
29 # 2008-07-03 PH updated for revised UCP property support (change of files)
30 # 2009-03-23 PH applied Steven Van Ingelgem's patch to change the name
31 # CMAKE_BINARY_DIR to PROJECT_BINARY_DIR so that it works when PCRE
32 # is included within another project.
33 # 2009-03-23 PH applied a modified version of Steven Van Ingelgem's patches to
34 # add options to stop the building of pcregrep and the tests, and
35 # to disable the final configuration report.
36 # 2009-04-11 PH applied Christian Ehrlicher's patch to show compiler flags that
37 # are set by specifying a release type.
38 # 2010-01-02 PH added test for stdint.h
39 # 2010-03-02 PH added test for inttypes.h
40 # 2011-08-01 PH added PCREGREP_BUFSIZE
41 # 2011-08-22 PH added PCRE_SUPPORT_JIT
42 # 2011-09-06 PH modified WIN32 ADD_TEST line as suggested by Sergey Cherepanov
43 # 2011-09-06 PH added PCRE_SUPPORT_PCREGREP_JIT
44 # 2011-10-04 Sheri added support for including coff data in windows shared libraries
45 # compiled with MINGW if pcre.rc and/or pcreposix.rc are placed in
46 # the source dir by the user prior to building
47 # 2011-10-04 Sheri changed various add_test's to use exes' location built instead
48 # of DEBUG location only (likely only matters in MSVC)
49 # 2011-10-04 Sheri added scripts to provide needed variables to RunTest and
50 # RunGrepTest (used for UNIX and Msys)
51 # 2011-10-04 Sheri added scripts to provide needed variables and to execute
52 # RunTest.bat in Win32 (for effortless testing with "make test")
53 # 2011-10-04 Sheri Increased minimum required cmake version
54 # 2012-01-06 PH removed pcre_info.c and added pcre_string_utils.c
55 # 2012-01-10 Zoltan Herczeg added libpcre16 support
56 # 2012-01-13 Stephen Kelly added out of source build support
57 # 2012-01-17 PH applied Stephen Kelly's patch to parse the version data out
58 # of the configure.ac file
59 # 2012-02-26 PH added support for libedit
60 # 2012-09-06 PH added support for PCRE_EBCDIC_NL25
61
62 PROJECT(PCRE C CXX)
63
64 # Increased minimum to 2.8.0 to support newer add_test features
65
66 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0)
67
68 SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # for FindReadline.cmake
69
70 # external packages
71 FIND_PACKAGE( BZip2 )
72 FIND_PACKAGE( ZLIB )
73 FIND_PACKAGE( Readline )
74 FIND_PACKAGE( Editline )
75
76 # Configuration checks
77
78 INCLUDE(CheckIncludeFile)
79 INCLUDE(CheckIncludeFileCXX)
80 INCLUDE(CheckFunctionExists)
81 INCLUDE(CheckTypeSize)
82
83 CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
84 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
85 CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H)
86 CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
87 CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
88 CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
89 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
90
91 CHECK_INCLUDE_FILE_CXX(type_traits.h HAVE_TYPE_TRAITS_H)
92 CHECK_INCLUDE_FILE_CXX(bits/type_traits.h HAVE_BITS_TYPE_TRAITS_H)
93
94 CHECK_FUNCTION_EXISTS(bcopy HAVE_BCOPY)
95 CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE)
96 CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR)
97 CHECK_FUNCTION_EXISTS(strtoll HAVE_STRTOLL)
98 CHECK_FUNCTION_EXISTS(strtoq HAVE_STRTOQ)
99 CHECK_FUNCTION_EXISTS(_strtoi64 HAVE__STRTOI64)
100
101 CHECK_TYPE_SIZE("long long" LONG_LONG)
102 CHECK_TYPE_SIZE("unsigned long long" UNSIGNED_LONG_LONG)
103
104 # User-configurable options
105 #
106 # (Note: CMakeSetup displays these in alphabetical order, regardless of
107 # the order we use here)
108
109 SET(BUILD_SHARED_LIBS OFF CACHE BOOL
110 "Build shared libraries instead of static ones.")
111
112 OPTION(PCRE_BUILD_PCRE8 "Build 8 bit PCRE library" ON)
113
114 OPTION(PCRE_BUILD_PCRE16 "Build 16 bit PCRE library" OFF)
115
116 OPTION(PCRE_BUILD_PCRECPP "Build the PCRE C++ library (pcrecpp)." ON)
117
118 SET(PCRE_EBCDIC OFF CACHE BOOL
119 "Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems.)")
120
121 SET(PCRE_EBCDIC_NL25 OFF CACHE BOOL
122 "Use 0x25 as EBCDIC NL character instead of 0x15; implies EBCDIC.")
123
124 SET(PCRE_LINK_SIZE "2" CACHE STRING
125 "Internal link size (2, 3 or 4 allowed). See LINK_SIZE in config.h.in for details.")
126
127 SET(PCRE_MATCH_LIMIT "10000000" CACHE STRING
128 "Default limit on internal looping. See MATCH_LIMIT in config.h.in for details.")
129
130 SET(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT" CACHE STRING
131 "Default limit on internal recursion. See MATCH_LIMIT_RECURSION in config.h.in for details.")
132
133 SET(PCREGREP_BUFSIZE "20480" CACHE STRING
134 "Buffer size parameter for pcregrep. See PCREGREP_BUFSIZE in config.h.in for details.")
135
136 SET(PCRE_NEWLINE "LF" CACHE STRING
137 "What to recognize as a newline (one of CR, LF, CRLF, ANY, ANYCRLF).")
138
139 SET(PCRE_NO_RECURSE OFF CACHE BOOL
140 "If ON, then don't use stack recursion when matching. See NO_RECURSE in config.h.in for details.")
141
142 SET(PCRE_POSIX_MALLOC_THRESHOLD "10" CACHE STRING
143 "Threshold for malloc() usage. See POSIX_MALLOC_THRESHOLD in config.h.in for details.")
144
145 SET(PCRE_SUPPORT_JIT OFF CACHE BOOL
146 "Enable support for Just-in-time compiling.")
147
148 SET(PCRE_SUPPORT_PCREGREP_JIT ON CACHE BOOL
149 "Enable use of Just-in-time compiling in pcregrep.")
150
151 SET(PCRE_SUPPORT_UTF OFF CACHE BOOL
152 "Enable support for Unicode Transformation Format (UTF-8 and/or UTF-16) encoding.")
153
154 SET(PCRE_SUPPORT_UNICODE_PROPERTIES OFF CACHE BOOL
155 "Enable support for Unicode properties (if set, UTF support will be enabled as well).")
156
157 SET(PCRE_SUPPORT_BSR_ANYCRLF OFF CACHE BOOL
158 "ON=Backslash-R matches only LF CR and CRLF, OFF=Backslash-R matches all Unicode Linebreaks")
159
160 OPTION(PCRE_SHOW_REPORT "Show the final configuration report" ON)
161 OPTION(PCRE_BUILD_PCREGREP "Build pcregrep" ON)
162 OPTION(PCRE_BUILD_TESTS "Build the tests" ON)
163
164 IF (MINGW)
165 OPTION(NON_STANDARD_LIB_PREFIX
166 "ON=Shared libraries built in mingw will be named pcre.dll, etc., instead of libpcre.dll, etc."
167 OFF)
168
169 OPTION(NON_STANDARD_LIB_SUFFIX
170 "ON=Shared libraries built in mingw will be named libpcre-0.dll, etc., instead of libpcre.dll, etc."
171 OFF)
172 ENDIF(MINGW)
173
174 # bzip2 lib
175 IF(BZIP2_FOUND)
176 OPTION (PCRE_SUPPORT_LIBBZ2 "Enable support for linking pcregrep with libbz2." ON)
177 ENDIF(BZIP2_FOUND)
178 IF(PCRE_SUPPORT_LIBBZ2)
179 INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR})
180 ENDIF(PCRE_SUPPORT_LIBBZ2)
181
182 # zlib
183 IF(ZLIB_FOUND)
184 OPTION (PCRE_SUPPORT_LIBZ "Enable support for linking pcregrep with libz." ON)
185 ENDIF(ZLIB_FOUND)
186 IF(PCRE_SUPPORT_LIBZ)
187 INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
188 ENDIF(PCRE_SUPPORT_LIBZ)
189
190 # editline lib
191 IF(EDITLINE_FOUND)
192 OPTION (PCRE_SUPPORT_LIBEDIT "Enable support for linking pcretest with libedit." OFF)
193 ENDIF(EDITLINE_FOUND)
194 IF(PCRE_SUPPORT_LIBEDIT)
195 INCLUDE_DIRECTORIES(${EDITLINE_INCLUDE_DIR})
196 ENDIF(PCRE_SUPPORT_LIBEDIT)
197
198 # readline lib
199 IF(READLINE_FOUND)
200 OPTION (PCRE_SUPPORT_LIBREADLINE "Enable support for linking pcretest with libreadline." ON)
201 ENDIF(READLINE_FOUND)
202 IF(PCRE_SUPPORT_LIBREADLINE)
203 INCLUDE_DIRECTORIES(${READLINE_INCLUDE_DIR})
204 ENDIF(PCRE_SUPPORT_LIBREADLINE)
205
206 # Prepare build configuration
207
208 SET(pcre_have_type_traits 0)
209 SET(pcre_have_bits_type_traits 0)
210
211 IF(HAVE_TYPE_TRAITS_H)
212 SET(pcre_have_type_traits 1)
213 ENDIF(HAVE_TYPE_TRAITS_H)
214
215 IF(HAVE_BITS_TYPE_TRAITS_H)
216 SET(pcre_have_bits_type_traits 1)
217 ENDIF(HAVE_BITS_TYPE_TRAITS_H)
218
219 SET(pcre_have_long_long 0)
220 SET(pcre_have_ulong_long 0)
221
222 IF(HAVE_LONG_LONG)
223 SET(pcre_have_long_long 1)
224 ENDIF(HAVE_LONG_LONG)
225
226 IF(HAVE_UNSIGNED_LONG_LONG)
227 SET(pcre_have_ulong_long 1)
228 ENDIF(HAVE_UNSIGNED_LONG_LONG)
229
230 IF(NOT BUILD_SHARED_LIBS)
231 SET(PCRE_STATIC 1)
232 ENDIF(NOT BUILD_SHARED_LIBS)
233
234 IF(NOT PCRE_BUILD_PCRE8 AND NOT PCRE_BUILD_PCRE16)
235 MESSAGE(FATAL_ERROR "Either PCRE_BUILD_PCRE8 or PCRE_BUILD_PCRE16 must be enabled")
236 ENDIF(NOT PCRE_BUILD_PCRE8 AND NOT PCRE_BUILD_PCRE16)
237
238 IF(PCRE_BUILD_PCRE8)
239 SET(SUPPORT_PCRE8 1)
240 ENDIF(PCRE_BUILD_PCRE8)
241
242 IF(PCRE_BUILD_PCRE16)
243 SET(SUPPORT_PCRE16 1)
244 ENDIF(PCRE_BUILD_PCRE16)
245
246 IF(PCRE_BUILD_PCRECPP AND NOT PCRE_BUILD_PCRE8)
247 MESSAGE(STATUS "** PCRE_BUILD_PCRE8 must be enabled for the C++ library support")
248 SET(PCRE_BUILD_PCRECPP OFF)
249 ENDIF(PCRE_BUILD_PCRECPP AND NOT PCRE_BUILD_PCRE8)
250
251 IF(PCRE_BUILD_PCREGREP AND NOT PCRE_BUILD_PCRE8)
252 MESSAGE(STATUS "** PCRE_BUILD_PCRE8 must be enabled for the pcregrep program")
253 SET(PCRE_BUILD_PCREGREP OFF)
254 ENDIF(PCRE_BUILD_PCREGREP AND NOT PCRE_BUILD_PCRE8)
255
256 IF(PCRE_SUPPORT_LIBREADLINE AND PCRE_SUPPORT_LIBEDIT)
257 MESSAGE(FATAL_ERROR "Only one of libreadline or libeditline can be specified")
258 ENDIF(PCRE_SUPPORT_LIBREADLINE AND PCRE_SUPPORT_LIBEDIT)
259
260 IF(PCRE_SUPPORT_BSR_ANYCRLF)
261 SET(BSR_ANYCRLF 1)
262 ENDIF(PCRE_SUPPORT_BSR_ANYCRLF)
263
264 IF(PCRE_SUPPORT_UTF OR PCRE_SUPPORT_UNICODE_PROPERTIES)
265 SET(SUPPORT_UTF 1)
266 SET(PCRE_SUPPORT_UTF ON)
267 ENDIF(PCRE_SUPPORT_UTF OR PCRE_SUPPORT_UNICODE_PROPERTIES)
268
269 IF(PCRE_SUPPORT_UNICODE_PROPERTIES)
270 SET(SUPPORT_UCP 1)
271 ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES)
272
273 IF(PCRE_SUPPORT_JIT)
274 SET(SUPPORT_JIT 1)
275 ENDIF(PCRE_SUPPORT_JIT)
276
277 IF(PCRE_SUPPORT_PCREGREP_JIT)
278 SET(SUPPORT_PCREGREP_JIT 1)
279 ENDIF(PCRE_SUPPORT_PCREGREP_JIT)
280
281 # This next one used to contain
282 # SET(PCRETEST_LIBS ${READLINE_LIBRARY})
283 # but I was advised to add the NCURSES test as well, along with
284 # some modifications to cmake/FindReadline.cmake which should
285 # make it possible to override the default if necessary. PH
286
287 IF(PCRE_SUPPORT_LIBREADLINE)
288 SET(SUPPORT_LIBREADLINE 1)
289 SET(PCRETEST_LIBS ${READLINE_LIBRARY} ${NCURSES_LIBRARY})
290 ENDIF(PCRE_SUPPORT_LIBREADLINE)
291
292 # libedit is a plug-compatible alternative to libreadline
293
294 IF(PCRE_SUPPORT_LIBEDIT)
295 SET(SUPPORT_LIBEDIT 1)
296 SET(PCRETEST_LIBS ${EDITLINE_LIBRARY} ${NCURSES_LIBRARY})
297 ENDIF(PCRE_SUPPORT_LIBEDIT)
298
299 IF(PCRE_SUPPORT_LIBZ)
300 SET(SUPPORT_LIBZ 1)
301 SET(PCREGREP_LIBS ${PCREGREP_LIBS} ${ZLIB_LIBRARIES})
302 ENDIF(PCRE_SUPPORT_LIBZ)
303
304 IF(PCRE_SUPPORT_LIBBZ2)
305 SET(SUPPORT_LIBBZ2 1)
306 SET(PCREGREP_LIBS ${PCREGREP_LIBS} ${BZIP2_LIBRARIES})
307 ENDIF(PCRE_SUPPORT_LIBBZ2)
308
309 SET(NEWLINE "")
310
311 IF(PCRE_NEWLINE STREQUAL "LF")
312 SET(NEWLINE "10")
313 ENDIF(PCRE_NEWLINE STREQUAL "LF")
314 IF(PCRE_NEWLINE STREQUAL "CR")
315 SET(NEWLINE "13")
316 ENDIF(PCRE_NEWLINE STREQUAL "CR")
317 IF(PCRE_NEWLINE STREQUAL "CRLF")
318 SET(NEWLINE "3338")
319 ENDIF(PCRE_NEWLINE STREQUAL "CRLF")
320 IF(PCRE_NEWLINE STREQUAL "ANY")
321 SET(NEWLINE "-1")
322 ENDIF(PCRE_NEWLINE STREQUAL "ANY")
323 IF(PCRE_NEWLINE STREQUAL "ANYCRLF")
324 SET(NEWLINE "-2")
325 ENDIF(PCRE_NEWLINE STREQUAL "ANYCRLF")
326
327 IF(NEWLINE STREQUAL "")
328 MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".")
329 ENDIF(NEWLINE STREQUAL "")
330
331 IF(PCRE_EBCDIC)
332 SET(EBCDIC 1)
333 IF(PCRE_NEWLINE STREQUAL "LF")
334 SET(NEWLINE "21")
335 ENDIF(PCRE_NEWLINE STREQUAL "LF")
336 IF(PCRE_NEWLINE STREQUAL "CRLF")
337 SET(NEWLINE "3349")
338 ENDIF(PCRE_NEWLINE STREQUAL "CRLF")
339 ENDIF(PCRE_EBCDIC)
340
341 IF(PCRE_EBCDIC_NL25)
342 SET(EBCDIC 1)
343 SET(EBCDIC_NL25 1)
344 IF(PCRE_NEWLINE STREQUAL "LF")
345 SET(NEWLINE "37")
346 ENDIF(PCRE_NEWLINE STREQUAL "LF")
347 IF(PCRE_NEWLINE STREQUAL "CRLF")
348 SET(NEWLINE "3365")
349 ENDIF(PCRE_NEWLINE STREQUAL "CRLF")
350 ENDIF(PCRE_EBCDIC_NL25)
351
352 IF(PCRE_NO_RECURSE)
353 SET(NO_RECURSE 1)
354 ENDIF(PCRE_NO_RECURSE)
355
356 # Output files
357 CONFIGURE_FILE(config-cmake.h.in
358 ${PROJECT_BINARY_DIR}/config.h
359 @ONLY)
360
361 # Parse version numbers and date out of configure.ac
362
363 file(STRINGS ${PROJECT_SOURCE_DIR}/configure.ac
364 configure_lines
365 LIMIT_COUNT 50 # Read only the first 50 lines of the file
366 )
367
368 set(SEARCHED_VARIABLES "pcre_major" "pcre_minor" "pcre_prerelease" "pcre_date")
369 foreach(configure_line ${configure_lines})
370 foreach(_substitution_variable ${SEARCHED_VARIABLES})
371 string(TOUPPER ${_substitution_variable} _substitution_variable_upper)
372 if (NOT ${_substitution_variable_upper})
373 string(REGEX MATCH "m4_define\\(${_substitution_variable}, \\[(.*)\\]" MACTHED_STRING ${configure_line})
374 if (CMAKE_MATCH_1)
375 set(${_substitution_variable_upper} ${CMAKE_MATCH_1})
376 endif()
377 endif()
378 endforeach()
379 endforeach()
380
381 CONFIGURE_FILE(pcre.h.in
382 ${PROJECT_BINARY_DIR}/pcre.h
383 @ONLY)
384
385 # What about pcre-config and libpcre.pc?
386
387 IF(PCRE_BUILD_PCRECPP)
388 CONFIGURE_FILE(pcre_stringpiece.h.in
389 ${PROJECT_BINARY_DIR}/pcre_stringpiece.h
390 @ONLY)
391
392 CONFIGURE_FILE(pcrecpparg.h.in
393 ${PROJECT_BINARY_DIR}/pcrecpparg.h
394 @ONLY)
395 ENDIF(PCRE_BUILD_PCRECPP)
396
397 # Character table generation
398
399 OPTION(PCRE_REBUILD_CHARTABLES "Rebuild char tables" OFF)
400 IF(PCRE_REBUILD_CHARTABLES)
401 ADD_EXECUTABLE(dftables dftables.c)
402
403 GET_TARGET_PROPERTY(DFTABLES_EXE dftables LOCATION)
404
405 ADD_CUSTOM_COMMAND(
406 COMMENT "Generating character tables (pcre_chartables.c) for current locale"
407 DEPENDS dftables
408 COMMAND ${DFTABLES_EXE}
409 ARGS ${PROJECT_BINARY_DIR}/pcre_chartables.c
410 OUTPUT ${PROJECT_BINARY_DIR}/pcre_chartables.c
411 )
412 ELSE(PCRE_REBUILD_CHARTABLES)
413 CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/pcre_chartables.c.dist
414 ${PROJECT_BINARY_DIR}/pcre_chartables.c
415 COPYONLY)
416 ENDIF(PCRE_REBUILD_CHARTABLES)
417
418 # Source code
419
420 SET(PCRE_HEADERS ${PROJECT_BINARY_DIR}/pcre.h)
421
422 IF(PCRE_BUILD_PCRE8)
423 SET(PCRE_SOURCES
424 pcre_byte_order.c
425 pcre_chartables.c
426 pcre_compile.c
427 pcre_config.c
428 pcre_dfa_exec.c
429 pcre_exec.c
430 pcre_fullinfo.c
431 pcre_get.c
432 pcre_globals.c
433 pcre_jit_compile.c
434 pcre_maketables.c
435 pcre_newline.c
436 pcre_ord2utf8.c
437 pcre_refcount.c
438 pcre_string_utils.c
439 pcre_study.c
440 pcre_tables.c
441 pcre_ucd.c
442 pcre_valid_utf8.c
443 pcre_version.c
444 pcre_xclass.c
445 )
446
447 SET(PCREPOSIX_HEADERS pcreposix.h)
448
449 SET(PCREPOSIX_SOURCES pcreposix.c)
450
451 ENDIF(PCRE_BUILD_PCRE8)
452
453 IF(PCRE_BUILD_PCRE16)
454 SET(PCRE16_SOURCES
455 pcre16_byte_order.c
456 pcre16_chartables.c
457 pcre16_compile.c
458 pcre16_config.c
459 pcre16_dfa_exec.c
460 pcre16_exec.c
461 pcre16_fullinfo.c
462 pcre16_get.c
463 pcre16_globals.c
464 pcre16_jit_compile.c
465 pcre16_maketables.c
466 pcre16_newline.c
467 pcre16_ord2utf16.c
468 pcre16_refcount.c
469 pcre16_string_utils.c
470 pcre16_study.c
471 pcre16_tables.c
472 pcre16_ucd.c
473 pcre16_utf16_utils.c
474 pcre16_valid_utf16.c
475 pcre16_version.c
476 pcre16_xclass.c
477 )
478 ENDIF(PCRE_BUILD_PCRE16)
479
480 IF(MINGW AND NOT PCRE_STATIC)
481 IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc)
482 ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcre.o
483 PRE-LINK
484 COMMAND windres ARGS pcre.rc pcre.o
485 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
486 COMMENT Using pcre coff info in mingw build)
487 SET(PCRE_SOURCES
488 ${PCRE_SOURCES} ${PROJECT_SOURCE_DIR}/pcre.o
489 )
490 ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc)
491 IF (EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc)
492 ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcreposix.o
493 PRE-LINK
494 COMMAND windres ARGS pcreposix.rc pcreposix.o
495 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
496 COMMENT Using pcreposix coff info in mingw build)
497 SET(PCREPOSIX_SOURCES
498 ${PCREPOSIX_SOURCES} ${PROJECT_SOURCE_DIR}/pcreposix.o
499 )
500 ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc)
501 ENDIF(MINGW AND NOT PCRE_STATIC)
502
503 SET(PCRECPP_HEADERS
504 pcrecpp.h
505 pcre_scanner.h
506 ${PROJECT_BINARY_DIR}/pcrecpparg.h
507 ${PROJECT_BINARY_DIR}/pcre_stringpiece.h
508 )
509
510 SET(PCRECPP_SOURCES
511 pcrecpp.cc
512 pcre_scanner.cc
513 pcre_stringpiece.cc
514 )
515
516 # Build setup
517
518 ADD_DEFINITIONS(-DHAVE_CONFIG_H)
519
520 IF(MSVC)
521 ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
522 ENDIF(MSVC)
523
524 SET(CMAKE_INCLUDE_CURRENT_DIR 1)
525 # needed to make sure to not link debug libs
526 # against release libs and vice versa
527 IF(WIN32)
528 SET(CMAKE_DEBUG_POSTFIX "d")
529 ENDIF(WIN32)
530
531 SET(targets)
532
533 # Libraries
534 # pcre
535 IF(PCRE_BUILD_PCRE8)
536 ADD_LIBRARY(pcre ${PCRE_HEADERS} ${PCRE_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
537 SET(targets ${targets} pcre)
538 ADD_LIBRARY(pcreposix ${PCREPOSIX_HEADERS} ${PCREPOSIX_SOURCES})
539 SET(targets ${targets} pcreposix)
540 TARGET_LINK_LIBRARIES(pcreposix pcre)
541
542 IF(MINGW AND NOT PCRE_STATIC)
543 IF(NON_STANDARD_LIB_PREFIX)
544 SET_TARGET_PROPERTIES(pcre pcreposix
545 PROPERTIES PREFIX ""
546 )
547 ENDIF(NON_STANDARD_LIB_PREFIX)
548
549 IF(NON_STANDARD_LIB_SUFFIX)
550 SET_TARGET_PROPERTIES(pcre pcreposix
551 PROPERTIES SUFFIX "-0.dll"
552 )
553 ENDIF(NON_STANDARD_LIB_SUFFIX)
554 ENDIF(MINGW AND NOT PCRE_STATIC)
555
556 ENDIF(PCRE_BUILD_PCRE8)
557
558 IF(PCRE_BUILD_PCRE16)
559 ADD_LIBRARY(pcre16 ${PCRE_HEADERS} ${PCRE16_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
560 SET(targets ${targets} pcre16)
561
562 IF(MINGW AND NOT PCRE_STATIC)
563 IF(NON_STANDARD_LIB_PREFIX)
564 SET_TARGET_PROPERTIES(pcre16
565 PROPERTIES PREFIX ""
566 )
567 ENDIF(NON_STANDARD_LIB_PREFIX)
568
569 IF(NON_STANDARD_LIB_SUFFIX)
570 SET_TARGET_PROPERTIES(pcre16
571 PROPERTIES SUFFIX "-0.dll"
572 )
573 ENDIF(NON_STANDARD_LIB_SUFFIX)
574 ENDIF(MINGW AND NOT PCRE_STATIC)
575
576 ENDIF(PCRE_BUILD_PCRE16)
577
578 # pcrecpp
579 IF(PCRE_BUILD_PCRECPP)
580 ADD_LIBRARY(pcrecpp ${PCRECPP_HEADERS} ${PCRECPP_SOURCES})
581 SET(targets ${targets} pcrecpp)
582 TARGET_LINK_LIBRARIES(pcrecpp pcre)
583
584 IF(MINGW AND NOT PCRE_STATIC)
585 IF(NON_STANDARD_LIB_PREFIX)
586 SET_TARGET_PROPERTIES(pcrecpp
587 PROPERTIES PREFIX ""
588 )
589 ENDIF(NON_STANDARD_LIB_PREFIX)
590
591 IF(NON_STANDARD_LIB_SUFFIX)
592 SET_TARGET_PROPERTIES(pcrecpp
593 PROPERTIES SUFFIX "-0.dll"
594 )
595 ENDIF(NON_STANDARD_LIB_SUFFIX)
596 ENDIF(MINGW AND NOT PCRE_STATIC)
597 ENDIF(PCRE_BUILD_PCRECPP)
598
599
600 # Executables
601
602 # Removed by PH (2008-01-23) because pcredemo shouldn't really be built
603 # automatically, and it gave trouble in some environments anyway.
604 # ADD_EXECUTABLE(pcredemo pcredemo.c)
605 # TARGET_LINK_LIBRARIES(pcredemo pcreposix)
606 # IF(NOT BUILD_SHARED_LIBS)
607 # # make sure to not use declspec(dllimport) in static mode on windows
608 # SET_TARGET_PROPERTIES(pcredemo PROPERTIES COMPILE_FLAGS "-DPCRE_STATIC")
609 # ENDIF(NOT BUILD_SHARED_LIBS)
610
611 IF(PCRE_BUILD_PCREGREP)
612 ADD_EXECUTABLE(pcregrep pcregrep.c)
613 SET(targets ${targets} pcregrep)
614 TARGET_LINK_LIBRARIES(pcregrep pcreposix ${PCREGREP_LIBS})
615 ENDIF(PCRE_BUILD_PCREGREP)
616
617 # Testing
618 IF(PCRE_BUILD_TESTS)
619 ENABLE_TESTING()
620
621 SET(PCRETEST_SOURCES pcretest.c)
622 IF(PCRE_BUILD_PCRE8)
623 LIST(APPEND PCRETEST_SOURCES pcre_printint.c)
624 ENDIF(PCRE_BUILD_PCRE8)
625 IF(PCRE_BUILD_PCRE16)
626 LIST(APPEND PCRETEST_SOURCES pcre16_printint.c)
627 ENDIF(PCRE_BUILD_PCRE16)
628
629 ADD_EXECUTABLE(pcretest ${PCRETEST_SOURCES})
630 SET(targets ${targets} pcretest)
631 IF(PCRE_BUILD_PCRE8)
632 LIST(APPEND PCRETEST_LIBS pcreposix pcre)
633 ENDIF(PCRE_BUILD_PCRE8)
634 IF(PCRE_BUILD_PCRE16)
635 LIST(APPEND PCRETEST_LIBS pcre16)
636 ENDIF(PCRE_BUILD_PCRE16)
637 TARGET_LINK_LIBRARIES(pcretest ${PCRETEST_LIBS})
638
639 IF(PCRE_SUPPORT_JIT)
640 ADD_EXECUTABLE(pcre_jit_test pcre_jit_test.c)
641 SET(targets ${targets} pcre_jit_test)
642 SET(PCRE_JIT_TEST_LIBS )
643 IF(PCRE_BUILD_PCRE8)
644 LIST(APPEND PCRE_JIT_TEST_LIBS pcre)
645 ENDIF(PCRE_BUILD_PCRE8)
646 IF(PCRE_BUILD_PCRE16)
647 LIST(APPEND PCRE_JIT_TEST_LIBS pcre16)
648 ENDIF(PCRE_BUILD_PCRE16)
649 TARGET_LINK_LIBRARIES(pcre_jit_test ${PCRE_JIT_TEST_LIBS})
650 ENDIF(PCRE_SUPPORT_JIT)
651
652 IF(PCRE_BUILD_PCRECPP)
653 ADD_EXECUTABLE(pcrecpp_unittest pcrecpp_unittest.cc)
654 SET(targets ${targets} pcrecpp_unittest)
655 TARGET_LINK_LIBRARIES(pcrecpp_unittest pcrecpp)
656 IF(MINGW AND NON_STANDARD_LIB_NAMES AND NOT PCRE_STATIC)
657 SET_TARGET_PROPERTIES(pcrecpp
658 PROPERTIES PREFIX ""
659 )
660 ENDIF(MINGW AND NON_STANDARD_LIB_NAMES AND NOT PCRE_STATIC)
661
662 ADD_EXECUTABLE(pcre_scanner_unittest pcre_scanner_unittest.cc)
663 SET(targets ${targets} pcre_scanner_unittest)
664 TARGET_LINK_LIBRARIES(pcre_scanner_unittest pcrecpp)
665
666 ADD_EXECUTABLE(pcre_stringpiece_unittest pcre_stringpiece_unittest.cc)
667 SET(targets ${targets} pcre_stringpiece_unittest)
668 TARGET_LINK_LIBRARIES(pcre_stringpiece_unittest pcrecpp)
669 ENDIF(PCRE_BUILD_PCRECPP)
670
671 # exes in Debug location tested by the RunTest shell script
672 # via "make test"
673 IF(PCRE_BUILD_PCREGREP)
674 GET_TARGET_PROPERTY(PCREGREP_EXE pcregrep DEBUG_LOCATION)
675 ENDIF(PCRE_BUILD_PCREGREP)
676
677 GET_TARGET_PROPERTY(PCRETEST_EXE pcretest DEBUG_LOCATION)
678
679 # =================================================
680 # Write out a CTest configuration file
681 #
682 FILE(WRITE ${PROJECT_BINARY_DIR}/CTestCustom.ctest
683 "# This is a generated file.
684 MESSAGE(\"When testing is complete, review test output in the
685 ${PROJECT_BINARY_DIR}/Testing/Temporary folder.\")
686 MESSAGE(\"\")
687 ")
688
689 FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_test.sh
690 "#! /bin/sh
691 # This is a generated file.
692 srcdir=${PROJECT_SOURCE_DIR}
693 pcretest=${PCRETEST_EXE}
694 source ${PROJECT_SOURCE_DIR}/RunTest
695 if test \"$?\" != \"0\"; then exit 1; fi
696 # End
697 ")
698
699 IF(UNIX)
700 ADD_TEST(pcre_test sh ${PROJECT_BINARY_DIR}/pcre_test.sh)
701 ENDIF(UNIX)
702
703 IF(PCRE_BUILD_PCREGREP)
704 FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_grep_test.sh
705 "#! /bin/sh
706 # This is a generated file.
707 srcdir=${PROJECT_SOURCE_DIR}
708 pcregrep=${PCREGREP_EXE}
709 pcretest=${PCRETEST_EXE}
710 source ${PROJECT_SOURCE_DIR}/RunGrepTest
711 if test \"$?\" != \"0\"; then exit 1; fi
712 # End
713 ")
714
715 IF(UNIX)
716 ADD_TEST(pcre_grep_test sh ${PROJECT_BINARY_DIR}/pcre_grep_test.sh)
717 ENDIF(UNIX)
718 ENDIF(PCRE_BUILD_PCREGREP)
719
720 IF(WIN32)
721 # Provide environment for executing the bat file version of RunTest
722 string(REPLACE "/" "\\" winsrc "${PROJECT_SOURCE_DIR}")
723
724 FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_test.txt
725 "\@REM This is a generated file.
726 \@Echo off
727 setlocal
728 SET\ srcdir=\${srcdir}
729 SET\ pcretest=\${pcretest}
730 call \"\${srcdir}\\RunTest.Bat\"
731 if errorlevel 1 exit /b 1
732 echo RunTest.bat tests successfully completed
733 ")
734
735 FILE(WRITE ${PROJECT_BINARY_DIR}/BatDriver.cmake
736 "# This is a generated file.
737 # this script is run with arguments via the cmake command in add_test(NAME pcre_test_bat)
738 # BatDriver feeds the actual location of pcretest.exe
739 FILE(TO_NATIVE_PATH \${pcretestx} pcretest)
740 FILE(TO_NATIVE_PATH \${srcdirx} srcdir)
741 configure_file(\"\${bindirx}/pcre_test.txt\" \"\${bindirx}/pcre_test.bat\")
742 # MESSAGE(\"cmake\ variable\ pcretest\ is\ \${pcretest}\")
743 # STRING(REPLACE \" \" \"\\ \" bindir \${bindirx})
744 MESSAGE(\"COMMAND pcre_test.bat \")
745 EXECUTE_PROCESS(COMMAND pcre_test.bat
746 WORKING_DIRECTORY .
747 OUTPUT_VARIABLE batoutput)
748 MESSAGE(\"OUTPUT: \${batoutput}\")
749 ")
750
751 ADD_TEST(NAME pcre_test_bat
752 COMMAND ${CMAKE_COMMAND} -D bindirx=${PROJECT_BINARY_DIR} -D srcdirx=${PROJECT_SOURCE_DIR} -D pcretestx=$<TARGET_FILE:pcretest> -P "${PROJECT_BINARY_DIR}/BatDriver.cmake")
753 SET_TESTS_PROPERTIES(pcre_test_bat PROPERTIES
754 PASS_REGULAR_EXPRESSION "RunTest\\.bat tests successfully completed")
755
756 IF("$ENV{OSTYPE}" STREQUAL "msys")
757 # Both the sh and bat file versions of RunTest are run if make test is used
758 # in msys
759 ADD_TEST(pcre_test_sh sh.exe ${PROJECT_BINARY_DIR}/pcre_test.sh)
760 IF(PCRE_BUILD_PCREGREP)
761 ADD_TEST(pcre_grep_test sh.exe ${PROJECT_BINARY_DIR}/pcre_grep_test.sh)
762 ENDIF(PCRE_BUILD_PCREGREP)
763 ENDIF("$ENV{OSTYPE}" STREQUAL "msys")
764
765 ENDIF(WIN32)
766
767 # Changed to accommodate testing whichever location was just built
768
769 IF(PCRE_SUPPORT_JIT)
770 ADD_TEST(pcre_jit_test pcre_jit_test)
771 ENDIF(PCRE_SUPPORT_JIT)
772
773 IF(PCRE_BUILD_PCRECPP)
774 ADD_TEST(pcrecpp_test pcrecpp_unittest)
775 ADD_TEST(pcre_scanner_test pcre_scanner_unittest)
776 ADD_TEST(pcre_stringpiece_test pcre_stringpiece_unittest)
777 ENDIF(PCRE_BUILD_PCRECPP)
778
779 ENDIF(PCRE_BUILD_TESTS)
780
781 # Installation
782 SET(CMAKE_INSTALL_ALWAYS 1)
783
784 INSTALL(TARGETS ${targets}
785 RUNTIME DESTINATION bin
786 LIBRARY DESTINATION lib
787 ARCHIVE DESTINATION lib)
788
789 INSTALL(FILES ${PCRE_HEADERS} ${PCREPOSIX_HEADERS} DESTINATION include)
790
791 FILE(GLOB html ${PROJECT_SOURCE_DIR}/doc/html/*.html)
792 FILE(GLOB man1 ${PROJECT_SOURCE_DIR}/doc/*.1)
793 FILE(GLOB man3 ${PROJECT_SOURCE_DIR}/doc/*.3)
794
795 IF(PCRE_BUILD_PCRECPP)
796 INSTALL(FILES ${PCRECPP_HEADERS} DESTINATION include)
797 ELSE(PCRE_BUILD_PCRECPP)
798 # Remove pcrecpp.3
799 FOREACH(man ${man3})
800 GET_FILENAME_COMPONENT(man_tmp ${man} NAME)
801 IF(NOT man_tmp STREQUAL "pcrecpp.3")
802 SET(man3_new ${man3} ${man})
803 ENDIF(NOT man_tmp STREQUAL "pcrecpp.3")
804 ENDFOREACH(man ${man3})
805 SET(man3 ${man3_new})
806 ENDIF(PCRE_BUILD_PCRECPP)
807
808 INSTALL(FILES ${man1} DESTINATION man/man1)
809 INSTALL(FILES ${man3} DESTINATION man/man3)
810 INSTALL(FILES ${html} DESTINATION share/doc/pcre/html)
811
812 # help, only for nice output
813 IF(BUILD_SHARED_LIBS)
814 SET(BUILD_STATIC_LIBS OFF)
815 ELSE(BUILD_SHARED_LIBS)
816 SET(BUILD_STATIC_LIBS ON)
817 ENDIF(BUILD_SHARED_LIBS)
818
819 IF(PCRE_SHOW_REPORT)
820 STRING(TOUPPER "${CMAKE_BUILD_TYPE}" buildtype)
821 IF (CMAKE_C_FLAGS)
822 SET(cfsp " ")
823 ENDIF(CMAKE_C_FLAGS)
824 IF (CMAKE_CXX_FLAGS)
825 SET(cxxfsp " ")
826 ENDIF(CMAKE_CXX_FLAGS)
827 MESSAGE(STATUS "")
828 MESSAGE(STATUS "")
829 MESSAGE(STATUS "PCRE configuration summary:")
830 MESSAGE(STATUS "")
831 MESSAGE(STATUS " Install prefix .................. : ${CMAKE_INSTALL_PREFIX}")
832 MESSAGE(STATUS " C compiler ...................... : ${CMAKE_C_COMPILER}")
833 MESSAGE(STATUS " C++ compiler .................... : ${CMAKE_CXX_COMPILER}")
834 MESSAGE(STATUS " C compiler flags ................ : ${CMAKE_C_FLAGS}${cfsp}${CMAKE_C_FLAGS_${buildtype}}")
835 MESSAGE(STATUS " C++ compiler flags .............. : ${CMAKE_CXX_FLAGS}${cxxfsp}${CMAKE_CXX_FLAGS_${buildtype}}")
836 MESSAGE(STATUS "")
837 MESSAGE(STATUS " Build 8 bit PCRE library ........ : ${PCRE_BUILD_PCRE8}")
838 MESSAGE(STATUS " Build 16 bit PCRE library ....... : ${PCRE_BUILD_PCRE16}")
839 MESSAGE(STATUS " Build C++ library ............... : ${PCRE_BUILD_PCRECPP}")
840 MESSAGE(STATUS " Enable JIT compiling support .... : ${PCRE_SUPPORT_JIT}")
841 MESSAGE(STATUS " Enable UTF support .............. : ${PCRE_SUPPORT_UTF}")
842 MESSAGE(STATUS " Unicode properties .............. : ${PCRE_SUPPORT_UNICODE_PROPERTIES}")
843 MESSAGE(STATUS " Newline char/sequence ........... : ${PCRE_NEWLINE}")
844 MESSAGE(STATUS " \\R matches only ANYCRLF ......... : ${PCRE_SUPPORT_BSR_ANYCRLF}")
845 MESSAGE(STATUS " EBCDIC coding ................... : ${PCRE_EBCDIC}")
846 MESSAGE(STATUS " EBCDIC coding with NL=0x25 ...... : ${PCRE_EBCDIC_NL25}")
847 MESSAGE(STATUS " Rebuild char tables ............. : ${PCRE_REBUILD_CHARTABLES}")
848 MESSAGE(STATUS " No stack recursion .............. : ${PCRE_NO_RECURSE}")
849 MESSAGE(STATUS " POSIX mem threshold ............. : ${PCRE_POSIX_MALLOC_THRESHOLD}")
850 MESSAGE(STATUS " Internal link size .............. : ${PCRE_LINK_SIZE}")
851 MESSAGE(STATUS " Match limit ..................... : ${PCRE_MATCH_LIMIT}")
852 MESSAGE(STATUS " Match limit recursion ........... : ${PCRE_MATCH_LIMIT_RECURSION}")
853 MESSAGE(STATUS " Build shared libs ............... : ${BUILD_SHARED_LIBS}")
854 MESSAGE(STATUS " Build static libs ............... : ${BUILD_STATIC_LIBS}")
855 MESSAGE(STATUS " Build pcregrep .................. : ${PCRE_BUILD_PCREGREP}")
856 MESSAGE(STATUS " Enable JIT in pcregrep .......... : ${PCRE_SUPPORT_PCREGREP_JIT}")
857 MESSAGE(STATUS " Buffer size for pcregrep ........ : ${PCREGREP_BUFSIZE}")
858 MESSAGE(STATUS " Build tests (implies pcretest .. : ${PCRE_BUILD_TESTS}")
859 MESSAGE(STATUS " and pcregrep)")
860 IF(ZLIB_FOUND)
861 MESSAGE(STATUS " Link pcregrep with libz ......... : ${PCRE_SUPPORT_LIBZ}")
862 ELSE(ZLIB_FOUND)
863 MESSAGE(STATUS " Link pcregrep with libz ......... : Library not found" )
864 ENDIF(ZLIB_FOUND)
865 IF(BZIP2_FOUND)
866 MESSAGE(STATUS " Link pcregrep with libbz2 ....... : ${PCRE_SUPPORT_LIBBZ2}")
867 ELSE(BZIP2_FOUND)
868 MESSAGE(STATUS " Link pcregrep with libbz2 ....... : Library not found" )
869 ENDIF(BZIP2_FOUND)
870 IF(EDITLINE_FOUND)
871 MESSAGE(STATUS " Link pcretest with libeditline .. : ${PCRE_SUPPORT_LIBEDIT}")
872 ELSE(EDITLINE_FOUND)
873 MESSAGE(STATUS " Link pcretest with libeditline .. : Library not found" )
874 ENDIF(EDITLINE_FOUND)
875 IF(READLINE_FOUND)
876 MESSAGE(STATUS " Link pcretest with libreadline .. : ${PCRE_SUPPORT_LIBREADLINE}")
877 ELSE(READLINE_FOUND)
878 MESSAGE(STATUS " Link pcretest with libreadline .. : Library not found" )
879 ENDIF(READLINE_FOUND)
880
881 IF(MINGW AND NOT PCRE_STATIC)
882 MESSAGE(STATUS " Non-standard dll names (prefix) . : ${NON_STANDARD_LIB_PREFIX}")
883 MESSAGE(STATUS " Non-standard dll names (suffix) . : ${NON_STANDARD_LIB_SUFFIX}")
884 ENDIF(MINGW AND NOT PCRE_STATIC)
885 MESSAGE(STATUS "")
886 ENDIF(PCRE_SHOW_REPORT)
887
888 # end CMakeLists.txt

  ViewVC Help
Powered by ViewVC 1.1.5