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

Contents of /code/trunk/CMakeLists.txt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 144 - (hide annotations) (download)
Mon Apr 2 13:32:07 2007 UTC (7 years ago) by ph10
File MIME type: text/plain
File size: 8873 byte(s)
Daniel's patches to add to the CMake support.

1 ph10 137 # 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 ph10 144 SET(BUILD_SHARED_LIBS OFF CACHE BOOL
42     "Build shared libraries instead of static ones.")
43 ph10 137
44     OPTION(PCRE_BUILD_PCRECPP "Build the PCRE C++ library (pcrecpp)." ON)
45    
46 ph10 144 SET(PCRE_EBCDIC OFF CACHE BOOL
47 ph10 137 "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 ph10 144 SET(PCRE_NO_RECURSE ON CACHE BOOL
62 ph10 137 "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 ph10 144 SET(PCRE_SUPPORT_UNICODE_PROPERTIES OFF CACHE BOOL
68 ph10 137 "Enable support for Unicode properties. (If set, UTF-8 support will be enabled as well)")
69    
70 ph10 144 SET(PCRE_SUPPORT_UTF8 OFF CACHE BOOL
71 ph10 137 "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 ph10 144 IF(NOT BUILD_SHARED_LIBS)
98     SET(PCRE_STATIC 1)
99     ENDIF(NOT BUILD_SHARED_LIBS)
100    
101 ph10 137 IF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES)
102     SET(SUPPORT_UTF8 1)
103     ENDIF(PCRE_SUPPORT_UTF8 OR PCRE_SUPPORT_UNICODE_PROPERTIES)
104    
105     IF(PCRE_SUPPORT_UNICODE_PROPERTIES)
106     SET(SUPPORT_UCP 1)
107     ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES)
108    
109 ph10 144 SET(NEWLINE "")
110    
111 ph10 137 IF(PCRE_NEWLINE STREQUAL "LF")
112 ph10 144 SET(NEWLINE "10")
113     ENDIF(PCRE_NEWLINE STREQUAL "LF")
114     IF(PCRE_NEWLINE STREQUAL "CR")
115     SET(NEWLINE "13")
116     ENDIF(PCRE_NEWLINE STREQUAL "CR")
117     IF(PCRE_NEWLINE STREQUAL "CRLF")
118     SET(NEWLINE "3338")
119     ENDIF(PCRE_NEWLINE STREQUAL "CRLF")
120     IF(PCRE_NEWLINE STREQUAL "ANY")
121 ph10 137 SET(NEWLINE "-1")
122 ph10 144 ENDIF(PCRE_NEWLINE STREQUAL "ANY")
123    
124     IF(NEWLINE STREQUAL "")
125 ph10 137 MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\".")
126 ph10 144 ENDIF(NEWLINE STREQUAL "")
127 ph10 137
128     IF(PCRE_EBCDIC)
129     SET(EBCDIC 1)
130     ENDIF(PCRE_EBCDIC)
131    
132     IF(PCRE_NO_RECURSE)
133     SET(NO_RECURSE 1)
134     ENDIF(PCRE_NO_RECURSE)
135    
136     # Output files
137    
138     CONFIGURE_FILE(config-cmake.h.in
139     ${CMAKE_BINARY_DIR}/config.h
140     @ONLY)
141    
142     CONFIGURE_FILE(pcre.h.generic
143     ${CMAKE_BINARY_DIR}/pcre.h
144     COPYONLY)
145    
146     # What about pcre-config and libpcre.pc?
147    
148     IF(PCRE_BUILD_PCRECPP)
149     CONFIGURE_FILE(pcre_stringpiece.h.in
150 ph10 140 ${CMAKE_BINARY_DIR}/pcre_stringpiece.h
151     @ONLY)
152 ph10 137
153     CONFIGURE_FILE(pcrecpparg.h.in
154 ph10 140 ${CMAKE_BINARY_DIR}/pcrecpparg.h
155     @ONLY)
156 ph10 137 ENDIF(PCRE_BUILD_PCRECPP)
157    
158     # Character table generation
159    
160     ADD_EXECUTABLE(dftables dftables.c)
161    
162     GET_TARGET_PROPERTY(DFTABLES_EXE dftables LOCATION)
163    
164     ADD_CUSTOM_COMMAND(
165     COMMENT "Generating character tables (pcre_chartables.c) for current locale"
166     DEPENDS dftables
167     COMMAND ${DFTABLES_EXE}
168 ph10 140 ARGS ${CMAKE_BINARY_DIR}/pcre_chartables.c
169     OUTPUT ${CMAKE_BINARY_DIR}/pcre_chartables.c
170 ph10 137 )
171    
172     # Source code
173    
174     SET(PCRE_HEADERS ${CMAKE_BINARY_DIR}/pcre.h)
175    
176     SET(PCRE_SOURCES
177     ${CMAKE_BINARY_DIR}/pcre_chartables.c
178     pcre_compile.c
179     pcre_config.c
180     pcre_dfa_exec.c
181     pcre_exec.c
182     pcre_fullinfo.c
183     pcre_get.c
184     pcre_globals.c
185     pcre_info.c
186     pcre_newline.c
187     pcre_maketables.c
188     pcre_ord2utf8.c
189     pcre_refcount.c
190     pcre_study.c
191     pcre_tables.c
192     pcre_try_flipped.c
193     pcre_ucp_searchfuncs.c
194     pcre_valid_utf8.c
195     pcre_version.c
196     pcre_xclass.c
197     )
198    
199     SET(PCREPOSIX_HEADERS pcreposix.h)
200    
201     SET(PCREPOSIX_SOURCES pcreposix.c)
202    
203     SET(PCRECPP_HEADERS
204     pcrecpp.h
205     pcre_scanner.h
206     ${CMAKE_BINARY_DIR}/pcrecpparg.h
207     ${CMAKE_BINARY_DIR}/pcre_stringpiece.h
208     )
209    
210     SET(PCRECPP_SOURCES
211     pcrecpp.cc
212     pcre_scanner.cc
213     pcre_stringpiece.cc
214     )
215    
216     # Build setup
217    
218     ADD_DEFINITIONS(-DHAVE_CONFIG_H)
219    
220     IF(WIN32)
221     # What about -DDLL_EXPORT?
222     ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
223     ENDIF(WIN32)
224    
225     SET(CMAKE_INCLUDE_CURRENT_DIR 1)
226    
227     #SET(CMAKE_DEBUG_POSTFIX "d")
228    
229     # Libraries
230    
231     ADD_LIBRARY(pcre ${PCRE_HEADERS} ${PCRE_SOURCES})
232    
233     ADD_LIBRARY(pcreposix ${PCREPOSIX_HEADERS} ${PCREPOSIX_SOURCES})
234     TARGET_LINK_LIBRARIES(pcreposix pcre)
235    
236     IF(PCRE_BUILD_PCRECPP)
237     ADD_LIBRARY(pcrecpp ${PCRECPP_HEADERS} ${PCRECPP_SOURCES})
238     TARGET_LINK_LIBRARIES(pcrecpp pcre)
239     IF(MINGW)
240     SET_TARGET_PROPERTIES(pcrecpp PROPERTIES PREFIX "mingw-")
241     ENDIF(MINGW)
242     ENDIF(PCRE_BUILD_PCRECPP)
243    
244     # Executables
245    
246     ADD_EXECUTABLE(pcretest pcretest.c)
247     TARGET_LINK_LIBRARIES(pcretest pcreposix)
248    
249     ADD_EXECUTABLE(pcregrep pcregrep.c)
250     TARGET_LINK_LIBRARIES(pcregrep pcreposix)
251    
252 ph10 144 IF(PCRE_BUILD_PCRECPP)
253     ADD_EXECUTABLE(pcrecpp_unittest pcrecpp_unittest.cc)
254     TARGET_LINK_LIBRARIES(pcrecpp_unittest pcrecpp)
255    
256     ADD_EXECUTABLE(pcre_scanner_unittest pcre_scanner_unittest.cc)
257     TARGET_LINK_LIBRARIES(pcre_scanner_unittest pcrecpp)
258    
259     ADD_EXECUTABLE(pcre_stringpiece_unittest pcre_stringpiece_unittest.cc)
260     TARGET_LINK_LIBRARIES(pcre_stringpiece_unittest pcrecpp)
261     ENDIF(PCRE_BUILD_PCRECPP)
262    
263 ph10 137 # Testing
264    
265     ENABLE_TESTING()
266    
267 ph10 144 GET_TARGET_PROPERTY(PCREGREP_EXE pcregrep DEBUG_LOCATION)
268     GET_TARGET_PROPERTY(PCRETEST_EXE pcretest DEBUG_LOCATION)
269    
270     # Write out a CTest configuration file that sets some needed environment
271     # variables for the test scripts.
272     #
273     FILE(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.ctest
274     "# This is a generated file.
275     SET(ENV{srcdir} ${CMAKE_SOURCE_DIR})
276     SET(ENV{pcregrep} ${PCREGREP_EXE})
277     SET(ENV{pcretest} ${PCRETEST_EXE})
278     ")
279    
280 ph10 137 IF(UNIX)
281 ph10 144 ADD_TEST(pcre_test ${CMAKE_SOURCE_DIR}/RunTest)
282     ADD_TEST(pcre_grep_test ${CMAKE_SOURCE_DIR}/RunGrepTest)
283 ph10 137 ENDIF(UNIX)
284 ph10 144 IF(WIN32)
285     ADD_TEST(pcre_test cmd /C ${CMAKE_SOURCE_DIR}/RunTest.bat)
286     ENDIF(WIN32)
287 ph10 137
288 ph10 144 GET_TARGET_PROPERTY(PCRECPP_UNITTEST_EXE
289     pcrecpp_unittest
290     DEBUG_LOCATION)
291    
292     GET_TARGET_PROPERTY(PCRE_SCANNER_UNITTEST_EXE
293     pcre_scanner_unittest
294     DEBUG_LOCATION)
295    
296     GET_TARGET_PROPERTY(PCRE_STRINGPIECE_UNITTEST_EXE
297     pcre_stringpiece_unittest
298     DEBUG_LOCATION)
299    
300     ADD_TEST(pcrecpp_test ${PCRECPP_UNITTEST_EXE})
301     ADD_TEST(pcre_scanner_test ${PCRE_SCANNER_UNITTEST_EXE})
302     ADD_TEST(pcre_stringpiece_test ${PCRE_STRINGPIECE_UNITTEST_EXE})
303    
304 ph10 137 # Installation
305    
306     SET(CMAKE_INSTALL_ALWAYS 1)
307    
308     INSTALL(TARGETS pcre pcreposix pcregrep pcretest
309     RUNTIME DESTINATION bin
310     LIBRARY DESTINATION lib
311     ARCHIVE DESTINATION lib)
312    
313     INSTALL(FILES ${PCRE_HEADERS} ${PCREPOSIX_HEADERS} DESTINATION include)
314    
315     FILE(GLOB html ${CMAKE_SOURCE_DIR}/doc/html/*.html)
316     FILE(GLOB man1 ${CMAKE_SOURCE_DIR}/doc/*.1)
317     FILE(GLOB man3 ${CMAKE_SOURCE_DIR}/doc/*.3)
318    
319     IF(PCRE_BUILD_PCRECPP)
320     INSTALL(TARGETS pcrecpp DESTINATION lib)
321     INSTALL(FILES ${PCRECPP_HEADERS} DESTINATION include)
322     ELSE(PCRE_BUILD_PCRECPP)
323     # Remove pcrecpp.3
324     FOREACH(man ${man3})
325     GET_FILENAME_COMPONENT(man_tmp ${man} NAME)
326     IF(NOT man_tmp STREQUAL "pcrecpp.3")
327     SET(man3_new ${man3} ${man})
328     ENDIF(NOT man_tmp STREQUAL "pcrecpp.3")
329     ENDFOREACH(man ${man3})
330     SET(man3 ${man3_new})
331     ENDIF(PCRE_BUILD_PCRECPP)
332    
333     INSTALL(FILES ${man1} DESTINATION man/man1)
334     INSTALL(FILES ${man3} DESTINATION man/man3)
335     INSTALL(FILES ${html} DESTINATION doc/html)
336    
337     # end CMakeLists.txt

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12