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

Contents of /code/trunk/CMakeLists.txt

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.5