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

Diff of /code/trunk/CMakeLists.txt

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.200  
changed lines
  Added in v.1221

  ViewVC Help
Powered by ViewVC 1.1.5