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

Contents of /code/trunk/CMakeLists.txt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 258 - (show annotations) (download)
Wed Sep 19 09:27:50 2007 UTC (7 years, 2 months ago) by ph10
File MIME type: text/plain
File size: 9486 byte(s)
Sheri's CMake updates and notes.

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

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12