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

Contents of /code/trunk/CMakeLists.txt

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.5