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

Contents of /code/trunk/CMakeLists.txt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 836 - (hide annotations) (download)
Wed Dec 28 17:16:11 2011 UTC (2 years, 8 months ago) by ph10
File MIME type: text/plain
File size: 24793 byte(s)
Merging all the changes from the pcre16 branch into the trunk.

1 ph10 137 # CMakeLists.txt
2     #
3 ph10 258 #
4 ph10 137 # 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 ph10 258 # 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 ph10 291 # 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 ph10 303 # 2008-01-20 Brought up to date to include several new features by Christian
17     # Ehrlicher.
18 ph10 405 # 2008-01-22 Sheri added options for backward compatibility of library names
19     # when building with minGW:
20 ph10 311 # if "ON", NON_STANDARD_LIB_PREFIX causes shared libraries to
21 ph10 405 # be built without "lib" as prefix. (The libraries will be named
22     # pcre.dll, pcreposix.dll and pcrecpp.dll).
23 ph10 311 # 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 ph10 312 # 2008-01-23 PH removed the automatic build of pcredemo.
28 ph10 344 # 2008-04-22 PH modified READLINE support so it finds NCURSES when needed.
29 ph10 351 # 2008-07-03 PH updated for revised UCP property support (change of files)
30 ph10 407 # 2009-03-23 PH applied Steven Van Ingelgem's patch to change the name
31 ph10 405 # CMAKE_BINARY_DIR to PROJECT_BINARY_DIR so that it works when PCRE
32     # is included within another project.
33 ph10 407 # 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 ph10 413 # 2009-04-11 PH applied Christian Ehrlicher's patch to show compiler flags that
37     # are set by specifying a release type.
38 ph10 475 # 2010-01-02 PH added test for stdint.h
39 ph10 650 # 2010-03-02 PH added test for inttypes.h
40     # 2011-08-01 PH added PCREGREP_BUFSIZE
41 ph10 667 # 2011-08-22 PH added PCRE_SUPPORT_JIT
42 ph10 684 # 2011-09-06 PH modified WIN32 ADD_TEST line as suggested by Sergey Cherepanov
43 ph10 685 # 2011-09-06 PH added PCRE_SUPPORT_PCREGREP_JIT
44 ph10 719 # 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 ph10 137
55     PROJECT(PCRE C CXX)
56    
57 ph10 719 # Increased minimum to 2.8.0 to support newer add_test features
58 ph10 137
59 ph10 719 CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0)
60    
61 ph10 405 SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # for FindReadline.cmake
62 ph10 303
63     # external packages
64     FIND_PACKAGE( BZip2 )
65     FIND_PACKAGE( ZLIB )
66     FIND_PACKAGE( Readline )
67    
68 ph10 137 # Configuration checks
69    
70     INCLUDE(CheckIncludeFile)
71     INCLUDE(CheckIncludeFileCXX)
72     INCLUDE(CheckFunctionExists)
73     INCLUDE(CheckTypeSize)
74    
75 ph10 318 CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
76 ph10 475 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
77 ph10 495 CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H)
78 ph10 318 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 ph10 137
83 ph10 318 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 ph10 137
86 ph10 318 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 ph10 303 CHECK_FUNCTION_EXISTS(_strtoi64 HAVE__STRTOI64)
92 ph10 137
93 ph10 318 CHECK_TYPE_SIZE("long long" LONG_LONG)
94     CHECK_TYPE_SIZE("unsigned long long" UNSIGNED_LONG_LONG)
95 ph10 137
96     # User-configurable options
97     #
98     # (Note: CMakeSetup displays these in alphabetical order, regardless of
99     # the order we use here)
100    
101 ph10 144 SET(BUILD_SHARED_LIBS OFF CACHE BOOL
102     "Build shared libraries instead of static ones.")
103 ph10 137
104     OPTION(PCRE_BUILD_PCRECPP "Build the PCRE C++ library (pcrecpp)." ON)
105    
106 ph10 144 SET(PCRE_EBCDIC OFF CACHE BOOL
107 ph10 137 "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 ph10 650 SET(PCREGREP_BUFSIZE "20480" CACHE STRING
119     "Buffer size parameter for pcregrep. See PCREGREP_BUFSIZE in config.h.in for details.")
120    
121 ph10 137 SET(PCRE_NEWLINE "LF" CACHE STRING
122 ph10 258 "What to recognize as a newline (one of CR, LF, CRLF, ANY, ANYCRLF).")
123 ph10 137
124 ph10 199 SET(PCRE_NO_RECURSE OFF CACHE BOOL
125 ph10 137 "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 ph10 667 SET(PCRE_SUPPORT_JIT OFF CACHE BOOL
131     "Enable support for Just-in-time compiling.")
132 ph10 691
133 ph10 685 SET(PCRE_SUPPORT_PCREGREP_JIT ON CACHE BOOL
134     "Enable use of Just-in-time compiling in pcregrep.")
135 ph10 691
136 ph10 144 SET(PCRE_SUPPORT_UNICODE_PROPERTIES OFF CACHE BOOL
137 ph10 137 "Enable support for Unicode properties. (If set, UTF-8 support will be enabled as well)")
138    
139 ph10 144 SET(PCRE_SUPPORT_UTF8 OFF CACHE BOOL
140 ph10 137 "Enable support for the Unicode UTF-8 encoding.")
141    
142 ph10 258 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 ph10 407 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 ph10 311
149 ph10 407 IF (PCRE_BUILD_TESTS)
150     IF (NOT PCRE_BUILD_PCREGREP)
151 ph10 411 MESSAGE(STATUS "** Building tests requires pcregrep: PCRE_BUILD_PCREGREP forced ON")
152 ph10 407 SET(PCRE_BUILD_PCREGREP ON)
153 ph10 411 ENDIF(NOT PCRE_BUILD_PCREGREP)
154     ENDIF(PCRE_BUILD_TESTS)
155 ph10 407
156 ph10 318 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 ph10 311
161 ph10 318 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 ph10 303 # 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 ph10 292
174 ph10 303 # 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 ph10 292
182 ph10 303 # 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 ph10 291
190 ph10 137 # 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 ph10 318 SET(pcre_have_type_traits 1)
197 ph10 137 ENDIF(HAVE_TYPE_TRAITS_H)
198    
199     IF(HAVE_BITS_TYPE_TRAITS_H)
200 ph10 318 SET(pcre_have_bits_type_traits 1)
201 ph10 137 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 ph10 318 SET(pcre_have_long_long 1)
208 ph10 137 ENDIF(HAVE_LONG_LONG)
209    
210     IF(HAVE_UNSIGNED_LONG_LONG)
211 ph10 318 SET(pcre_have_ulong_long 1)
212 ph10 137 ENDIF(HAVE_UNSIGNED_LONG_LONG)
213    
214 ph10 144 IF(NOT BUILD_SHARED_LIBS)
215 ph10 318 SET(PCRE_STATIC 1)
216 ph10 144 ENDIF(NOT BUILD_SHARED_LIBS)
217    
218 ph10 258 IF(PCRE_SUPPORT_BSR_ANYCRLF)
219 ph10 318 SET(BSR_ANYCRLF 1)
220 ph10 258 ENDIF(PCRE_SUPPORT_BSR_ANYCRLF)
221    
222 ph10 137 IF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES)
223 ph10 318 SET(SUPPORT_UTF8 1)
224 ph10 137 ENDIF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES)
225    
226     IF(PCRE_SUPPORT_UNICODE_PROPERTIES)
227 ph10 318 SET(SUPPORT_UCP 1)
228 ph10 137 ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES)
229    
230 ph10 667 IF(PCRE_SUPPORT_JIT)
231     SET(SUPPORT_JIT 1)
232 ph10 691 ENDIF(PCRE_SUPPORT_JIT)
233 ph10 667
234 ph10 685 IF(PCRE_SUPPORT_PCREGREP_JIT)
235     SET(SUPPORT_PCREGREP_JIT 1)
236 ph10 691 ENDIF(PCRE_SUPPORT_PCREGREP_JIT)
237 ph10 685
238 ph10 344 # 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 ph10 291 IF(PCRE_SUPPORT_LIBREADLINE)
245     SET(SUPPORT_LIBREADLINE 1)
246 ph10 344 SET(PCRETEST_LIBS ${READLINE_LIBRARY} ${NCURSES_LIBRARY})
247 ph10 291 ENDIF(PCRE_SUPPORT_LIBREADLINE)
248    
249     IF(PCRE_SUPPORT_LIBZ)
250     SET(SUPPORT_LIBZ 1)
251 ph10 303 SET(PCREGREP_LIBS ${PCREGREP_LIBS} ${ZLIB_LIBRARIES})
252 ph10 291 ENDIF(PCRE_SUPPORT_LIBZ)
253    
254     IF(PCRE_SUPPORT_LIBBZ2)
255     SET(SUPPORT_LIBBZ2 1)
256 ph10 303 SET(PCREGREP_LIBS ${PCREGREP_LIBS} ${BZIP2_LIBRARIES})
257 ph10 292 ENDIF(PCRE_SUPPORT_LIBBZ2)
258 ph10 291
259 ph10 144 SET(NEWLINE "")
260    
261 ph10 137 IF(PCRE_NEWLINE STREQUAL "LF")
262 ph10 318 SET(NEWLINE "10")
263 ph10 144 ENDIF(PCRE_NEWLINE STREQUAL "LF")
264     IF(PCRE_NEWLINE STREQUAL "CR")
265 ph10 318 SET(NEWLINE "13")
266 ph10 144 ENDIF(PCRE_NEWLINE STREQUAL "CR")
267     IF(PCRE_NEWLINE STREQUAL "CRLF")
268 ph10 318 SET(NEWLINE "3338")
269 ph10 144 ENDIF(PCRE_NEWLINE STREQUAL "CRLF")
270     IF(PCRE_NEWLINE STREQUAL "ANY")
271 ph10 318 SET(NEWLINE "-1")
272 ph10 144 ENDIF(PCRE_NEWLINE STREQUAL "ANY")
273 ph10 258 IF(PCRE_NEWLINE STREQUAL "ANYCRLF")
274 ph10 318 SET(NEWLINE "-2")
275 ph10 258 ENDIF(PCRE_NEWLINE STREQUAL "ANYCRLF")
276 ph10 144
277     IF(NEWLINE STREQUAL "")
278 ph10 318 MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".")
279 ph10 144 ENDIF(NEWLINE STREQUAL "")
280 ph10 137
281     IF(PCRE_EBCDIC)
282 ph10 318 SET(EBCDIC 1)
283 ph10 137 ENDIF(PCRE_EBCDIC)
284    
285     IF(PCRE_NO_RECURSE)
286 ph10 318 SET(NO_RECURSE 1)
287 ph10 137 ENDIF(PCRE_NO_RECURSE)
288    
289     # Output files
290     CONFIGURE_FILE(config-cmake.h.in
291 ph10 405 ${PROJECT_BINARY_DIR}/config.h
292 ph10 137 @ONLY)
293    
294     CONFIGURE_FILE(pcre.h.generic
295 ph10 405 ${PROJECT_BINARY_DIR}/pcre.h
296 ph10 137 COPYONLY)
297    
298     # What about pcre-config and libpcre.pc?
299    
300     IF(PCRE_BUILD_PCRECPP)
301 ph10 318 CONFIGURE_FILE(pcre_stringpiece.h.in
302 ph10 405 ${PROJECT_BINARY_DIR}/pcre_stringpiece.h
303 ph10 318 @ONLY)
304 ph10 137
305 ph10 318 CONFIGURE_FILE(pcrecpparg.h.in
306 ph10 405 ${PROJECT_BINARY_DIR}/pcrecpparg.h
307 ph10 318 @ONLY)
308 ph10 137 ENDIF(PCRE_BUILD_PCRECPP)
309    
310     # Character table generation
311    
312 ph10 303 OPTION(PCRE_REBUILD_CHARTABLES "Rebuild char tables" OFF)
313     IF(PCRE_REBUILD_CHARTABLES)
314     ADD_EXECUTABLE(dftables dftables.c)
315 ph10 137
316 ph10 303 GET_TARGET_PROPERTY(DFTABLES_EXE dftables LOCATION)
317 ph10 137
318 ph10 303 ADD_CUSTOM_COMMAND(
319     COMMENT "Generating character tables (pcre_chartables.c) for current locale"
320     DEPENDS dftables
321     COMMAND ${DFTABLES_EXE}
322 ph10 405 ARGS ${PROJECT_BINARY_DIR}/pcre_chartables.c
323     OUTPUT ${PROJECT_BINARY_DIR}/pcre_chartables.c
324 ph10 303 )
325     ELSE(PCRE_REBUILD_CHARTABLES)
326 ph10 405 CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/pcre_chartables.c.dist
327     ${PROJECT_BINARY_DIR}/pcre_chartables.c
328 ph10 303 COPYONLY)
329     ENDIF(PCRE_REBUILD_CHARTABLES)
330 ph10 137
331     # Source code
332    
333 ph10 405 SET(PCRE_HEADERS ${PROJECT_BINARY_DIR}/pcre.h)
334 ph10 137
335     SET(PCRE_SOURCES
336 ph10 836 ${PROJECT_BINARY_DIR}/pcre_byte_order.c
337     pcre_chartables.c
338 ph10 303 pcre_compile.c
339     pcre_config.c
340     pcre_dfa_exec.c
341     pcre_exec.c
342     pcre_fullinfo.c
343     pcre_get.c
344     pcre_globals.c
345     pcre_info.c
346 ph10 667 pcre_jit_compile.c
347 ph10 303 pcre_newline.c
348     pcre_maketables.c
349     pcre_ord2utf8.c
350     pcre_refcount.c
351     pcre_study.c
352     pcre_tables.c
353 ph10 351 pcre_ucd.c
354 ph10 303 pcre_valid_utf8.c
355     pcre_version.c
356     pcre_xclass.c
357 ph10 137 )
358    
359 ph10 719
360 ph10 137 SET(PCREPOSIX_HEADERS pcreposix.h)
361    
362     SET(PCREPOSIX_SOURCES pcreposix.c)
363    
364 ph10 719 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 ph10 137 SET(PCRECPP_HEADERS
388 ph10 303 pcrecpp.h
389     pcre_scanner.h
390 ph10 405 ${PROJECT_BINARY_DIR}/pcrecpparg.h
391     ${PROJECT_BINARY_DIR}/pcre_stringpiece.h
392 ph10 137 )
393    
394     SET(PCRECPP_SOURCES
395 ph10 318 pcrecpp.cc
396     pcre_scanner.cc
397     pcre_stringpiece.cc
398 ph10 137 )
399    
400     # Build setup
401    
402     ADD_DEFINITIONS(-DHAVE_CONFIG_H)
403    
404 ph10 303 IF(MSVC)
405 ph10 318 ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
406 ph10 303 ENDIF(MSVC)
407 ph10 137
408     SET(CMAKE_INCLUDE_CURRENT_DIR 1)
409 ph10 303 # 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 ph10 137
415 ph10 407 SET(targets)
416    
417 ph10 137 # Libraries
418 ph10 318 # pcre
419 ph10 405 ADD_LIBRARY(pcre ${PCRE_HEADERS} ${PCRE_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
420 ph10 407 SET(targets ${targets} pcre)
421 ph10 137 ADD_LIBRARY(pcreposix ${PCREPOSIX_HEADERS} ${PCREPOSIX_SOURCES})
422 ph10 407 SET(targets ${targets} pcreposix)
423 ph10 137 TARGET_LINK_LIBRARIES(pcreposix pcre)
424 ph10 318 IF(MINGW AND NOT PCRE_STATIC)
425     IF(NON_STANDARD_LIB_PREFIX)
426     SET_TARGET_PROPERTIES(pcre pcreposix
427 ph10 311 PROPERTIES PREFIX ""
428 ph10 318 )
429     ENDIF(NON_STANDARD_LIB_PREFIX)
430 ph10 311
431 ph10 318 IF(NON_STANDARD_LIB_SUFFIX)
432     SET_TARGET_PROPERTIES(pcre pcreposix
433 ph10 311 PROPERTIES SUFFIX "-0.dll"
434 ph10 318 )
435     ENDIF(NON_STANDARD_LIB_SUFFIX)
436     ENDIF(MINGW AND NOT PCRE_STATIC)
437 ph10 311
438 ph10 318
439     # pcrecpp
440 ph10 137 IF(PCRE_BUILD_PCRECPP)
441 ph10 303 ADD_LIBRARY(pcrecpp ${PCRECPP_HEADERS} ${PCRECPP_SOURCES})
442 ph10 407 SET(targets ${targets} pcrecpp)
443 ph10 303 TARGET_LINK_LIBRARIES(pcrecpp pcre)
444 ph10 311
445 ph10 318 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 ph10 137 ENDIF(PCRE_BUILD_PCRECPP)
459    
460 ph10 318
461 ph10 137 # Executables
462    
463 ph10 312 # 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 ph10 318 # SET_TARGET_PROPERTIES(pcredemo PROPERTIES COMPILE_FLAGS "-DPCRE_STATIC")
470 ph10 312 # ENDIF(NOT BUILD_SHARED_LIBS)
471 ph10 303
472 ph10 719 IF(PCRE_BUILD_PCREGREP OR PCRE_BUILD_TESTS)
473 ph10 407 ADD_EXECUTABLE(pcregrep pcregrep.c)
474     SET(targets ${targets} pcregrep)
475     TARGET_LINK_LIBRARIES(pcregrep pcreposix ${PCREGREP_LIBS})
476 ph10 719 ENDIF(PCRE_BUILD_PCREGREP OR PCRE_BUILD_TESTS)
477 ph10 144
478 ph10 407 # Testing
479     IF(PCRE_BUILD_TESTS)
480     ENABLE_TESTING()
481 ph10 144
482 ph10 407 ADD_EXECUTABLE(pcretest pcretest.c)
483     SET(targets ${targets} pcretest)
484     TARGET_LINK_LIBRARIES(pcretest pcreposix ${PCRETEST_LIBS})
485 ph10 691
486 ph10 698 IF(PCRE_SUPPORT_JIT)
487 ph10 667 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 ph10 698 ENDIF(PCRE_SUPPORT_JIT)
491 ph10 144
492 ph10 407 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 ph10 137
502 ph10 407 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 ph10 144
506 ph10 407 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 ph10 144
511 ph10 719 # exes in Debug location tested by the RunTest shell script
512     # via "make test"
513 ph10 407 GET_TARGET_PROPERTY(PCREGREP_EXE pcregrep DEBUG_LOCATION)
514     GET_TARGET_PROPERTY(PCRETEST_EXE pcretest DEBUG_LOCATION)
515 ph10 137
516 ph10 719 # =================================================
517     # Write out a CTest configuration file
518 ph10 407 #
519     FILE(WRITE ${PROJECT_BINARY_DIR}/CTestCustom.ctest
520     "# This is a generated file.
521 ph10 719 MESSAGE(\"When testing is complete, review test output in the
522     ${PROJECT_BINARY_DIR}/Testing/Temporary folder.\")
523     MESSAGE(\"\")
524     ")
525 ph10 144
526 ph10 719 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 ph10 407 IF(UNIX)
549 ph10 732 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 ph10 407 ENDIF(UNIX)
552 ph10 706
553 ph10 407 IF(WIN32)
554 ph10 719 # 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 ph10 706 IF("$ENV{OSTYPE}" STREQUAL "msys")
593 ph10 719 # 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 ph10 706 ENDIF("$ENV{OSTYPE}" STREQUAL "msys")
600 ph10 407 ENDIF(WIN32)
601 ph10 144
602 ph10 719 # Changed to accommodate testing whichever location was just built
603    
604 ph10 698 IF(PCRE_SUPPORT_JIT)
605 ph10 719 ADD_TEST(pcre_jit_test pcre_jit_test)
606 ph10 698 ENDIF(PCRE_SUPPORT_JIT)
607 ph10 667
608 ph10 719 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 ph10 144
613 ph10 719 ENDIF(PCRE_BUILD_PCRECPP)
614 ph10 407 ENDIF(PCRE_BUILD_TESTS)
615    
616 ph10 137 # Installation
617     SET(CMAKE_INSTALL_ALWAYS 1)
618    
619 ph10 407 INSTALL(TARGETS ${targets}
620 ph10 137 RUNTIME DESTINATION bin
621     LIBRARY DESTINATION lib
622     ARCHIVE DESTINATION lib)
623    
624     INSTALL(FILES ${PCRE_HEADERS} ${PCREPOSIX_HEADERS} DESTINATION include)
625    
626 ph10 405 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 ph10 137
630     IF(PCRE_BUILD_PCRECPP)
631 ph10 318 INSTALL(FILES ${PCRECPP_HEADERS} DESTINATION include)
632 ph10 137 ELSE(PCRE_BUILD_PCRECPP)
633 ph10 318 # 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 ph10 137 ENDIF(PCRE_BUILD_PCRECPP)
642    
643     INSTALL(FILES ${man1} DESTINATION man/man1)
644     INSTALL(FILES ${man3} DESTINATION man/man3)
645 ph10 199 INSTALL(FILES ${html} DESTINATION share/doc/pcre/html)
646 ph10 137
647 ph10 303 # 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 ph10 407 IF(PCRE_SHOW_REPORT)
655 ph10 414 STRING(TOUPPER "${CMAKE_BUILD_TYPE}" buildtype)
656 ph10 413 IF (CMAKE_C_FLAGS)
657     SET(cfsp " ")
658 ph10 416 ENDIF(CMAKE_C_FLAGS)
659 ph10 413 IF (CMAKE_CXX_FLAGS)
660     SET(cxxfsp " ")
661 ph10 416 ENDIF(CMAKE_CXX_FLAGS)
662 ph10 407 MESSAGE(STATUS "")
663     MESSAGE(STATUS "")
664     MESSAGE(STATUS "PCRE configuration summary:")
665     MESSAGE(STATUS "")
666 ph10 413 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 ph10 407 MESSAGE(STATUS "")
672 ph10 413 MESSAGE(STATUS " Build C++ library ............... : ${PCRE_BUILD_PCRECPP}")
673 ph10 667 MESSAGE(STATUS " Enable JIT compiling support .... : ${PCRE_SUPPORT_JIT}")
674 ph10 413 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 ph10 685 MESSAGE(STATUS " Enable JIT in pcregrep .......... : ${PCRE_SUPPORT_PCREGREP_JIT}")
689 ph10 655 MESSAGE(STATUS " Buffer size for pcregrep ........ : ${PCREGREP_BUFSIZE}")
690 ph10 719 MESSAGE(STATUS " Build tests (implies pcretest .. : ${PCRE_BUILD_TESTS}")
691     MESSAGE(STATUS " and pcregrep)")
692 ph10 407 IF(ZLIB_FOUND)
693 ph10 413 MESSAGE(STATUS " Link pcregrep with libz ......... : ${PCRE_SUPPORT_LIBZ}")
694 ph10 407 ELSE(ZLIB_FOUND)
695     MESSAGE(STATUS " Link pcregrep with libz ......... : None" )
696     ENDIF(ZLIB_FOUND)
697     IF(BZIP2_FOUND)
698 ph10 413 MESSAGE(STATUS " Link pcregrep with libbz2 ....... : ${PCRE_SUPPORT_LIBBZ2}")
699 ph10 407 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 ph10 413 MESSAGE(STATUS " Link pcretest with libreadline .. : ${PCRE_SUPPORT_LIBREADLINE}")
706 ph10 407 ENDIF(NOT PCRE_SUPPORT_LIBREADLINE)
707     IF(MINGW AND NOT PCRE_STATIC)
708 ph10 413 MESSAGE(STATUS " Non-standard dll names (prefix) . : ${NON_STANDARD_LIB_PREFIX}")
709     MESSAGE(STATUS " Non-standard dll names (suffix) . : ${NON_STANDARD_LIB_SUFFIX}")
710 ph10 407 ENDIF(MINGW AND NOT PCRE_STATIC)
711     MESSAGE(STATUS "")
712     ENDIF(PCRE_SHOW_REPORT)
713 ph10 303
714 ph10 137 # end CMakeLists.txt

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12