/[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 200 by ph10, Wed Aug 1 09:10:40 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 OFF CACHE BOOL
42        "Build shared libraries instead of static ones.")
43    
44    OPTION(PCRE_BUILD_PCRECPP "Build the PCRE C++ library (pcrecpp)." ON)
45    
46    SET(PCRE_EBCDIC OFF 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 OFF 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 OFF CACHE BOOL
68        "Enable support for Unicode properties. (If set, UTF-8 support will be enabled as well)")
69    
70    SET(PCRE_SUPPORT_UTF8 OFF 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(NOT BUILD_SHARED_LIBS)
98            SET(PCRE_STATIC 1)
99    ENDIF(NOT BUILD_SHARED_LIBS)
100    
101    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    SET(NEWLINE "")
110    
111    IF(PCRE_NEWLINE STREQUAL "LF")
112            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            SET(NEWLINE "-1")
122    ENDIF(PCRE_NEWLINE STREQUAL "ANY")
123    
124    IF(NEWLINE STREQUAL "")
125            MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\".")
126    ENDIF(NEWLINE STREQUAL "")
127    
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                           ${CMAKE_BINARY_DIR}/pcre_stringpiece.h
151                           @ONLY)
152    
153            CONFIGURE_FILE(pcrecpparg.h.in
154                           ${CMAKE_BINARY_DIR}/pcrecpparg.h
155                           @ONLY)
156    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            ARGS    ${CMAKE_BINARY_DIR}/pcre_chartables.c
169            OUTPUT  ${CMAKE_BINARY_DIR}/pcre_chartables.c
170    )
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            ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
222    ENDIF(WIN32)
223    
224    SET(CMAKE_INCLUDE_CURRENT_DIR 1)
225    
226    #SET(CMAKE_DEBUG_POSTFIX "d")
227    
228    # Libraries
229    
230    ADD_LIBRARY(pcre ${PCRE_HEADERS} ${PCRE_SOURCES})
231    
232    ADD_LIBRARY(pcreposix ${PCREPOSIX_HEADERS} ${PCREPOSIX_SOURCES})
233    TARGET_LINK_LIBRARIES(pcreposix pcre)
234    
235    IF(PCRE_BUILD_PCRECPP)
236            ADD_LIBRARY(pcrecpp ${PCRECPP_HEADERS} ${PCRECPP_SOURCES})
237            TARGET_LINK_LIBRARIES(pcrecpp pcre)
238            IF(MINGW)
239                    SET_TARGET_PROPERTIES(pcrecpp PROPERTIES PREFIX "mingw-")
240            ENDIF(MINGW)
241    ENDIF(PCRE_BUILD_PCRECPP)
242    
243    # Executables
244    
245    ADD_EXECUTABLE(pcretest pcretest.c)
246    TARGET_LINK_LIBRARIES(pcretest pcreposix)
247    
248    ADD_EXECUTABLE(pcregrep pcregrep.c)
249    TARGET_LINK_LIBRARIES(pcregrep pcreposix)
250    
251    IF(PCRE_BUILD_PCRECPP)
252            ADD_EXECUTABLE(pcrecpp_unittest pcrecpp_unittest.cc)
253            TARGET_LINK_LIBRARIES(pcrecpp_unittest pcrecpp)
254    
255            ADD_EXECUTABLE(pcre_scanner_unittest pcre_scanner_unittest.cc)
256            TARGET_LINK_LIBRARIES(pcre_scanner_unittest pcrecpp)
257    
258            ADD_EXECUTABLE(pcre_stringpiece_unittest pcre_stringpiece_unittest.cc)
259            TARGET_LINK_LIBRARIES(pcre_stringpiece_unittest pcrecpp)
260    ENDIF(PCRE_BUILD_PCRECPP)
261    
262    # Testing
263    
264    ENABLE_TESTING()
265    
266    GET_TARGET_PROPERTY(PCREGREP_EXE pcregrep DEBUG_LOCATION)
267    GET_TARGET_PROPERTY(PCRETEST_EXE pcretest DEBUG_LOCATION)
268    
269    # Write out a CTest configuration file that sets some needed environment
270    # variables for the test scripts.
271    #
272    FILE(WRITE ${CMAKE_BINARY_DIR}/CTestCustom.ctest
273    "# This is a generated file.
274    SET(ENV{srcdir} ${CMAKE_SOURCE_DIR})
275    SET(ENV{pcregrep} ${PCREGREP_EXE})
276    SET(ENV{pcretest} ${PCRETEST_EXE})
277    ")
278    
279    IF(UNIX)
280            ADD_TEST(pcre_test      ${CMAKE_SOURCE_DIR}/RunTest)
281            ADD_TEST(pcre_grep_test ${CMAKE_SOURCE_DIR}/RunGrepTest)
282    ENDIF(UNIX)
283    IF(WIN32)
284            ADD_TEST(pcre_test cmd /C ${CMAKE_SOURCE_DIR}/RunTest.bat)
285    ENDIF(WIN32)
286    
287    GET_TARGET_PROPERTY(PCRECPP_UNITTEST_EXE
288                        pcrecpp_unittest
289                        DEBUG_LOCATION)
290    
291    GET_TARGET_PROPERTY(PCRE_SCANNER_UNITTEST_EXE
292                        pcre_scanner_unittest
293                        DEBUG_LOCATION)
294    
295    GET_TARGET_PROPERTY(PCRE_STRINGPIECE_UNITTEST_EXE
296                        pcre_stringpiece_unittest
297                        DEBUG_LOCATION)
298    
299    ADD_TEST(pcrecpp_test          ${PCRECPP_UNITTEST_EXE})
300    ADD_TEST(pcre_scanner_test     ${PCRE_SCANNER_UNITTEST_EXE})
301    ADD_TEST(pcre_stringpiece_test ${PCRE_STRINGPIECE_UNITTEST_EXE})
302    
303    # Installation
304    
305    SET(CMAKE_INSTALL_ALWAYS 1)
306    
307    INSTALL(TARGETS pcre pcreposix pcregrep pcretest
308            RUNTIME DESTINATION bin
309            LIBRARY DESTINATION lib
310            ARCHIVE DESTINATION lib)
311    
312    INSTALL(FILES ${PCRE_HEADERS} ${PCREPOSIX_HEADERS} DESTINATION include)
313    
314    FILE(GLOB html ${CMAKE_SOURCE_DIR}/doc/html/*.html)
315    FILE(GLOB man1 ${CMAKE_SOURCE_DIR}/doc/*.1)
316    FILE(GLOB man3 ${CMAKE_SOURCE_DIR}/doc/*.3)
317    
318    IF(PCRE_BUILD_PCRECPP)
319            INSTALL(TARGETS pcrecpp
320                    RUNTIME DESTINATION bin
321                    LIBRARY DESTINATION lib
322                    ARCHIVE DESTINATION lib)
323            INSTALL(FILES ${PCRECPP_HEADERS} DESTINATION include)
324    ELSE(PCRE_BUILD_PCRECPP)
325            # Remove pcrecpp.3
326            FOREACH(man ${man3})
327                    GET_FILENAME_COMPONENT(man_tmp ${man} NAME)
328                    IF(NOT man_tmp STREQUAL "pcrecpp.3")
329                            SET(man3_new ${man3} ${man})
330                    ENDIF(NOT man_tmp STREQUAL "pcrecpp.3")
331            ENDFOREACH(man ${man3})
332            SET(man3 ${man3_new})
333    ENDIF(PCRE_BUILD_PCRECPP)
334    
335    INSTALL(FILES ${man1} DESTINATION man/man1)
336    INSTALL(FILES ${man3} DESTINATION man/man3)
337    INSTALL(FILES ${html} DESTINATION share/doc/pcre/html)
338    
339    # end CMakeLists.txt

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

  ViewVC Help
Powered by ViewVC 1.1.5