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

Contents of /code/trunk/CMakeLists.txt

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.5