/[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 97 by ph10, Mon Mar 5 12:36:47 2007 UTC revision 140 by ph10, Fri Mar 30 14:16:42 2007 UTC
# Line 1  Line 1 
1  # This file is a placeholder.  # CMakeLists.txt
2    #
3    # This file allows building PCRE with the CMake configuration and build
4    # tool. Download CMake in source or binary form from http://www.cmake.org/
5    #
6    # Original listfile by Christian Ehrlicher <Ch.Ehrlicher@gmx.de>
7    # Refined and expanded by Daniel Richard G. <skunk@iSKUNK.ORG>
8    #
9    
10    PROJECT(PCRE C CXX)
11    
12    CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6)
13    
14    # Configuration checks
15    
16    INCLUDE(CheckIncludeFile)
17    INCLUDE(CheckIncludeFileCXX)
18    INCLUDE(CheckFunctionExists)
19    INCLUDE(CheckTypeSize)
20    
21    CHECK_INCLUDE_FILE(dirent.h     HAVE_DIRENT_H)
22    CHECK_INCLUDE_FILE(unistd.h     HAVE_UNISTD_H)
23    CHECK_INCLUDE_FILE(sys/stat.h   HAVE_SYS_STAT_H)
24    CHECK_INCLUDE_FILE(sys/types.h  HAVE_SYS_TYPES_H)
25    
26    CHECK_INCLUDE_FILE_CXX(type_traits.h            HAVE_TYPE_TRAITS_H)
27    CHECK_INCLUDE_FILE_CXX(bits/type_traits.h       HAVE_BITS_TYPE_TRAITS_H)
28    
29    CHECK_FUNCTION_EXISTS(bcopy     HAVE_BCOPY)
30    CHECK_FUNCTION_EXISTS(memmove   HAVE_MEMMOVE)
31    CHECK_FUNCTION_EXISTS(strerror  HAVE_STRERROR)
32    
33    CHECK_TYPE_SIZE("long long"             LONG_LONG)
34    CHECK_TYPE_SIZE("unsigned long long"    UNSIGNED_LONG_LONG)
35    
36    # User-configurable options
37    #
38    # (Note: CMakeSetup displays these in alphabetical order, regardless of
39    # the order we use here)
40    
41    SET(BUILD_SHARED_LIBS "SHARED" CACHE STRING
42        "What type of libraries to build. Set to SHARED or STATIC.")
43    
44    OPTION(PCRE_BUILD_PCRECPP "Build the PCRE C++ library (pcrecpp)." ON)
45    
46    SET(PCRE_EBCDIC FALSE CACHE BOOL
47        "Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems)")
48    
49    SET(PCRE_LINK_SIZE "2" CACHE STRING
50        "Internal link size (2, 3 or 4 allowed). See LINK_SIZE in config.h.in for details.")
51    
52    SET(PCRE_MATCH_LIMIT "10000000" CACHE STRING
53        "Default limit on internal looping. See MATCH_LIMIT in config.h.in for details.")
54    
55    SET(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT" CACHE STRING
56        "Default limit on internal recursion. See MATCH_LIMIT_RECURSION in config.h.in for details.")
57    
58    SET(PCRE_NEWLINE "LF" CACHE STRING
59        "What to recognize as a newline (one of CR, LF, CRLF, ANY).")
60    
61    SET(PCRE_NO_RECURSE TRUE CACHE BOOL
62        "If ON, then don't use stack recursion when matching. See NO_RECURSE in config.h.in for details.")
63    
64    SET(PCRE_POSIX_MALLOC_THRESHOLD "10" CACHE STRING
65        "Threshold for malloc() usage. See POSIX_MALLOC_THRESHOLD in config.h.in for details.")
66    
67    SET(PCRE_SUPPORT_UNICODE_PROPERTIES FALSE CACHE BOOL
68        "Enable support for Unicode properties. (If set, UTF-8 support will be enabled as well)")
69    
70    SET(PCRE_SUPPORT_UTF8 FALSE CACHE BOOL
71        "Enable support for the Unicode UTF-8 encoding.")
72    
73    # Prepare build configuration
74    
75    SET(pcre_have_type_traits 0)
76    SET(pcre_have_bits_type_traits 0)
77    
78    IF(HAVE_TYPE_TRAITS_H)
79            SET(pcre_have_type_traits 1)
80    ENDIF(HAVE_TYPE_TRAITS_H)
81    
82    IF(HAVE_BITS_TYPE_TRAITS_H)
83            SET(pcre_have_bits_type_traits 1)
84    ENDIF(HAVE_BITS_TYPE_TRAITS_H)
85    
86    SET(pcre_have_long_long 0)
87    SET(pcre_have_ulong_long 0)
88    
89    IF(HAVE_LONG_LONG)
90            SET(pcre_have_long_long 1)
91    ENDIF(HAVE_LONG_LONG)
92    
93    IF(HAVE_UNSIGNED_LONG_LONG)
94            SET(pcre_have_ulong_long 1)
95    ENDIF(HAVE_UNSIGNED_LONG_LONG)
96    
97    IF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES)
98            SET(SUPPORT_UTF8 1)
99    ENDIF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES)
100    
101    IF(PCRE_SUPPORT_UNICODE_PROPERTIES)
102            SET(SUPPORT_UCP 1)
103    ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES)
104    
105    IF(PCRE_NEWLINE STREQUAL "LF")
106      SET(NEWLINE "10")
107    ELSE(PCRE_NEWLINE STREQUAL "LF")
108      IF(PCRE_NEWLINE STREQUAL "CR")
109        SET(NEWLINE "13")
110      ELSE(PCRE_NEWLINE STREQUAL "CR")
111        IF(PCRE_NEWLINE STREQUAL "CRLF")
112          SET(NEWLINE "3338")
113        ELSE(PCRE_NEWLINE STREQUAL "CRLF")
114          IF(PCRE_NEWLINE STREQUAL "ANY")
115            SET(NEWLINE "-1")
116          ELSE(PCRE_NEWLINE STREQUAL "ANY")
117            MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\".")
118          ENDIF(PCRE_NEWLINE STREQUAL "ANY")
119        ENDIF(PCRE_NEWLINE STREQUAL "CRLF")
120      ENDIF(PCRE_NEWLINE STREQUAL "CR")
121    ENDIF(PCRE_NEWLINE STREQUAL "LF")
122    
123    IF(PCRE_EBCDIC)
124            SET(EBCDIC 1)
125    ENDIF(PCRE_EBCDIC)
126    
127    IF(PCRE_NO_RECURSE)
128            SET(NO_RECURSE 1)
129    ENDIF(PCRE_NO_RECURSE)
130    
131    # Output files
132    
133    CONFIGURE_FILE(config-cmake.h.in
134                   ${CMAKE_BINARY_DIR}/config.h
135                   @ONLY)
136    
137    CONFIGURE_FILE(pcre.h.generic
138                   ${CMAKE_BINARY_DIR}/pcre.h
139                   COPYONLY)
140    
141    # What about pcre-config and libpcre.pc?
142    
143    IF(PCRE_BUILD_PCRECPP)
144            CONFIGURE_FILE(pcre_stringpiece.h.in
145                           ${CMAKE_BINARY_DIR}/pcre_stringpiece.h
146                           @ONLY)
147    
148            CONFIGURE_FILE(pcrecpparg.h.in
149                           ${CMAKE_BINARY_DIR}/pcrecpparg.h
150                           @ONLY)
151    ENDIF(PCRE_BUILD_PCRECPP)
152    
153    # Character table generation
154    
155    ADD_EXECUTABLE(dftables dftables.c)
156    
157    GET_TARGET_PROPERTY(DFTABLES_EXE dftables LOCATION)
158    
159    ADD_CUSTOM_COMMAND(
160            COMMENT "Generating character tables (pcre_chartables.c) for current locale"
161            DEPENDS dftables
162            COMMAND ${DFTABLES_EXE}
163            ARGS    ${CMAKE_BINARY_DIR}/pcre_chartables.c
164            OUTPUT  ${CMAKE_BINARY_DIR}/pcre_chartables.c
165    )
166    
167    # Source code
168    
169    SET(PCRE_HEADERS ${CMAKE_BINARY_DIR}/pcre.h)
170    
171    SET(PCRE_SOURCES
172            ${CMAKE_BINARY_DIR}/pcre_chartables.c
173            pcre_compile.c
174            pcre_config.c
175            pcre_dfa_exec.c
176            pcre_exec.c
177            pcre_fullinfo.c
178            pcre_get.c
179            pcre_globals.c
180            pcre_info.c
181            pcre_newline.c
182            pcre_maketables.c
183            pcre_ord2utf8.c
184            pcre_refcount.c
185            pcre_study.c
186            pcre_tables.c
187            pcre_try_flipped.c
188            pcre_ucp_searchfuncs.c
189            pcre_valid_utf8.c
190            pcre_version.c
191            pcre_xclass.c
192    )
193    
194    SET(PCREPOSIX_HEADERS pcreposix.h)
195    
196    SET(PCREPOSIX_SOURCES pcreposix.c)
197    
198    SET(PCRECPP_HEADERS
199            pcrecpp.h
200            pcre_scanner.h
201            ${CMAKE_BINARY_DIR}/pcrecpparg.h
202            ${CMAKE_BINARY_DIR}/pcre_stringpiece.h
203    )
204    
205    SET(PCRECPP_SOURCES
206            pcrecpp.cc
207            pcre_scanner.cc
208            pcre_stringpiece.cc
209    )
210    
211    # Build setup
212    
213    ADD_DEFINITIONS(-DHAVE_CONFIG_H)
214    
215    IF(WIN32)
216            # What about -DDLL_EXPORT?
217            ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
218    ENDIF(WIN32)
219    
220    SET(CMAKE_INCLUDE_CURRENT_DIR 1)
221    
222    #SET(CMAKE_DEBUG_POSTFIX "d")
223    
224    # Libraries
225    
226    ADD_LIBRARY(pcre ${PCRE_HEADERS} ${PCRE_SOURCES})
227    
228    ADD_LIBRARY(pcreposix ${PCREPOSIX_HEADERS} ${PCREPOSIX_SOURCES})
229    TARGET_LINK_LIBRARIES(pcreposix pcre)
230    
231    IF(PCRE_BUILD_PCRECPP)
232            ADD_LIBRARY(pcrecpp ${PCRECPP_HEADERS} ${PCRECPP_SOURCES})
233            TARGET_LINK_LIBRARIES(pcrecpp pcre)
234            IF(MINGW)
235                    SET_TARGET_PROPERTIES(pcrecpp PROPERTIES PREFIX "mingw-")
236            ENDIF(MINGW)
237    ENDIF(PCRE_BUILD_PCRECPP)
238    
239    # Executables
240    
241    ADD_EXECUTABLE(pcretest pcretest.c)
242    TARGET_LINK_LIBRARIES(pcretest pcreposix)
243    
244    ADD_EXECUTABLE(pcregrep pcregrep.c)
245    TARGET_LINK_LIBRARIES(pcregrep pcreposix)
246    
247    # Testing
248    
249    ENABLE_TESTING()
250    
251    IF(UNIX)
252            ADD_TEST(test1 sh -c "srcdir=${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/RunTest")
253            ADD_TEST(test2 sh -c "srcdir=${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/RunGrepTest")
254    ELSE(UNIX)
255      IF(WIN32)
256            ADD_TEST(test1 ${CMAKE_SOURCE_DIR}/RunTest.bat ${CMAKE_SOURCE_DIR})
257      ENDIF(WIN32)
258    ENDIF(UNIX)
259    
260    # Installation
261    
262    SET(CMAKE_INSTALL_ALWAYS 1)
263    
264    INSTALL(TARGETS pcre pcreposix pcregrep pcretest
265            RUNTIME DESTINATION bin
266            LIBRARY DESTINATION lib
267            ARCHIVE DESTINATION lib)
268    
269    INSTALL(FILES ${PCRE_HEADERS} ${PCREPOSIX_HEADERS} DESTINATION include)
270    
271    FILE(GLOB html ${CMAKE_SOURCE_DIR}/doc/html/*.html)
272    FILE(GLOB man1 ${CMAKE_SOURCE_DIR}/doc/*.1)
273    FILE(GLOB man3 ${CMAKE_SOURCE_DIR}/doc/*.3)
274    
275    IF(PCRE_BUILD_PCRECPP)
276            INSTALL(TARGETS pcrecpp DESTINATION lib)
277            INSTALL(FILES ${PCRECPP_HEADERS} DESTINATION include)
278    ELSE(PCRE_BUILD_PCRECPP)
279            # Remove pcrecpp.3
280            FOREACH(man ${man3})
281                    GET_FILENAME_COMPONENT(man_tmp ${man} NAME)
282                    IF(NOT man_tmp STREQUAL "pcrecpp.3")
283                            SET(man3_new ${man3} ${man})
284                    ENDIF(NOT man_tmp STREQUAL "pcrecpp.3")
285            ENDFOREACH(man ${man3})
286            SET(man3 ${man3_new})
287    ENDIF(PCRE_BUILD_PCRECPP)
288    
289    INSTALL(FILES ${man1} DESTINATION man/man1)
290    INSTALL(FILES ${man3} DESTINATION man/man3)
291    INSTALL(FILES ${html} DESTINATION doc/html)
292    
293    # end CMakeLists.txt

Legend:
Removed from v.97  
changed lines
  Added in v.140

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12