/[pcre]/code/branches/pcre16/CMakeLists.txt
ViewVC logotype

Contents of /code/branches/pcre16/CMakeLists.txt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 755 - (show annotations) (download)
Mon Nov 21 10:41:54 2011 UTC (2 years, 5 months ago) by ph10
File MIME type: text/plain
File size: 24794 byte(s)
Created a new branch for the development of 16-bit support.

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
55 PROJECT(PCRE C CXX)
56
57 # Increased minimum to 2.8.0 to support newer add_test features
58
59 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0)
60
61 SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # for FindReadline.cmake
62
63 # external packages
64 FIND_PACKAGE( BZip2 )
65 FIND_PACKAGE( ZLIB )
66 FIND_PACKAGE( Readline )
67
68 # Configuration checks
69
70 INCLUDE(CheckIncludeFile)
71 INCLUDE(CheckIncludeFileCXX)
72 INCLUDE(CheckFunctionExists)
73 INCLUDE(CheckTypeSize)
74
75 CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
76 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
77 CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H)
78 CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
79 CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
80 CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
81 CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
82
83 CHECK_INCLUDE_FILE_CXX(type_traits.h HAVE_TYPE_TRAITS_H)
84 CHECK_INCLUDE_FILE_CXX(bits/type_traits.h HAVE_BITS_TYPE_TRAITS_H)
85
86 CHECK_FUNCTION_EXISTS(bcopy HAVE_BCOPY)
87 CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE)
88 CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR)
89 CHECK_FUNCTION_EXISTS(strtoll HAVE_STRTOLL)
90 CHECK_FUNCTION_EXISTS(strtoq HAVE_STRTOQ)
91 CHECK_FUNCTION_EXISTS(_strtoi64 HAVE__STRTOI64)
92
93 CHECK_TYPE_SIZE("long long" LONG_LONG)
94 CHECK_TYPE_SIZE("unsigned long long" UNSIGNED_LONG_LONG)
95
96 # User-configurable options
97 #
98 # (Note: CMakeSetup displays these in alphabetical order, regardless of
99 # the order we use here)
100
101 SET(BUILD_SHARED_LIBS OFF CACHE BOOL
102 "Build shared libraries instead of static ones.")
103
104 OPTION(PCRE_BUILD_PCRECPP "Build the PCRE C++ library (pcrecpp)." ON)
105
106 SET(PCRE_EBCDIC OFF CACHE BOOL
107 "Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems)")
108
109 SET(PCRE_LINK_SIZE "2" CACHE STRING
110 "Internal link size (2, 3 or 4 allowed). See LINK_SIZE in config.h.in for details.")
111
112 SET(PCRE_MATCH_LIMIT "10000000" CACHE STRING
113 "Default limit on internal looping. See MATCH_LIMIT in config.h.in for details.")
114
115 SET(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT" CACHE STRING
116 "Default limit on internal recursion. See MATCH_LIMIT_RECURSION in config.h.in for details.")
117
118 SET(PCREGREP_BUFSIZE "20480" CACHE STRING
119 "Buffer size parameter for pcregrep. See PCREGREP_BUFSIZE in config.h.in for details.")
120
121 SET(PCRE_NEWLINE "LF" CACHE STRING
122 "What to recognize as a newline (one of CR, LF, CRLF, ANY, ANYCRLF).")
123
124 SET(PCRE_NO_RECURSE OFF CACHE BOOL
125 "If ON, then don't use stack recursion when matching. See NO_RECURSE in config.h.in for details.")
126
127 SET(PCRE_POSIX_MALLOC_THRESHOLD "10" CACHE STRING
128 "Threshold for malloc() usage. See POSIX_MALLOC_THRESHOLD in config.h.in for details.")
129
130 SET(PCRE_SUPPORT_JIT OFF CACHE BOOL
131 "Enable support for Just-in-time compiling.")
132
133 SET(PCRE_SUPPORT_PCREGREP_JIT ON CACHE BOOL
134 "Enable use of Just-in-time compiling in pcregrep.")
135
136 SET(PCRE_SUPPORT_UNICODE_PROPERTIES OFF CACHE BOOL
137 "Enable support for Unicode properties. (If set, UTF-8 support will be enabled as well)")
138
139 SET(PCRE_SUPPORT_UTF8 OFF CACHE BOOL
140 "Enable support for the Unicode UTF-8 encoding.")
141
142 SET(PCRE_SUPPORT_BSR_ANYCRLF OFF CACHE BOOL
143 "ON=Backslash-R matches only LF CR and CRLF, OFF=Backslash-R matches all Unicode Linebreaks")
144
145 OPTION(PCRE_SHOW_REPORT "Show the final configuration report" ON)
146 OPTION(PCRE_BUILD_PCREGREP "Build pcregrep" ON)
147 OPTION(PCRE_BUILD_TESTS "Build the tests" ON)
148
149 IF (PCRE_BUILD_TESTS)
150 IF (NOT PCRE_BUILD_PCREGREP)
151 MESSAGE(STATUS "** Building tests requires pcregrep: PCRE_BUILD_PCREGREP forced ON")
152 SET(PCRE_BUILD_PCREGREP ON)
153 ENDIF(NOT PCRE_BUILD_PCREGREP)
154 ENDIF(PCRE_BUILD_TESTS)
155
156 IF (MINGW)
157 OPTION(NON_STANDARD_LIB_PREFIX
158 "ON=Shared libraries built in mingw will be named pcre.dll, etc., instead of libpcre.dll, etc."
159 OFF)
160
161 OPTION(NON_STANDARD_LIB_SUFFIX
162 "ON=Shared libraries built in mingw will be named libpcre-0.dll, etc., instead of libpcre.dll, etc."
163 OFF)
164 ENDIF(MINGW)
165
166 # bzip2 lib
167 IF(BZIP2_FOUND)
168 OPTION (PCRE_SUPPORT_LIBBZ2 "Enable support for linking pcregrep with libbz2." ON)
169 ENDIF(BZIP2_FOUND)
170 IF(PCRE_SUPPORT_LIBBZ2)
171 INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR})
172 ENDIF(PCRE_SUPPORT_LIBBZ2)
173
174 # zlib
175 IF(ZLIB_FOUND)
176 OPTION (PCRE_SUPPORT_LIBZ "Enable support for linking pcregrep with libz." ON)
177 ENDIF(ZLIB_FOUND)
178 IF(PCRE_SUPPORT_LIBZ)
179 INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
180 ENDIF(PCRE_SUPPORT_LIBZ)
181
182 # readline lib
183 IF(READLINE_FOUND)
184 OPTION (PCRE_SUPPORT_LIBREADLINE "Enable support for linking pcretest with libreadline." ON)
185 ENDIF(READLINE_FOUND)
186 IF(PCRE_SUPPORT_LIBREADLINE)
187 INCLUDE_DIRECTORIES(${READLINE_INCLUDE_DIR})
188 ENDIF(PCRE_SUPPORT_LIBREADLINE)
189
190 # Prepare build configuration
191
192 SET(pcre_have_type_traits 0)
193 SET(pcre_have_bits_type_traits 0)
194
195 IF(HAVE_TYPE_TRAITS_H)
196 SET(pcre_have_type_traits 1)
197 ENDIF(HAVE_TYPE_TRAITS_H)
198
199 IF(HAVE_BITS_TYPE_TRAITS_H)
200 SET(pcre_have_bits_type_traits 1)
201 ENDIF(HAVE_BITS_TYPE_TRAITS_H)
202
203 SET(pcre_have_long_long 0)
204 SET(pcre_have_ulong_long 0)
205
206 IF(HAVE_LONG_LONG)
207 SET(pcre_have_long_long 1)
208 ENDIF(HAVE_LONG_LONG)
209
210 IF(HAVE_UNSIGNED_LONG_LONG)
211 SET(pcre_have_ulong_long 1)
212 ENDIF(HAVE_UNSIGNED_LONG_LONG)
213
214 IF(NOT BUILD_SHARED_LIBS)
215 SET(PCRE_STATIC 1)
216 ENDIF(NOT BUILD_SHARED_LIBS)
217
218 IF(PCRE_SUPPORT_BSR_ANYCRLF)
219 SET(BSR_ANYCRLF 1)
220 ENDIF(PCRE_SUPPORT_BSR_ANYCRLF)
221
222 IF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES)
223 SET(SUPPORT_UTF8 1)
224 ENDIF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES)
225
226 IF(PCRE_SUPPORT_UNICODE_PROPERTIES)
227 SET(SUPPORT_UCP 1)
228 ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES)
229
230 IF(PCRE_SUPPORT_JIT)
231 SET(SUPPORT_JIT 1)
232 ENDIF(PCRE_SUPPORT_JIT)
233
234 IF(PCRE_SUPPORT_PCREGREP_JIT)
235 SET(SUPPORT_PCREGREP_JIT 1)
236 ENDIF(PCRE_SUPPORT_PCREGREP_JIT)
237
238 # This next one used to contain
239 # SET(PCRETEST_LIBS ${READLINE_LIBRARY})
240 # but I was advised to add the NCURSES test as well, along with
241 # some modifications to cmake/FindReadline.cmake which should
242 # make it possible to override the default if necessary. PH
243
244 IF(PCRE_SUPPORT_LIBREADLINE)
245 SET(SUPPORT_LIBREADLINE 1)
246 SET(PCRETEST_LIBS ${READLINE_LIBRARY} ${NCURSES_LIBRARY})
247 ENDIF(PCRE_SUPPORT_LIBREADLINE)
248
249 IF(PCRE_SUPPORT_LIBZ)
250 SET(SUPPORT_LIBZ 1)
251 SET(PCREGREP_LIBS ${PCREGREP_LIBS} ${ZLIB_LIBRARIES})
252 ENDIF(PCRE_SUPPORT_LIBZ)
253
254 IF(PCRE_SUPPORT_LIBBZ2)
255 SET(SUPPORT_LIBBZ2 1)
256 SET(PCREGREP_LIBS ${PCREGREP_LIBS} ${BZIP2_LIBRARIES})
257 ENDIF(PCRE_SUPPORT_LIBBZ2)
258
259 SET(NEWLINE "")
260
261 IF(PCRE_NEWLINE STREQUAL "LF")
262 SET(NEWLINE "10")
263 ENDIF(PCRE_NEWLINE STREQUAL "LF")
264 IF(PCRE_NEWLINE STREQUAL "CR")
265 SET(NEWLINE "13")
266 ENDIF(PCRE_NEWLINE STREQUAL "CR")
267 IF(PCRE_NEWLINE STREQUAL "CRLF")
268 SET(NEWLINE "3338")
269 ENDIF(PCRE_NEWLINE STREQUAL "CRLF")
270 IF(PCRE_NEWLINE STREQUAL "ANY")
271 SET(NEWLINE "-1")
272 ENDIF(PCRE_NEWLINE STREQUAL "ANY")
273 IF(PCRE_NEWLINE STREQUAL "ANYCRLF")
274 SET(NEWLINE "-2")
275 ENDIF(PCRE_NEWLINE STREQUAL "ANYCRLF")
276
277 IF(NEWLINE STREQUAL "")
278 MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".")
279 ENDIF(NEWLINE STREQUAL "")
280
281 IF(PCRE_EBCDIC)
282 SET(EBCDIC 1)
283 ENDIF(PCRE_EBCDIC)
284
285 IF(PCRE_NO_RECURSE)
286 SET(NO_RECURSE 1)
287 ENDIF(PCRE_NO_RECURSE)
288
289 # Output files
290 CONFIGURE_FILE(config-cmake.h.in
291 ${PROJECT_BINARY_DIR}/config.h
292 @ONLY)
293
294 CONFIGURE_FILE(pcre.h.generic
295 ${PROJECT_BINARY_DIR}/pcre.h
296 COPYONLY)
297
298 # What about pcre-config and libpcre.pc?
299
300 IF(PCRE_BUILD_PCRECPP)
301 CONFIGURE_FILE(pcre_stringpiece.h.in
302 ${PROJECT_BINARY_DIR}/pcre_stringpiece.h
303 @ONLY)
304
305 CONFIGURE_FILE(pcrecpparg.h.in
306 ${PROJECT_BINARY_DIR}/pcrecpparg.h
307 @ONLY)
308 ENDIF(PCRE_BUILD_PCRECPP)
309
310 # Character table generation
311
312 OPTION(PCRE_REBUILD_CHARTABLES "Rebuild char tables" OFF)
313 IF(PCRE_REBUILD_CHARTABLES)
314 ADD_EXECUTABLE(dftables dftables.c)
315
316 GET_TARGET_PROPERTY(DFTABLES_EXE dftables LOCATION)
317
318 ADD_CUSTOM_COMMAND(
319 COMMENT "Generating character tables (pcre_chartables.c) for current locale"
320 DEPENDS dftables
321 COMMAND ${DFTABLES_EXE}
322 ARGS ${PROJECT_BINARY_DIR}/pcre_chartables.c
323 OUTPUT ${PROJECT_BINARY_DIR}/pcre_chartables.c
324 )
325 ELSE(PCRE_REBUILD_CHARTABLES)
326 CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/pcre_chartables.c.dist
327 ${PROJECT_BINARY_DIR}/pcre_chartables.c
328 COPYONLY)
329 ENDIF(PCRE_REBUILD_CHARTABLES)
330
331 # Source code
332
333 SET(PCRE_HEADERS ${PROJECT_BINARY_DIR}/pcre.h)
334
335 SET(PCRE_SOURCES
336 ${PROJECT_BINARY_DIR}/pcre_chartables.c
337 pcre_compile.c
338 pcre_config.c
339 pcre_dfa_exec.c
340 pcre_exec.c
341 pcre_fullinfo.c
342 pcre_get.c
343 pcre_globals.c
344 pcre_info.c
345 pcre_jit_compile.c
346 pcre_newline.c
347 pcre_maketables.c
348 pcre_ord2utf8.c
349 pcre_refcount.c
350 pcre_study.c
351 pcre_tables.c
352 pcre_try_flipped.c
353 pcre_ucd.c
354 pcre_valid_utf8.c
355 pcre_version.c
356 pcre_xclass.c
357 )
358
359
360 SET(PCREPOSIX_HEADERS pcreposix.h)
361
362 SET(PCREPOSIX_SOURCES pcreposix.c)
363
364 IF(MINGW AND NOT PCRE_STATIC)
365 IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc)
366 ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcre.o
367 PRE-LINK
368 COMMAND windres ARGS pcre.rc pcre.o
369 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
370 COMMENT Using pcre coff info in mingw build)
371 SET(PCRE_SOURCES
372 ${PCRE_SOURCES} ${PROJECT_SOURCE_DIR}/pcre.o
373 )
374 ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc)
375 IF (EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc)
376 ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcreposix.o
377 PRE-LINK
378 COMMAND windres ARGS pcreposix.rc pcreposix.o
379 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
380 COMMENT Using pcreposix coff info in mingw build)
381 SET(PCREPOSIX_SOURCES
382 ${PCREPOSIX_SOURCES} ${PROJECT_SOURCE_DIR}/pcreposix.o
383 )
384 ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc)
385 ENDIF(MINGW AND NOT PCRE_STATIC)
386
387 SET(PCRECPP_HEADERS
388 pcrecpp.h
389 pcre_scanner.h
390 ${PROJECT_BINARY_DIR}/pcrecpparg.h
391 ${PROJECT_BINARY_DIR}/pcre_stringpiece.h
392 )
393
394 SET(PCRECPP_SOURCES
395 pcrecpp.cc
396 pcre_scanner.cc
397 pcre_stringpiece.cc
398 )
399
400 # Build setup
401
402 ADD_DEFINITIONS(-DHAVE_CONFIG_H)
403
404 IF(MSVC)
405 ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
406 ENDIF(MSVC)
407
408 SET(CMAKE_INCLUDE_CURRENT_DIR 1)
409 # needed to make sure to not link debug libs
410 # against release libs and vice versa
411 IF(WIN32)
412 SET(CMAKE_DEBUG_POSTFIX "d")
413 ENDIF(WIN32)
414
415 SET(targets)
416
417 # Libraries
418 # pcre
419 ADD_LIBRARY(pcre ${PCRE_HEADERS} ${PCRE_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
420 SET(targets ${targets} pcre)
421 ADD_LIBRARY(pcreposix ${PCREPOSIX_HEADERS} ${PCREPOSIX_SOURCES})
422 SET(targets ${targets} pcreposix)
423 TARGET_LINK_LIBRARIES(pcreposix pcre)
424 IF(MINGW AND NOT PCRE_STATIC)
425 IF(NON_STANDARD_LIB_PREFIX)
426 SET_TARGET_PROPERTIES(pcre pcreposix
427 PROPERTIES PREFIX ""
428 )
429 ENDIF(NON_STANDARD_LIB_PREFIX)
430
431 IF(NON_STANDARD_LIB_SUFFIX)
432 SET_TARGET_PROPERTIES(pcre pcreposix
433 PROPERTIES SUFFIX "-0.dll"
434 )
435 ENDIF(NON_STANDARD_LIB_SUFFIX)
436 ENDIF(MINGW AND NOT PCRE_STATIC)
437
438
439 # pcrecpp
440 IF(PCRE_BUILD_PCRECPP)
441 ADD_LIBRARY(pcrecpp ${PCRECPP_HEADERS} ${PCRECPP_SOURCES})
442 SET(targets ${targets} pcrecpp)
443 TARGET_LINK_LIBRARIES(pcrecpp pcre)
444
445 IF(MINGW AND NOT PCRE_STATIC)
446 IF(NON_STANDARD_LIB_PREFIX)
447 SET_TARGET_PROPERTIES(pcrecpp
448 PROPERTIES PREFIX ""
449 )
450 ENDIF(NON_STANDARD_LIB_PREFIX)
451
452 IF(NON_STANDARD_LIB_SUFFIX)
453 SET_TARGET_PROPERTIES(pcrecpp
454 PROPERTIES SUFFIX "-0.dll"
455 )
456 ENDIF(NON_STANDARD_LIB_SUFFIX)
457 ENDIF(MINGW AND NOT PCRE_STATIC)
458 ENDIF(PCRE_BUILD_PCRECPP)
459
460
461 # Executables
462
463 # Removed by PH (2008-01-23) because pcredemo shouldn't really be built
464 # automatically, and it gave trouble in some environments anyway.
465 # ADD_EXECUTABLE(pcredemo pcredemo.c)
466 # TARGET_LINK_LIBRARIES(pcredemo pcreposix)
467 # IF(NOT BUILD_SHARED_LIBS)
468 # # make sure to not use declspec(dllimport) in static mode on windows
469 # SET_TARGET_PROPERTIES(pcredemo PROPERTIES COMPILE_FLAGS "-DPCRE_STATIC")
470 # ENDIF(NOT BUILD_SHARED_LIBS)
471
472 IF(PCRE_BUILD_PCREGREP OR PCRE_BUILD_TESTS)
473 ADD_EXECUTABLE(pcregrep pcregrep.c)
474 SET(targets ${targets} pcregrep)
475 TARGET_LINK_LIBRARIES(pcregrep pcreposix ${PCREGREP_LIBS})
476 ENDIF(PCRE_BUILD_PCREGREP OR PCRE_BUILD_TESTS)
477
478 # Testing
479 IF(PCRE_BUILD_TESTS)
480 ENABLE_TESTING()
481
482 ADD_EXECUTABLE(pcretest pcretest.c)
483 SET(targets ${targets} pcretest)
484 TARGET_LINK_LIBRARIES(pcretest pcreposix ${PCRETEST_LIBS})
485
486 IF(PCRE_SUPPORT_JIT)
487 ADD_EXECUTABLE(pcre_jit_test pcre_jit_test.c)
488 SET(targets ${targets} pcre_jit_test)
489 TARGET_LINK_LIBRARIES(pcre_jit_test pcre)
490 ENDIF(PCRE_SUPPORT_JIT)
491
492 IF(PCRE_BUILD_PCRECPP)
493 ADD_EXECUTABLE(pcrecpp_unittest pcrecpp_unittest.cc)
494 SET(targets ${targets} pcrecpp_unittest)
495 TARGET_LINK_LIBRARIES(pcrecpp_unittest pcrecpp)
496 IF(MINGW AND NON_STANDARD_LIB_NAMES AND NOT PCRE_STATIC)
497 SET_TARGET_PROPERTIES(pcrecpp
498 PROPERTIES PREFIX ""
499 )
500 ENDIF(MINGW AND NON_STANDARD_LIB_NAMES AND NOT PCRE_STATIC)
501
502 ADD_EXECUTABLE(pcre_scanner_unittest pcre_scanner_unittest.cc)
503 SET(targets ${targets} pcre_scanner_unittest)
504 TARGET_LINK_LIBRARIES(pcre_scanner_unittest pcrecpp)
505
506 ADD_EXECUTABLE(pcre_stringpiece_unittest pcre_stringpiece_unittest.cc)
507 SET(targets ${targets} pcre_stringpiece_unittest)
508 TARGET_LINK_LIBRARIES(pcre_stringpiece_unittest pcrecpp)
509 ENDIF(PCRE_BUILD_PCRECPP)
510
511 # exes in Debug location tested by the RunTest shell script
512 # via "make test"
513 GET_TARGET_PROPERTY(PCREGREP_EXE pcregrep DEBUG_LOCATION)
514 GET_TARGET_PROPERTY(PCRETEST_EXE pcretest DEBUG_LOCATION)
515
516 # =================================================
517 # Write out a CTest configuration file
518 #
519 FILE(WRITE ${PROJECT_BINARY_DIR}/CTestCustom.ctest
520 "# This is a generated file.
521 MESSAGE(\"When testing is complete, review test output in the
522 ${PROJECT_BINARY_DIR}/Testing/Temporary folder.\")
523 MESSAGE(\"\")
524 ")
525
526 FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_test.sh
527 "#! /bin/sh
528 # This is a generated file.
529 srcdir=${PROJECT_SOURCE_DIR}
530 pcregrep=${PCREGREP_EXE}
531 pcretest=${PCRETEST_EXE}
532 source ${PROJECT_SOURCE_DIR}/RunTest
533 if test \"$?\" != \"0\"; then exit 1; fi
534 # End
535 ")
536
537 FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_grep_test.sh
538 "#! /bin/sh
539 # This is a generated file.
540 srcdir=${PROJECT_SOURCE_DIR}
541 pcregrep=${PCREGREP_EXE}
542 pcretest=${PCRETEST_EXE}
543 source ${PROJECT_SOURCE_DIR}/RunGrepTest
544 if test \"$?\" != \"0\"; then exit 1; fi
545 # End
546 ")
547
548 IF(UNIX)
549 ADD_TEST(pcre_test sh ${PROJECT_BINARY_DIR}/pcre_test.sh)
550 ADD_TEST(pcre_grep_test sh ${PROJECT_BINARY_DIR}/pcre_grep_test.sh)
551 ENDIF(UNIX)
552
553 IF(WIN32)
554 # Provide environment for executing the bat file version of RunTest
555 string(REPLACE "/" "\\" winsrc "${PROJECT_SOURCE_DIR}")
556
557 FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_test.txt
558 "\@REM This is a generated file.
559 \@Echo off
560 setlocal
561 SET\ srcdir=\${srcdir}
562 SET\ pcretest=\${pcretest}
563 SET\ pcregrep=\${pcregrep}
564 call \"\${srcdir}\\RunTest.Bat\"
565 if errorlevel 1 exit /b 1
566 echo RunTest.bat tests successfully completed
567 ")
568
569 FILE(WRITE ${PROJECT_BINARY_DIR}/BatDriver.cmake
570 "# This is a generated file.
571 # this script is run with arguments via the cmake command in add_test(NAME pcre_test_bat)
572 # BatDriver feeds the actual location of pcretest.exe and pcregrep.exe
573 FILE(TO_NATIVE_PATH \${pcretestx} pcretest)
574 FILE(TO_NATIVE_PATH \${pcregrepx} pcregrep)
575 FILE(TO_NATIVE_PATH \${srcdirx} srcdir)
576 configure_file(\"\${bindirx}/pcre_test.txt\" \"\${bindirx}/pcre_test.bat\")
577 # MESSAGE(\"cmake\ variable\ pcretest\ is\ \${pcretest}\")
578 # MESSAGE(\"cmake\ variable\ pcregrep\ is\ \${pcregrep}\")
579 # STRING(REPLACE \" \" \"\\ \" bindir \${bindirx})
580 MESSAGE(\"COMMAND pcre_test.bat \")
581 EXECUTE_PROCESS(COMMAND pcre_test.bat
582 WORKING_DIRECTORY .
583 OUTPUT_VARIABLE batoutput)
584 MESSAGE(\"OUTPUT: \${batoutput}\")
585 ")
586
587 ADD_TEST(NAME pcre_test_bat
588 COMMAND ${CMAKE_COMMAND} -D bindirx=${PROJECT_BINARY_DIR} -D srcdirx=${PROJECT_SOURCE_DIR} -D pcretestx=$<TARGET_FILE:pcretest> -D pcregrepx=$<TARGET_FILE:pcregrep> -P "${PROJECT_BINARY_DIR}/BatDriver.cmake")
589 SET_TESTS_PROPERTIES(pcre_test_bat PROPERTIES
590 PASS_REGULAR_EXPRESSION "RunTest\\.bat tests successfully completed")
591
592 IF("$ENV{OSTYPE}" STREQUAL "msys")
593 # Both the sh and bat file versions of RunTest are run if make test is used
594 # in msys
595
596 ADD_TEST(pcre_test_sh sh.exe ${PROJECT_BINARY_DIR}/pcre_test.sh)
597 ADD_TEST(pcre_grep_test sh.exe ${PROJECT_BINARY_DIR}/pcre_grep_test.sh)
598
599 ENDIF("$ENV{OSTYPE}" STREQUAL "msys")
600 ENDIF(WIN32)
601
602 # Changed to accommodate testing whichever location was just built
603
604 IF(PCRE_SUPPORT_JIT)
605 ADD_TEST(pcre_jit_test pcre_jit_test)
606 ENDIF(PCRE_SUPPORT_JIT)
607
608 IF(PCRE_BUILD_PCRECPP)
609 ADD_TEST(pcrecpp_test pcrecpp_unittest)
610 ADD_TEST(pcre_scanner_test pcre_scanner_unittest)
611 ADD_TEST(pcre_stringpiece_test pcre_stringpiece_unittest)
612
613 ENDIF(PCRE_BUILD_PCRECPP)
614 ENDIF(PCRE_BUILD_TESTS)
615
616 # Installation
617 SET(CMAKE_INSTALL_ALWAYS 1)
618
619 INSTALL(TARGETS ${targets}
620 RUNTIME DESTINATION bin
621 LIBRARY DESTINATION lib
622 ARCHIVE DESTINATION lib)
623
624 INSTALL(FILES ${PCRE_HEADERS} ${PCREPOSIX_HEADERS} DESTINATION include)
625
626 FILE(GLOB html ${PROJECT_SOURCE_DIR}/doc/html/*.html)
627 FILE(GLOB man1 ${PROJECT_SOURCE_DIR}/doc/*.1)
628 FILE(GLOB man3 ${PROJECT_SOURCE_DIR}/doc/*.3)
629
630 IF(PCRE_BUILD_PCRECPP)
631 INSTALL(FILES ${PCRECPP_HEADERS} DESTINATION include)
632 ELSE(PCRE_BUILD_PCRECPP)
633 # Remove pcrecpp.3
634 FOREACH(man ${man3})
635 GET_FILENAME_COMPONENT(man_tmp ${man} NAME)
636 IF(NOT man_tmp STREQUAL "pcrecpp.3")
637 SET(man3_new ${man3} ${man})
638 ENDIF(NOT man_tmp STREQUAL "pcrecpp.3")
639 ENDFOREACH(man ${man3})
640 SET(man3 ${man3_new})
641 ENDIF(PCRE_BUILD_PCRECPP)
642
643 INSTALL(FILES ${man1} DESTINATION man/man1)
644 INSTALL(FILES ${man3} DESTINATION man/man3)
645 INSTALL(FILES ${html} DESTINATION share/doc/pcre/html)
646
647 # help, only for nice output
648 IF(BUILD_SHARED_LIBS)
649 SET(BUILD_STATIC_LIBS OFF)
650 ELSE(BUILD_SHARED_LIBS)
651 SET(BUILD_STATIC_LIBS ON)
652 ENDIF(BUILD_SHARED_LIBS)
653
654 IF(PCRE_SHOW_REPORT)
655 STRING(TOUPPER "${CMAKE_BUILD_TYPE}" buildtype)
656 IF (CMAKE_C_FLAGS)
657 SET(cfsp " ")
658 ENDIF(CMAKE_C_FLAGS)
659 IF (CMAKE_CXX_FLAGS)
660 SET(cxxfsp " ")
661 ENDIF(CMAKE_CXX_FLAGS)
662 MESSAGE(STATUS "")
663 MESSAGE(STATUS "")
664 MESSAGE(STATUS "PCRE configuration summary:")
665 MESSAGE(STATUS "")
666 MESSAGE(STATUS " Install prefix .................. : ${CMAKE_INSTALL_PREFIX}")
667 MESSAGE(STATUS " C compiler ...................... : ${CMAKE_C_COMPILER}")
668 MESSAGE(STATUS " C++ compiler .................... : ${CMAKE_CXX_COMPILER}")
669 MESSAGE(STATUS " C compiler flags ................ : ${CMAKE_C_FLAGS}${cfsp}${CMAKE_C_FLAGS_${buildtype}}")
670 MESSAGE(STATUS " C++ compiler flags .............. : ${CMAKE_CXX_FLAGS}${cxxfsp}${CMAKE_CXX_FLAGS_${buildtype}}")
671 MESSAGE(STATUS "")
672 MESSAGE(STATUS " Build C++ library ............... : ${PCRE_BUILD_PCRECPP}")
673 MESSAGE(STATUS " Enable JIT compiling support .... : ${PCRE_SUPPORT_JIT}")
674 MESSAGE(STATUS " Enable UTF-8 support ............ : ${PCRE_SUPPORT_UNICODE_PROPERTIES}")
675 MESSAGE(STATUS " Unicode properties .............. : ${PCRE_SUPPORT_UNICODE_PROPERTIES}")
676 MESSAGE(STATUS " Newline char/sequence ........... : ${PCRE_NEWLINE}")
677 MESSAGE(STATUS " \\R matches only ANYCRLF ......... : ${PCRE_SUPPORT_BSR_ANYCRLF}")
678 MESSAGE(STATUS " EBCDIC coding ................... : ${PCRE_EBCDIC}")
679 MESSAGE(STATUS " Rebuild char tables ............. : ${PCRE_REBUILD_CHARTABLES}")
680 MESSAGE(STATUS " No stack recursion .............. : ${PCRE_NO_RECURSE}")
681 MESSAGE(STATUS " POSIX mem threshold ............. : ${PCRE_POSIX_MALLOC_THRESHOLD}")
682 MESSAGE(STATUS " Internal link size .............. : ${PCRE_LINK_SIZE}")
683 MESSAGE(STATUS " Match limit ..................... : ${PCRE_MATCH_LIMIT}")
684 MESSAGE(STATUS " Match limit recursion ........... : ${PCRE_MATCH_LIMIT_RECURSION}")
685 MESSAGE(STATUS " Build shared libs ............... : ${BUILD_SHARED_LIBS}")
686 MESSAGE(STATUS " Build static libs ............... : ${BUILD_STATIC_LIBS}")
687 MESSAGE(STATUS " Build pcregrep .................. : ${PCRE_BUILD_PCREGREP}")
688 MESSAGE(STATUS " Enable JIT in pcregrep .......... : ${PCRE_SUPPORT_PCREGREP_JIT}")
689 MESSAGE(STATUS " Buffer size for pcregrep ........ : ${PCREGREP_BUFSIZE}")
690 MESSAGE(STATUS " Build tests (implies pcretest .. : ${PCRE_BUILD_TESTS}")
691 MESSAGE(STATUS " and pcregrep)")
692 IF(ZLIB_FOUND)
693 MESSAGE(STATUS " Link pcregrep with libz ......... : ${PCRE_SUPPORT_LIBZ}")
694 ELSE(ZLIB_FOUND)
695 MESSAGE(STATUS " Link pcregrep with libz ......... : None" )
696 ENDIF(ZLIB_FOUND)
697 IF(BZIP2_FOUND)
698 MESSAGE(STATUS " Link pcregrep with libbz2 ....... : ${PCRE_SUPPORT_LIBBZ2}")
699 ELSE(BZIP2_FOUND)
700 MESSAGE(STATUS " Link pcregrep with libbz2 ....... : None" )
701 ENDIF(BZIP2_FOUND)
702 IF(NOT PCRE_SUPPORT_LIBREADLINE)
703 MESSAGE(STATUS " Link pcretest with libreadline .. : None" )
704 ELSE(NOT PCRE_SUPPORT_LIBREADLINE)
705 MESSAGE(STATUS " Link pcretest with libreadline .. : ${PCRE_SUPPORT_LIBREADLINE}")
706 ENDIF(NOT PCRE_SUPPORT_LIBREADLINE)
707 IF(MINGW AND NOT PCRE_STATIC)
708 MESSAGE(STATUS " Non-standard dll names (prefix) . : ${NON_STANDARD_LIB_PREFIX}")
709 MESSAGE(STATUS " Non-standard dll names (suffix) . : ${NON_STANDARD_LIB_SUFFIX}")
710 ENDIF(MINGW AND NOT PCRE_STATIC)
711 MESSAGE(STATUS "")
712 ENDIF(PCRE_SHOW_REPORT)
713
714 # end CMakeLists.txt

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12