Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 1 | # CMakeLists.txt |
| 2 | # |
| 3 | # |
| 4 | # This file enables PCRE2 to be built with the CMake configuration and build |
| 5 | # tool. Download CMake in source or binary form from http://www.cmake.org/ |
| 6 | # Converted to support PCRE2 from the original PCRE file, August 2014. |
| 7 | # |
| 8 | # Original listfile by Christian Ehrlicher <Ch.Ehrlicher@gmx.de> |
| 9 | # Refined and expanded by Daniel Richard G. <skunk@iSKUNK.ORG> |
| 10 | # 2007-09-14 mod by Sheri so 7.4 supported configuration options can be entered |
| 11 | # 2007-09-19 Adjusted by PH to retain previous default settings |
| 12 | # 2007-12-26 (a) On UNIX, use names libpcre instead of just pcre |
| 13 | # (b) Ensure pcretest and pcregrep link with the local library, |
| 14 | # not a previously-installed one. |
| 15 | # (c) Add PCRE_SUPPORT_LIBREADLINE, PCRE_SUPPORT_LIBZ, and |
| 16 | # PCRE_SUPPORT_LIBBZ2. |
| 17 | # 2008-01-20 Brought up to date to include several new features by Christian |
| 18 | # Ehrlicher. |
| 19 | # 2008-01-22 Sheri added options for backward compatibility of library names |
| 20 | # when building with minGW: |
| 21 | # if "ON", NON_STANDARD_LIB_PREFIX causes shared libraries to |
| 22 | # be built without "lib" as prefix. (The libraries will be named |
| 23 | # pcre.dll, pcreposix.dll and pcrecpp.dll). |
| 24 | # if "ON", NON_STANDARD_LIB_SUFFIX causes shared libraries to |
| 25 | # be built with suffix of "-0.dll". (The libraries will be named |
| 26 | # libpcre-0.dll, libpcreposix-0.dll and libpcrecpp-0.dll - same names |
| 27 | # built by default with Configure and Make. |
| 28 | # 2008-01-23 PH removed the automatic build of pcredemo. |
| 29 | # 2008-04-22 PH modified READLINE support so it finds NCURSES when needed. |
| 30 | # 2008-07-03 PH updated for revised UCP property support (change of files) |
| 31 | # 2009-03-23 PH applied Steven Van Ingelgem's patch to change the name |
| 32 | # CMAKE_BINARY_DIR to PROJECT_BINARY_DIR so that it works when PCRE |
| 33 | # is included within another project. |
| 34 | # 2009-03-23 PH applied a modified version of Steven Van Ingelgem's patches to |
| 35 | # add options to stop the building of pcregrep and the tests, and |
| 36 | # to disable the final configuration report. |
| 37 | # 2009-04-11 PH applied Christian Ehrlicher's patch to show compiler flags that |
| 38 | # are set by specifying a release type. |
| 39 | # 2010-01-02 PH added test for stdint.h |
| 40 | # 2010-03-02 PH added test for inttypes.h |
| 41 | # 2011-08-01 PH added PCREGREP_BUFSIZE |
| 42 | # 2011-08-22 PH added PCRE_SUPPORT_JIT |
| 43 | # 2011-09-06 PH modified WIN32 ADD_TEST line as suggested by Sergey Cherepanov |
| 44 | # 2011-09-06 PH added PCRE_SUPPORT_PCREGREP_JIT |
| 45 | # 2011-10-04 Sheri added support for including coff data in windows shared libraries |
| 46 | # compiled with MINGW if pcre.rc and/or pcreposix.rc are placed in |
| 47 | # the source dir by the user prior to building |
| 48 | # 2011-10-04 Sheri changed various add_test's to use exes' location built instead |
| 49 | # of DEBUG location only (likely only matters in MSVC) |
| 50 | # 2011-10-04 Sheri added scripts to provide needed variables to RunTest and |
| 51 | # RunGrepTest (used for UNIX and Msys) |
| 52 | # 2011-10-04 Sheri added scripts to provide needed variables and to execute |
| 53 | # RunTest.bat in Win32 (for effortless testing with "make test") |
| 54 | # 2011-10-04 Sheri Increased minimum required cmake version |
| 55 | # 2012-01-06 PH removed pcre_info.c and added pcre_string_utils.c |
| 56 | # 2012-01-10 Zoltan Herczeg added libpcre16 support |
| 57 | # 2012-01-13 Stephen Kelly added out of source build support |
| 58 | # 2012-01-17 PH applied Stephen Kelly's patch to parse the version data out |
| 59 | # of the configure.ac file |
| 60 | # 2012-02-26 PH added support for libedit |
| 61 | # 2012-09-06 PH added support for PCRE_EBCDIC_NL25 |
| 62 | # 2012-09-08 ChPe added PCRE32 support |
| 63 | # 2012-10-23 PH added support for VALGRIND and GCOV |
| 64 | # 2012-12-08 PH added patch from Daniel Richard G to quash some MSVC warnings |
| 65 | # 2013-07-01 PH realized that the "support" for GCOV was a total nonsense and |
| 66 | # so it has been removed. |
| 67 | # 2013-10-08 PH got rid of the "source" command, which is a bash-ism (use ".") |
| 68 | # 2013-11-05 PH added support for PARENS_NEST_LIMIT |
| 69 | # 2014-08-29 PH converted the file for PCRE2 (which has no C++). |
| 70 | # 2015-04-24 PH added support for PCRE2_DEBUG |
| 71 | # 2015-07-16 PH updated for new pcre2_find_bracket source module |
| 72 | # 2015-08-24 PH correct C_FLAGS setting (patch from Roy Ivy III) |
| 73 | # 2015-10=16 PH added support for never-backslash-C |
Janis Danisevskis | 8b979b2 | 2016-08-15 16:09:16 +0100 | [diff] [blame] | 74 | # 2016-03-01 PH applied Chris Wilson's patch for MSVC static |
| 75 | # 2016-06-24 PH applied Chris Wilson's second patch, putting the first under |
| 76 | # a new option instead of being unconditional. |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 77 | # 2016-10-05 PH fixed a typo (PCRE should be PCRE2) in above patch |
| 78 | # fix by David Gaussmann |
| 79 | # 2016-10-07 PH added PCREGREP_MAX_BUFSIZE |
| 80 | # 2017-03-11 PH turned HEAP_MATCH_RECURSE into a NO-OP for 10.30 |
| 81 | # 2017-04-08 PH added HEAP_LIMIT |
| 82 | # 2017-06-15 ZH added SUPPORT_JIT_SEALLOC support |
Elliott Hughes | 653c210 | 2019-01-09 15:41:36 -0800 | [diff] [blame] | 83 | # 2018-06-19 PH added checks for stdint.h and inttypes.h |
| 84 | # 2018-06-27 PH added Daniel's patch to increase the stack for MSVC |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 85 | |
| 86 | PROJECT(PCRE2 C) |
| 87 | |
| 88 | # Increased minimum to 2.8.0 to support newer add_test features. Set policy |
| 89 | # CMP0026 to avoid warnings for the use of LOCATION in GET_TARGET_PROPERTY. |
| 90 | |
| 91 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0) |
| 92 | CMAKE_POLICY(SET CMP0026 OLD) |
| 93 | |
| 94 | SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # for FindReadline.cmake |
| 95 | |
| 96 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${PROJECT_SOURCE_DIR}/src") |
| 97 | |
| 98 | # external packages |
| 99 | FIND_PACKAGE( BZip2 ) |
| 100 | FIND_PACKAGE( ZLIB ) |
| 101 | FIND_PACKAGE( Readline ) |
| 102 | FIND_PACKAGE( Editline ) |
| 103 | |
| 104 | # Configuration checks |
| 105 | |
| 106 | INCLUDE(CheckIncludeFile) |
| 107 | INCLUDE(CheckFunctionExists) |
| 108 | INCLUDE(CheckTypeSize) |
| 109 | |
| 110 | CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H) |
| 111 | CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H) |
| 112 | CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H) |
| 113 | CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H) |
| 114 | CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H) |
| 115 | CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) |
| 116 | CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H) |
| 117 | |
Elliott Hughes | 653c210 | 2019-01-09 15:41:36 -0800 | [diff] [blame] | 118 | IF(HAVE_INTTYPES_H) |
| 119 | SET(PCRE2_HAVE_INTTYPES_H 1) |
| 120 | ELSE(HAVE_INTTYPES_H) |
| 121 | SET(PCRE2_HAVE_INTTYPES_H 0) |
| 122 | ENDIF(HAVE_INTTYPES_H) |
| 123 | |
| 124 | IF(HAVE_STDINT_H) |
| 125 | SET(PCRE2_HAVE_STDINT_H 1) |
| 126 | ELSE(HAVE_STDINT_H) |
| 127 | SET(PCRE2_HAVE_STDINT_H 0) |
| 128 | ENDIF(HAVE_STDINT_H) |
| 129 | |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 130 | CHECK_FUNCTION_EXISTS(bcopy HAVE_BCOPY) |
| 131 | CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE) |
| 132 | CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR) |
| 133 | |
| 134 | # User-configurable options |
| 135 | # |
| 136 | # Note: CMakeSetup displays these in alphabetical order, regardless of |
| 137 | # the order we use here. |
| 138 | |
| 139 | SET(BUILD_SHARED_LIBS OFF CACHE BOOL |
| 140 | "Build shared libraries instead of static ones.") |
| 141 | |
| 142 | OPTION(PCRE2_BUILD_PCRE2_8 "Build 8 bit PCRE2 library" ON) |
| 143 | |
| 144 | OPTION(PCRE2_BUILD_PCRE2_16 "Build 16 bit PCRE2 library" OFF) |
| 145 | |
| 146 | OPTION(PCRE2_BUILD_PCRE2_32 "Build 32 bit PCRE2 library" OFF) |
| 147 | |
| 148 | OPTION(PCRE2_DEBUG "Include debugging code" OFF) |
| 149 | |
| 150 | SET(PCRE2_EBCDIC OFF CACHE BOOL |
| 151 | "Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems.)") |
| 152 | |
| 153 | SET(PCRE2_EBCDIC_NL25 OFF CACHE BOOL |
| 154 | "Use 0x25 as EBCDIC NL character instead of 0x15; implies EBCDIC.") |
| 155 | |
| 156 | SET(PCRE2_LINK_SIZE "2" CACHE STRING |
| 157 | "Internal link size (2, 3 or 4 allowed). See LINK_SIZE in config.h.in for details.") |
| 158 | |
| 159 | SET(PCRE2_PARENS_NEST_LIMIT "250" CACHE STRING |
| 160 | "Default nested parentheses limit. See PARENS_NEST_LIMIT in config.h.in for details.") |
| 161 | |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 162 | SET(PCRE2_HEAP_LIMIT "20000000" CACHE STRING |
Elliott Hughes | 653c210 | 2019-01-09 15:41:36 -0800 | [diff] [blame] | 163 | "Default limit on heap memory (kibibytes). See HEAP_LIMIT in config.h.in for details.") |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 164 | |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 165 | SET(PCRE2_MATCH_LIMIT "10000000" CACHE STRING |
| 166 | "Default limit on internal looping. See MATCH_LIMIT in config.h.in for details.") |
| 167 | |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 168 | SET(PCRE2_MATCH_LIMIT_DEPTH "MATCH_LIMIT" CACHE STRING |
| 169 | "Default limit on internal depth of search. See MATCH_LIMIT_DEPTH in config.h.in for details.") |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 170 | |
| 171 | SET(PCRE2GREP_BUFSIZE "20480" CACHE STRING |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 172 | "Buffer starting size parameter for pcre2grep. See PCRE2GREP_BUFSIZE in config.h.in for details.") |
| 173 | |
| 174 | SET(PCRE2GREP_MAX_BUFSIZE "1048576" CACHE STRING |
| 175 | "Buffer maximum size parameter for pcre2grep. See PCRE2GREP_MAX_BUFSIZE in config.h.in for details.") |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 176 | |
| 177 | SET(PCRE2_NEWLINE "LF" CACHE STRING |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 178 | "What to recognize as a newline (one of CR, LF, CRLF, ANY, ANYCRLF, NUL).") |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 179 | |
| 180 | SET(PCRE2_HEAP_MATCH_RECURSE OFF CACHE BOOL |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 181 | "Obsolete option: do not use") |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 182 | |
| 183 | SET(PCRE2_SUPPORT_JIT OFF CACHE BOOL |
| 184 | "Enable support for Just-in-time compiling.") |
| 185 | |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 186 | SET(PCRE2_SUPPORT_JIT_SEALLOC OFF CACHE BOOL |
| 187 | "Enable SELinux compatible execmem allocator in JIT.") |
| 188 | |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 189 | SET(PCRE2_SUPPORT_PCRE2GREP_JIT ON CACHE BOOL |
| 190 | "Enable use of Just-in-time compiling in pcre2grep.") |
| 191 | |
Janis Danisevskis | 8b979b2 | 2016-08-15 16:09:16 +0100 | [diff] [blame] | 192 | SET(PCRE2_SUPPORT_PCRE2GREP_CALLOUT ON CACHE BOOL |
| 193 | "Enable callout string support in pcre2grep.") |
| 194 | |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 195 | SET(PCRE2_SUPPORT_UNICODE ON CACHE BOOL |
| 196 | "Enable support for Unicode and UTF-8/UTF-16/UTF-32 encoding.") |
| 197 | |
| 198 | SET(PCRE2_SUPPORT_BSR_ANYCRLF OFF CACHE BOOL |
| 199 | "ON=Backslash-R matches only LF CR and CRLF, OFF=Backslash-R matches all Unicode Linebreaks") |
| 200 | |
| 201 | SET(PCRE2_NEVER_BACKSLASH_C OFF CACHE BOOL |
| 202 | "If ON, backslash-C (upper case C) is locked out.") |
| 203 | |
| 204 | SET(PCRE2_SUPPORT_VALGRIND OFF CACHE BOOL |
| 205 | "Enable Valgrind support.") |
| 206 | |
| 207 | OPTION(PCRE2_SHOW_REPORT "Show the final configuration report" ON) |
| 208 | OPTION(PCRE2_BUILD_PCRE2GREP "Build pcre2grep" ON) |
| 209 | OPTION(PCRE2_BUILD_TESTS "Build the tests" ON) |
| 210 | |
| 211 | IF (MINGW) |
| 212 | OPTION(NON_STANDARD_LIB_PREFIX |
| 213 | "ON=Shared libraries built in mingw will be named pcre2.dll, etc., instead of libpcre2.dll, etc." |
| 214 | OFF) |
| 215 | |
| 216 | OPTION(NON_STANDARD_LIB_SUFFIX |
| 217 | "ON=Shared libraries built in mingw will be named libpcre2-0.dll, etc., instead of libpcre2.dll, etc." |
| 218 | OFF) |
| 219 | ENDIF(MINGW) |
| 220 | |
| 221 | IF(MSVC) |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 222 | OPTION(PCRE2_STATIC_RUNTIME |
Janis Danisevskis | 8b979b2 | 2016-08-15 16:09:16 +0100 | [diff] [blame] | 223 | "ON=Compile against the static runtime (/MT)." |
| 224 | OFF) |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 225 | OPTION(INSTALL_MSVC_PDB |
| 226 | "ON=Install .pdb files built by MSVC, if generated" |
| 227 | OFF) |
| 228 | ENDIF(MSVC) |
| 229 | |
| 230 | # bzip2 lib |
| 231 | IF(BZIP2_FOUND) |
| 232 | OPTION (PCRE2_SUPPORT_LIBBZ2 "Enable support for linking pcre2grep with libbz2." ON) |
| 233 | ENDIF(BZIP2_FOUND) |
| 234 | IF(PCRE2_SUPPORT_LIBBZ2) |
| 235 | INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR}) |
| 236 | ENDIF(PCRE2_SUPPORT_LIBBZ2) |
| 237 | |
| 238 | # zlib |
| 239 | IF(ZLIB_FOUND) |
| 240 | OPTION (PCRE2_SUPPORT_LIBZ "Enable support for linking pcre2grep with libz." ON) |
| 241 | ENDIF(ZLIB_FOUND) |
| 242 | IF(PCRE2_SUPPORT_LIBZ) |
| 243 | INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR}) |
| 244 | ENDIF(PCRE2_SUPPORT_LIBZ) |
| 245 | |
| 246 | # editline lib |
| 247 | IF(EDITLINE_FOUND) |
| 248 | OPTION (PCRE2_SUPPORT_LIBEDIT "Enable support for linking pcre2test with libedit." OFF) |
| 249 | ENDIF(EDITLINE_FOUND) |
| 250 | IF(PCRE2_SUPPORT_LIBEDIT) |
| 251 | INCLUDE_DIRECTORIES(${EDITLINE_INCLUDE_DIR}) |
| 252 | ENDIF(PCRE2_SUPPORT_LIBEDIT) |
| 253 | |
| 254 | # readline lib |
| 255 | IF(READLINE_FOUND) |
| 256 | OPTION (PCRE2_SUPPORT_LIBREADLINE "Enable support for linking pcre2test with libreadline." ON) |
| 257 | ENDIF(READLINE_FOUND) |
| 258 | IF(PCRE2_SUPPORT_LIBREADLINE) |
| 259 | INCLUDE_DIRECTORIES(${READLINE_INCLUDE_DIR}) |
| 260 | ENDIF(PCRE2_SUPPORT_LIBREADLINE) |
| 261 | |
| 262 | # Prepare build configuration |
| 263 | |
| 264 | IF(NOT BUILD_SHARED_LIBS) |
| 265 | SET(PCRE2_STATIC 1) |
| 266 | ENDIF(NOT BUILD_SHARED_LIBS) |
| 267 | |
| 268 | IF(NOT PCRE2_BUILD_PCRE2_8 AND NOT PCRE2_BUILD_PCRE2_16 AND NOT PCRE2_BUILD_PCRE2_32) |
| 269 | MESSAGE(FATAL_ERROR "At least one of PCRE2_BUILD_PCRE2_8, PCRE2_BUILD_PCRE2_16 or PCRE2_BUILD_PCRE2_32 must be enabled") |
| 270 | ENDIF(NOT PCRE2_BUILD_PCRE2_8 AND NOT PCRE2_BUILD_PCRE2_16 AND NOT PCRE2_BUILD_PCRE2_32) |
| 271 | |
| 272 | IF(PCRE2_BUILD_PCRE2_8) |
| 273 | SET(SUPPORT_PCRE2_8 1) |
| 274 | ENDIF(PCRE2_BUILD_PCRE2_8) |
| 275 | |
| 276 | IF(PCRE2_BUILD_PCRE2_16) |
| 277 | SET(SUPPORT_PCRE2_16 1) |
| 278 | ENDIF(PCRE2_BUILD_PCRE2_16) |
| 279 | |
| 280 | IF(PCRE2_BUILD_PCRE2_32) |
| 281 | SET(SUPPORT_PCRE2_32 1) |
| 282 | ENDIF(PCRE2_BUILD_PCRE2_32) |
| 283 | |
| 284 | IF(PCRE2_BUILD_PCRE2GREP AND NOT PCRE2_BUILD_PCRE2_8) |
| 285 | MESSAGE(STATUS "** PCRE2_BUILD_PCRE2_8 must be enabled for the pcre2grep program") |
| 286 | SET(PCRE2_BUILD_PCRE2GREP OFF) |
| 287 | ENDIF(PCRE2_BUILD_PCRE2GREP AND NOT PCRE2_BUILD_PCRE2_8) |
| 288 | |
| 289 | IF(PCRE2_SUPPORT_LIBREADLINE AND PCRE2_SUPPORT_LIBEDIT) |
| 290 | MESSAGE(FATAL_ERROR "Only one of libreadline or libeditline can be specified") |
| 291 | ENDIF(PCRE2_SUPPORT_LIBREADLINE AND PCRE2_SUPPORT_LIBEDIT) |
| 292 | |
| 293 | IF(PCRE2_SUPPORT_BSR_ANYCRLF) |
| 294 | SET(BSR_ANYCRLF 1) |
| 295 | ENDIF(PCRE2_SUPPORT_BSR_ANYCRLF) |
| 296 | |
| 297 | IF(PCRE2_NEVER_BACKSLASH_C) |
| 298 | SET(NEVER_BACKSLASH_C 1) |
| 299 | ENDIF(PCRE2_NEVER_BACKSLASH_C) |
| 300 | |
| 301 | IF(PCRE2_SUPPORT_UNICODE) |
| 302 | SET(SUPPORT_UNICODE 1) |
| 303 | ENDIF(PCRE2_SUPPORT_UNICODE) |
| 304 | |
| 305 | IF(PCRE2_SUPPORT_JIT) |
| 306 | SET(SUPPORT_JIT 1) |
| 307 | ENDIF(PCRE2_SUPPORT_JIT) |
| 308 | |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 309 | IF(PCRE2_SUPPORT_JIT_SEALLOC) |
| 310 | SET(SLJIT_PROT_EXECUTABLE_ALLOCATOR 1) |
| 311 | ENDIF(PCRE2_SUPPORT_JIT_SEALLOC) |
| 312 | |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 313 | IF(PCRE2_SUPPORT_PCRE2GREP_JIT) |
| 314 | SET(SUPPORT_PCRE2GREP_JIT 1) |
| 315 | ENDIF(PCRE2_SUPPORT_PCRE2GREP_JIT) |
| 316 | |
Janis Danisevskis | 8b979b2 | 2016-08-15 16:09:16 +0100 | [diff] [blame] | 317 | IF(PCRE2_SUPPORT_PCRE2GREP_CALLOUT) |
| 318 | SET(SUPPORT_PCRE2GREP_CALLOUT 1) |
| 319 | ENDIF(PCRE2_SUPPORT_PCRE2GREP_CALLOUT) |
| 320 | |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 321 | IF(PCRE2_SUPPORT_VALGRIND) |
| 322 | SET(SUPPORT_VALGRIND 1) |
| 323 | ENDIF(PCRE2_SUPPORT_VALGRIND) |
| 324 | |
| 325 | # This next one used to reference ${READLINE_LIBRARY}) |
| 326 | # but I was advised to add the NCURSES test as well, along with |
| 327 | # some modifications to cmake/FindReadline.cmake which should |
| 328 | # make it possible to override the default if necessary. PH |
| 329 | |
| 330 | IF(PCRE2_SUPPORT_LIBREADLINE) |
| 331 | SET(SUPPORT_LIBREADLINE 1) |
| 332 | SET(PCRE2TEST_LIBS ${READLINE_LIBRARY} ${NCURSES_LIBRARY}) |
| 333 | ENDIF(PCRE2_SUPPORT_LIBREADLINE) |
| 334 | |
| 335 | # libedit is a plug-compatible alternative to libreadline |
| 336 | |
| 337 | IF(PCRE2_SUPPORT_LIBEDIT) |
| 338 | SET(SUPPORT_LIBEDIT 1) |
| 339 | SET(PCRE2TEST_LIBS ${EDITLINE_LIBRARY} ${NCURSES_LIBRARY}) |
| 340 | ENDIF(PCRE2_SUPPORT_LIBEDIT) |
| 341 | |
| 342 | IF(PCRE2_SUPPORT_LIBZ) |
| 343 | SET(SUPPORT_LIBZ 1) |
| 344 | SET(PCRE2GREP_LIBS ${PCRE2GREP_LIBS} ${ZLIB_LIBRARIES}) |
| 345 | ENDIF(PCRE2_SUPPORT_LIBZ) |
| 346 | |
| 347 | IF(PCRE2_SUPPORT_LIBBZ2) |
| 348 | SET(SUPPORT_LIBBZ2 1) |
| 349 | SET(PCRE2GREP_LIBS ${PCRE2GREP_LIBS} ${BZIP2_LIBRARIES}) |
| 350 | ENDIF(PCRE2_SUPPORT_LIBBZ2) |
| 351 | |
| 352 | SET(NEWLINE_DEFAULT "") |
| 353 | |
| 354 | IF(PCRE2_NEWLINE STREQUAL "CR") |
| 355 | SET(NEWLINE_DEFAULT "1") |
| 356 | ENDIF(PCRE2_NEWLINE STREQUAL "CR") |
| 357 | IF(PCRE2_NEWLINE STREQUAL "LF") |
| 358 | SET(NEWLINE_DEFAULT "2") |
| 359 | ENDIF(PCRE2_NEWLINE STREQUAL "LF") |
| 360 | IF(PCRE2_NEWLINE STREQUAL "CRLF") |
| 361 | SET(NEWLINE_DEFAULT "3") |
| 362 | ENDIF(PCRE2_NEWLINE STREQUAL "CRLF") |
| 363 | IF(PCRE2_NEWLINE STREQUAL "ANY") |
| 364 | SET(NEWLINE_DEFAULT "4") |
| 365 | ENDIF(PCRE2_NEWLINE STREQUAL "ANY") |
| 366 | IF(PCRE2_NEWLINE STREQUAL "ANYCRLF") |
| 367 | SET(NEWLINE_DEFAULT "5") |
| 368 | ENDIF(PCRE2_NEWLINE STREQUAL "ANYCRLF") |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 369 | IF(PCRE2_NEWLINE STREQUAL "NUL") |
| 370 | SET(NEWLINE_DEFAULT "6") |
| 371 | ENDIF(PCRE2_NEWLINE STREQUAL "NUL") |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 372 | |
| 373 | IF(NEWLINE_DEFAULT STREQUAL "") |
| 374 | MESSAGE(FATAL_ERROR "The PCRE2_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".") |
| 375 | ENDIF(NEWLINE_DEFAULT STREQUAL "") |
| 376 | |
| 377 | IF(PCRE2_EBCDIC) |
| 378 | SET(EBCDIC 1) |
| 379 | ENDIF(PCRE2_EBCDIC) |
| 380 | |
| 381 | IF(PCRE2_EBCDIC_NL25) |
| 382 | SET(EBCDIC 1) |
| 383 | SET(EBCDIC_NL25 1) |
| 384 | ENDIF(PCRE2_EBCDIC_NL25) |
| 385 | |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 386 | # Output files |
| 387 | |
| 388 | CONFIGURE_FILE(config-cmake.h.in |
| 389 | ${PROJECT_BINARY_DIR}/config.h |
| 390 | @ONLY) |
| 391 | |
| 392 | # Parse version numbers and date out of configure.ac |
| 393 | |
| 394 | file(STRINGS ${PROJECT_SOURCE_DIR}/configure.ac |
| 395 | configure_lines |
| 396 | LIMIT_COUNT 50 # Read only the first 50 lines of the file |
| 397 | ) |
| 398 | |
| 399 | set(SEARCHED_VARIABLES "pcre2_major" "pcre2_minor" "pcre2_prerelease" "pcre2_date") |
| 400 | foreach(configure_line ${configure_lines}) |
| 401 | foreach(_substitution_variable ${SEARCHED_VARIABLES}) |
| 402 | string(TOUPPER ${_substitution_variable} _substitution_variable_upper) |
| 403 | if (NOT ${_substitution_variable_upper}) |
| 404 | string(REGEX MATCH "m4_define\\(${_substitution_variable}, \\[(.*)\\]" MACTHED_STRING ${configure_line}) |
| 405 | if (CMAKE_MATCH_1) |
| 406 | set(${_substitution_variable_upper} ${CMAKE_MATCH_1}) |
| 407 | endif() |
| 408 | endif() |
| 409 | endforeach() |
| 410 | endforeach() |
| 411 | |
| 412 | CONFIGURE_FILE(src/pcre2.h.in |
| 413 | ${PROJECT_BINARY_DIR}/pcre2.h |
| 414 | @ONLY) |
| 415 | |
| 416 | # What about pcre2-config and libpcre2.pc? |
| 417 | |
| 418 | # Character table generation |
| 419 | |
| 420 | OPTION(PCRE2_REBUILD_CHARTABLES "Rebuild char tables" OFF) |
| 421 | IF(PCRE2_REBUILD_CHARTABLES) |
| 422 | ADD_EXECUTABLE(dftables src/dftables.c) |
| 423 | ADD_CUSTOM_COMMAND( |
| 424 | COMMENT "Generating character tables (pcre2_chartables.c) for current locale" |
| 425 | DEPENDS dftables |
| 426 | COMMAND dftables |
| 427 | ARGS ${PROJECT_BINARY_DIR}/pcre2_chartables.c |
| 428 | OUTPUT ${PROJECT_BINARY_DIR}/pcre2_chartables.c |
| 429 | ) |
| 430 | ELSE(PCRE2_REBUILD_CHARTABLES) |
| 431 | CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/src/pcre2_chartables.c.dist |
| 432 | ${PROJECT_BINARY_DIR}/pcre2_chartables.c |
| 433 | COPYONLY) |
| 434 | ENDIF(PCRE2_REBUILD_CHARTABLES) |
| 435 | |
| 436 | # Source code |
| 437 | |
| 438 | SET(PCRE2_HEADERS ${PROJECT_BINARY_DIR}/pcre2.h) |
| 439 | |
| 440 | SET(PCRE2_SOURCES |
| 441 | src/pcre2_auto_possess.c |
| 442 | ${PROJECT_BINARY_DIR}/pcre2_chartables.c |
| 443 | src/pcre2_compile.c |
| 444 | src/pcre2_config.c |
| 445 | src/pcre2_context.c |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 446 | src/pcre2_convert.c |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 447 | src/pcre2_dfa_match.c |
| 448 | src/pcre2_error.c |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 449 | src/pcre2_extuni.c |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 450 | src/pcre2_find_bracket.c |
| 451 | src/pcre2_jit_compile.c |
| 452 | src/pcre2_maketables.c |
| 453 | src/pcre2_match.c |
| 454 | src/pcre2_match_data.c |
| 455 | src/pcre2_newline.c |
| 456 | src/pcre2_ord2utf.c |
| 457 | src/pcre2_pattern_info.c |
| 458 | src/pcre2_serialize.c |
| 459 | src/pcre2_string_utils.c |
| 460 | src/pcre2_study.c |
| 461 | src/pcre2_substitute.c |
| 462 | src/pcre2_substring.c |
| 463 | src/pcre2_tables.c |
| 464 | src/pcre2_ucd.c |
| 465 | src/pcre2_valid_utf.c |
| 466 | src/pcre2_xclass.c |
| 467 | ) |
| 468 | |
| 469 | SET(PCRE2POSIX_HEADERS src/pcre2posix.h) |
| 470 | SET(PCRE2POSIX_SOURCES src/pcre2posix.c) |
| 471 | |
| 472 | IF(MINGW AND NOT PCRE2_STATIC) |
| 473 | IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2.rc) |
| 474 | ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcre2.o |
| 475 | PRE-LINK |
| 476 | COMMAND windres ARGS pcre2.rc pcre2.o |
| 477 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} |
| 478 | COMMENT Using pcre2 coff info in mingw build) |
| 479 | SET(PCRE2_SOURCES |
| 480 | ${PCRE2_SOURCES} ${PROJECT_SOURCE_DIR}/pcre2.o |
| 481 | ) |
| 482 | ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre2.rc) |
| 483 | IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2posix.rc) |
| 484 | ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcre2posix.o |
| 485 | PRE-LINK |
| 486 | COMMAND windres ARGS pcre2posix.rc pcre2posix.o |
| 487 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} |
| 488 | COMMENT Using pcre2posix coff info in mingw build) |
| 489 | SET(PCRE2POSIX_SOURCES |
| 490 | ${PCRE2POSIX_SOURCES} ${PROJECT_SOURCE_DIR}/pcre2posix.o |
| 491 | ) |
| 492 | ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre2posix.rc) |
| 493 | ENDIF(MINGW AND NOT PCRE2_STATIC) |
| 494 | |
| 495 | IF(MSVC AND NOT PCRE2_STATIC) |
| 496 | IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2.rc) |
| 497 | SET(PCRE2_SOURCES |
| 498 | ${PCRE2_SOURCES} pcre2.rc) |
| 499 | ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre2.rc) |
| 500 | IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2posix.rc) |
| 501 | SET(PCRE2POSIX_SOURCES |
| 502 | ${PCRE2POSIX_SOURCES} pcre2posix.rc) |
| 503 | ENDIF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2posix.rc) |
| 504 | ENDIF(MSVC AND NOT PCRE2_STATIC) |
| 505 | |
Janis Danisevskis | 8b979b2 | 2016-08-15 16:09:16 +0100 | [diff] [blame] | 506 | # Fix static compilation with MSVC: https://bugs.exim.org/show_bug.cgi?id=1681 |
| 507 | # This code was taken from the CMake wiki, not from WebM. |
| 508 | |
| 509 | IF(MSVC AND PCRE2_STATIC_RUNTIME) |
| 510 | MESSAGE(STATUS "** MSVC and PCRE2_STATIC_RUNTIME: modifying compiler flags to use static runtime library") |
| 511 | foreach(flag_var |
| 512 | CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE |
| 513 | CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) |
| 514 | string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") |
| 515 | endforeach() |
| 516 | ENDIF(MSVC AND PCRE2_STATIC_RUNTIME) |
| 517 | |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 518 | # Build setup |
| 519 | |
| 520 | ADD_DEFINITIONS(-DHAVE_CONFIG_H) |
| 521 | |
| 522 | IF(MSVC) |
| 523 | ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS) |
| 524 | ENDIF(MSVC) |
| 525 | |
| 526 | SET(CMAKE_INCLUDE_CURRENT_DIR 1) |
| 527 | # needed to make sure to not link debug libs |
| 528 | # against release libs and vice versa |
| 529 | IF(WIN32) |
| 530 | SET(CMAKE_DEBUG_POSTFIX "d") |
| 531 | ENDIF(WIN32) |
| 532 | |
| 533 | SET(targets) |
| 534 | |
| 535 | # 8-bit library |
| 536 | |
| 537 | IF(PCRE2_BUILD_PCRE2_8) |
| 538 | ADD_LIBRARY(pcre2-8 ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h) |
| 539 | SET_PROPERTY(TARGET pcre2-8 |
| 540 | PROPERTY COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8) |
| 541 | SET(targets ${targets} pcre2-8) |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 542 | ADD_LIBRARY(pcre2-posix ${PCRE2POSIX_HEADERS} ${PCRE2POSIX_SOURCES}) |
| 543 | SET_PROPERTY(TARGET pcre2-posix |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 544 | PROPERTY COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8) |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 545 | SET(targets ${targets} pcre2-posix) |
| 546 | TARGET_LINK_LIBRARIES(pcre2-posix pcre2-8) |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 547 | |
| 548 | IF(MINGW AND NOT PCRE2_STATIC) |
| 549 | IF(NON_STANDARD_LIB_PREFIX) |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 550 | SET_TARGET_PROPERTIES(pcre2-8 pcre2-posix PROPERTIES PREFIX "") |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 551 | ENDIF(NON_STANDARD_LIB_PREFIX) |
| 552 | IF(NON_STANDARD_LIB_SUFFIX) |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 553 | SET_TARGET_PROPERTIES(pcre2-8 pcre2-posix PROPERTIES SUFFIX "-0.dll") |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 554 | ENDIF(NON_STANDARD_LIB_SUFFIX) |
| 555 | ENDIF(MINGW AND NOT PCRE2_STATIC) |
| 556 | ENDIF(PCRE2_BUILD_PCRE2_8) |
| 557 | |
| 558 | # 16-bit library |
| 559 | |
| 560 | IF(PCRE2_BUILD_PCRE2_16) |
| 561 | ADD_LIBRARY(pcre2-16 ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h) |
| 562 | SET_PROPERTY(TARGET pcre2-16 |
| 563 | PROPERTY COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=16) |
| 564 | SET(targets ${targets} pcre2-16) |
| 565 | |
| 566 | IF(MINGW AND NOT PCRE2_STATIC) |
| 567 | IF(NON_STANDARD_LIB_PREFIX) |
| 568 | SET_TARGET_PROPERTIES(pcre2-16 PROPERTIES PREFIX "") |
| 569 | ENDIF(NON_STANDARD_LIB_PREFIX) |
| 570 | IF(NON_STANDARD_LIB_SUFFIX) |
| 571 | SET_TARGET_PROPERTIES(pcre2-16 PROPERTIES SUFFIX "-0.dll") |
| 572 | ENDIF(NON_STANDARD_LIB_SUFFIX) |
| 573 | ENDIF(MINGW AND NOT PCRE2_STATIC) |
| 574 | ENDIF(PCRE2_BUILD_PCRE2_16) |
| 575 | |
| 576 | # 32-bit library |
| 577 | |
| 578 | IF(PCRE2_BUILD_PCRE2_32) |
| 579 | ADD_LIBRARY(pcre2-32 ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h) |
| 580 | SET_PROPERTY(TARGET pcre2-32 |
| 581 | PROPERTY COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=32) |
| 582 | SET(targets ${targets} pcre2-32) |
| 583 | |
| 584 | IF(MINGW AND NOT PCRE2_STATIC) |
| 585 | IF(NON_STANDARD_LIB_PREFIX) |
| 586 | SET_TARGET_PROPERTIES(pcre2-32 PROPERTIES PREFIX "") |
| 587 | ENDIF(NON_STANDARD_LIB_PREFIX) |
| 588 | IF(NON_STANDARD_LIB_SUFFIX) |
| 589 | SET_TARGET_PROPERTIES(pcre2-32 PROPERTIES SUFFIX "-0.dll") |
| 590 | ENDIF(NON_STANDARD_LIB_SUFFIX) |
| 591 | ENDIF(MINGW AND NOT PCRE2_STATIC) |
| 592 | ENDIF(PCRE2_BUILD_PCRE2_32) |
| 593 | |
| 594 | # Executables |
| 595 | |
| 596 | IF(PCRE2_BUILD_PCRE2GREP) |
| 597 | ADD_EXECUTABLE(pcre2grep src/pcre2grep.c) |
| 598 | SET_PROPERTY(TARGET pcre2grep |
| 599 | PROPERTY COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8) |
| 600 | SET(targets ${targets} pcre2grep) |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 601 | TARGET_LINK_LIBRARIES(pcre2grep pcre2-posix ${PCRE2GREP_LIBS}) |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 602 | ENDIF(PCRE2_BUILD_PCRE2GREP) |
| 603 | |
| 604 | # Testing |
| 605 | |
| 606 | IF(PCRE2_BUILD_TESTS) |
| 607 | ENABLE_TESTING() |
| 608 | |
| 609 | SET(PCRE2TEST_SOURCES src/pcre2test.c) |
| 610 | |
Elliott Hughes | 653c210 | 2019-01-09 15:41:36 -0800 | [diff] [blame] | 611 | IF(MSVC) |
| 612 | # This is needed to avoid a stack overflow error in the standard tests. The |
| 613 | # flag should be indicated with a forward-slash instead of a hyphen, but |
| 614 | # then CMake treats it as a file path. |
| 615 | SET(PCRE2TEST_LINKER_FLAGS -STACK:2500000) |
| 616 | ENDIF(MSVC) |
| 617 | |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 618 | ADD_EXECUTABLE(pcre2test ${PCRE2TEST_SOURCES}) |
| 619 | SET(targets ${targets} pcre2test) |
| 620 | IF(PCRE2_BUILD_PCRE2_8) |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 621 | LIST(APPEND PCRE2TEST_LIBS pcre2-posix pcre2-8) |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 622 | ENDIF(PCRE2_BUILD_PCRE2_8) |
| 623 | IF(PCRE2_BUILD_PCRE2_16) |
| 624 | LIST(APPEND PCRE2TEST_LIBS pcre2-16) |
| 625 | ENDIF(PCRE2_BUILD_PCRE2_16) |
| 626 | IF(PCRE2_BUILD_PCRE2_32) |
| 627 | LIST(APPEND PCRE2TEST_LIBS pcre2-32) |
| 628 | ENDIF(PCRE2_BUILD_PCRE2_32) |
Elliott Hughes | 653c210 | 2019-01-09 15:41:36 -0800 | [diff] [blame] | 629 | TARGET_LINK_LIBRARIES(pcre2test ${PCRE2TEST_LIBS} ${PCRE2TEST_LINKER_FLAGS}) |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 630 | |
| 631 | IF(PCRE2_SUPPORT_JIT) |
| 632 | ADD_EXECUTABLE(pcre2_jit_test src/pcre2_jit_test.c) |
| 633 | SET(targets ${targets} pcre2_jit_test) |
| 634 | SET(PCRE2_JIT_TEST_LIBS ) |
| 635 | IF(PCRE2_BUILD_PCRE2_8) |
| 636 | LIST(APPEND PCRE2_JIT_TEST_LIBS pcre2-8) |
| 637 | ENDIF(PCRE2_BUILD_PCRE2_8) |
| 638 | IF(PCRE2_BUILD_PCRE2_16) |
| 639 | LIST(APPEND PCRE2_JIT_TEST_LIBS pcre2-16) |
| 640 | ENDIF(PCRE2_BUILD_PCRE2_16) |
| 641 | IF(PCRE2_BUILD_PCRE2_32) |
| 642 | LIST(APPEND PCRE2_JIT_TEST_LIBS pcre2-32) |
| 643 | ENDIF(PCRE2_BUILD_PCRE2_32) |
| 644 | TARGET_LINK_LIBRARIES(pcre2_jit_test ${PCRE2_JIT_TEST_LIBS}) |
| 645 | ENDIF(PCRE2_SUPPORT_JIT) |
| 646 | |
| 647 | # exes in Debug location tested by the RunTest shell script |
| 648 | # via "make test" |
| 649 | |
| 650 | IF(PCRE2_BUILD_PCRE2GREP) |
| 651 | GET_TARGET_PROPERTY(PCRE2GREP_EXE pcre2grep DEBUG_LOCATION) |
| 652 | ENDIF(PCRE2_BUILD_PCRE2GREP) |
| 653 | |
| 654 | GET_TARGET_PROPERTY(PCRE2TEST_EXE pcre2test DEBUG_LOCATION) |
| 655 | |
| 656 | # ================================================= |
| 657 | # Write out a CTest configuration file |
| 658 | # |
| 659 | FILE(WRITE ${PROJECT_BINARY_DIR}/CTestCustom.ctest |
| 660 | "# This is a generated file. |
| 661 | MESSAGE(\"When testing is complete, review test output in the |
| 662 | \\\"${PROJECT_BINARY_DIR}/Testing/Temporary\\\" folder.\") |
| 663 | MESSAGE(\" \") |
| 664 | ") |
| 665 | |
| 666 | FILE(WRITE ${PROJECT_BINARY_DIR}/pcre2_test.sh |
| 667 | "#! /bin/sh |
| 668 | # This is a generated file. |
| 669 | . ${PROJECT_SOURCE_DIR}/RunTest |
| 670 | if test \"$?\" != \"0\"; then exit 1; fi |
| 671 | # End |
| 672 | ") |
| 673 | |
| 674 | IF(UNIX) |
| 675 | ADD_TEST(pcre2_test sh ${PROJECT_BINARY_DIR}/pcre2_test.sh) |
| 676 | ENDIF(UNIX) |
| 677 | |
| 678 | IF(PCRE2_BUILD_PCRE2GREP) |
| 679 | FILE(WRITE ${PROJECT_BINARY_DIR}/pcre2_grep_test.sh |
| 680 | "#! /bin/sh |
| 681 | # This is a generated file. |
| 682 | . ${PROJECT_SOURCE_DIR}/RunGrepTest |
| 683 | if test \"$?\" != \"0\"; then exit 1; fi |
| 684 | # End |
| 685 | ") |
| 686 | |
| 687 | IF(UNIX) |
| 688 | ADD_TEST(pcre2_grep_test sh ${PROJECT_BINARY_DIR}/pcre2_grep_test.sh) |
| 689 | ENDIF(UNIX) |
| 690 | ENDIF(PCRE2_BUILD_PCRE2GREP) |
| 691 | |
| 692 | IF(WIN32) |
| 693 | # Provide environment for executing the bat file version of RunTest |
| 694 | FILE(TO_NATIVE_PATH ${PROJECT_SOURCE_DIR} winsrc) |
| 695 | FILE(TO_NATIVE_PATH ${PROJECT_BINARY_DIR} winbin) |
| 696 | FILE(TO_NATIVE_PATH ${PCRE2TEST_EXE} winexe) |
| 697 | |
| 698 | FILE(WRITE ${PROJECT_BINARY_DIR}/pcre2_test.bat |
| 699 | "\@REM This is a generated file. |
| 700 | \@echo off |
| 701 | setlocal |
| 702 | SET srcdir=\"${winsrc}\" |
| 703 | SET pcre2test=\"${winexe}\" |
| 704 | if not [%CMAKE_CONFIG_TYPE%]==[] SET pcre2test=\"${winbin}\\%CMAKE_CONFIG_TYPE%\\pcre2test.exe\" |
| 705 | call %srcdir%\\RunTest.Bat |
| 706 | if errorlevel 1 exit /b 1 |
| 707 | echo RunTest.bat tests successfully completed |
| 708 | ") |
| 709 | |
| 710 | ADD_TEST(NAME pcre2_test_bat |
| 711 | COMMAND pcre2_test.bat) |
| 712 | SET_TESTS_PROPERTIES(pcre2_test_bat PROPERTIES |
| 713 | PASS_REGULAR_EXPRESSION "RunTest\\.bat tests successfully completed") |
| 714 | |
| 715 | IF("$ENV{OSTYPE}" STREQUAL "msys") |
| 716 | # Both the sh and bat file versions of RunTest are run if make test is used |
| 717 | # in msys |
| 718 | ADD_TEST(pcre2_test_sh sh.exe ${PROJECT_BINARY_DIR}/pcre2_test.sh) |
| 719 | IF(PCRE2_BUILD_PCRE2GREP) |
| 720 | ADD_TEST(pcre2_grep_test sh.exe ${PROJECT_BINARY_DIR}/pcre2_grep_test.sh) |
| 721 | ENDIF(PCRE2_BUILD_PCRE2GREP) |
| 722 | ENDIF("$ENV{OSTYPE}" STREQUAL "msys") |
| 723 | ENDIF(WIN32) |
| 724 | |
| 725 | # Changed to accommodate testing whichever location was just built |
| 726 | |
| 727 | IF(PCRE2_SUPPORT_JIT) |
| 728 | ADD_TEST(pcre2_jit_test pcre2_jit_test) |
| 729 | ENDIF(PCRE2_SUPPORT_JIT) |
| 730 | |
| 731 | ENDIF(PCRE2_BUILD_TESTS) |
| 732 | |
| 733 | # Installation |
| 734 | |
| 735 | SET(CMAKE_INSTALL_ALWAYS 1) |
| 736 | |
| 737 | INSTALL(TARGETS ${targets} |
| 738 | RUNTIME DESTINATION bin |
| 739 | LIBRARY DESTINATION lib |
| 740 | ARCHIVE DESTINATION lib) |
| 741 | |
| 742 | INSTALL(FILES ${PCRE2_HEADERS} ${PCRE2POSIX_HEADERS} DESTINATION include) |
| 743 | |
| 744 | FILE(GLOB html ${PROJECT_SOURCE_DIR}/doc/html/*.html) |
| 745 | FILE(GLOB man1 ${PROJECT_SOURCE_DIR}/doc/*.1) |
| 746 | FILE(GLOB man3 ${PROJECT_SOURCE_DIR}/doc/*.3) |
| 747 | |
| 748 | FOREACH(man ${man3}) |
| 749 | GET_FILENAME_COMPONENT(man_tmp ${man} NAME) |
| 750 | SET(man3_new ${man3} ${man}) |
| 751 | ENDFOREACH(man ${man3}) |
| 752 | SET(man3 ${man3_new}) |
| 753 | |
| 754 | INSTALL(FILES ${man1} DESTINATION man/man1) |
| 755 | INSTALL(FILES ${man3} DESTINATION man/man3) |
| 756 | INSTALL(FILES ${html} DESTINATION share/doc/pcre2/html) |
| 757 | |
| 758 | IF(MSVC AND INSTALL_MSVC_PDB) |
| 759 | INSTALL(FILES ${PROJECT_BINARY_DIR}/pcre2.pdb |
| 760 | ${PROJECT_BINARY_DIR}/pcre2posix.pdb |
| 761 | DESTINATION bin |
| 762 | CONFIGURATIONS RelWithDebInfo) |
| 763 | INSTALL(FILES ${PROJECT_BINARY_DIR}/pcre2d.pdb |
| 764 | ${PROJECT_BINARY_DIR}/pcre2posixd.pdb |
| 765 | DESTINATION bin |
| 766 | CONFIGURATIONS Debug) |
| 767 | ENDIF(MSVC AND INSTALL_MSVC_PDB) |
| 768 | |
| 769 | # Help, only for nice output |
| 770 | IF(BUILD_SHARED_LIBS) |
| 771 | SET(BUILD_STATIC_LIBS OFF) |
| 772 | ELSE(BUILD_SHARED_LIBS) |
| 773 | SET(BUILD_STATIC_LIBS ON) |
| 774 | ENDIF(BUILD_SHARED_LIBS) |
| 775 | |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 776 | IF(PCRE2_HEAP_MATCH_RECURSE) |
| 777 | MESSAGE(WARNING "HEAP_MATCH_RECURSE is obsolete and does nothing.") |
| 778 | ENDIF(PCRE2_HEAP_MATCH_RECURSE) |
| 779 | |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 780 | IF(PCRE2_SHOW_REPORT) |
| 781 | STRING(TOUPPER "${CMAKE_BUILD_TYPE}" buildtype) |
| 782 | IF (CMAKE_C_FLAGS) |
| 783 | SET(cfsp " ") |
| 784 | ENDIF(CMAKE_C_FLAGS) |
| 785 | MESSAGE(STATUS "") |
| 786 | MESSAGE(STATUS "") |
| 787 | MESSAGE(STATUS "PCRE2 configuration summary:") |
| 788 | MESSAGE(STATUS "") |
| 789 | MESSAGE(STATUS " Install prefix .................. : ${CMAKE_INSTALL_PREFIX}") |
| 790 | MESSAGE(STATUS " C compiler ...................... : ${CMAKE_C_COMPILER}") |
| 791 | MESSAGE(STATUS " C compiler flags ................ : ${CMAKE_C_FLAGS}${cfsp}${CMAKE_C_FLAGS_${buildtype}}") |
| 792 | MESSAGE(STATUS "") |
| 793 | MESSAGE(STATUS " Build 8 bit PCRE2 library ....... : ${PCRE2_BUILD_PCRE2_8}") |
| 794 | MESSAGE(STATUS " Build 16 bit PCRE2 library ...... : ${PCRE2_BUILD_PCRE2_16}") |
| 795 | MESSAGE(STATUS " Build 32 bit PCRE2 library ...... : ${PCRE2_BUILD_PCRE2_32}") |
| 796 | MESSAGE(STATUS " Enable JIT compiling support .... : ${PCRE2_SUPPORT_JIT}") |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 797 | MESSAGE(STATUS " Use SELinux allocator in JIT .... : ${PCRE2_SUPPORT_JIT_SEALLOC}") |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 798 | MESSAGE(STATUS " Enable Unicode support .......... : ${PCRE2_SUPPORT_UNICODE}") |
| 799 | MESSAGE(STATUS " Newline char/sequence ........... : ${PCRE2_NEWLINE}") |
| 800 | MESSAGE(STATUS " \\R matches only ANYCRLF ......... : ${PCRE2_SUPPORT_BSR_ANYCRLF}") |
| 801 | MESSAGE(STATUS " \\C is disabled .................. : ${PCRE2_NEVER_BACKSLASH_C}") |
| 802 | MESSAGE(STATUS " EBCDIC coding ................... : ${PCRE2_EBCDIC}") |
| 803 | MESSAGE(STATUS " EBCDIC coding with NL=0x25 ...... : ${PCRE2_EBCDIC_NL25}") |
| 804 | MESSAGE(STATUS " Rebuild char tables ............. : ${PCRE2_REBUILD_CHARTABLES}") |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 805 | MESSAGE(STATUS " Internal link size .............. : ${PCRE2_LINK_SIZE}") |
| 806 | MESSAGE(STATUS " Parentheses nest limit .......... : ${PCRE2_PARENS_NEST_LIMIT}") |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 807 | MESSAGE(STATUS " Heap limit ...................... : ${PCRE2_HEAP_LIMIT}") |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 808 | MESSAGE(STATUS " Match limit ..................... : ${PCRE2_MATCH_LIMIT}") |
Elliott Hughes | 9bc971b | 2018-07-27 13:23:14 -0700 | [diff] [blame] | 809 | MESSAGE(STATUS " Match depth limit ............... : ${PCRE2_MATCH_LIMIT_DEPTH}") |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 810 | MESSAGE(STATUS " Build shared libs ............... : ${BUILD_SHARED_LIBS}") |
| 811 | MESSAGE(STATUS " Build static libs ............... : ${BUILD_STATIC_LIBS}") |
| 812 | MESSAGE(STATUS " Build pcre2grep ................. : ${PCRE2_BUILD_PCRE2GREP}") |
| 813 | MESSAGE(STATUS " Enable JIT in pcre2grep ......... : ${PCRE2_SUPPORT_PCRE2GREP_JIT}") |
Janis Danisevskis | 8b979b2 | 2016-08-15 16:09:16 +0100 | [diff] [blame] | 814 | MESSAGE(STATUS " Enable callouts in pcre2grep .... : ${PCRE2_SUPPORT_PCRE2GREP_CALLOUT}") |
Janis Danisevskis | 53e448c | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 815 | MESSAGE(STATUS " Buffer size for pcre2grep ....... : ${PCRE2GREP_BUFSIZE}") |
| 816 | MESSAGE(STATUS " Build tests (implies pcre2test . : ${PCRE2_BUILD_TESTS}") |
| 817 | MESSAGE(STATUS " and pcre2grep)") |
| 818 | IF(ZLIB_FOUND) |
| 819 | MESSAGE(STATUS " Link pcre2grep with libz ........ : ${PCRE2_SUPPORT_LIBZ}") |
| 820 | ELSE(ZLIB_FOUND) |
| 821 | MESSAGE(STATUS " Link pcre2grep with libz ........ : Library not found" ) |
| 822 | ENDIF(ZLIB_FOUND) |
| 823 | IF(BZIP2_FOUND) |
| 824 | MESSAGE(STATUS " Link pcre2grep with libbz2 ...... : ${PCRE2_SUPPORT_LIBBZ2}") |
| 825 | ELSE(BZIP2_FOUND) |
| 826 | MESSAGE(STATUS " Link pcre2grep with libbz2 ...... : Library not found" ) |
| 827 | ENDIF(BZIP2_FOUND) |
| 828 | IF(EDITLINE_FOUND) |
| 829 | MESSAGE(STATUS " Link pcre2test with libeditline . : ${PCRE2_SUPPORT_LIBEDIT}") |
| 830 | ELSE(EDITLINE_FOUND) |
| 831 | MESSAGE(STATUS " Link pcre2test with libeditline . : Library not found" ) |
| 832 | ENDIF(EDITLINE_FOUND) |
| 833 | IF(READLINE_FOUND) |
| 834 | MESSAGE(STATUS " Link pcre2test with libreadline . : ${PCRE2_SUPPORT_LIBREADLINE}") |
| 835 | ELSE(READLINE_FOUND) |
| 836 | MESSAGE(STATUS " Link pcre2test with libreadline . : Library not found" ) |
| 837 | ENDIF(READLINE_FOUND) |
| 838 | MESSAGE(STATUS " Support Valgrind .................: ${PCRE2_SUPPORT_VALGRIND}") |
| 839 | |
| 840 | IF(MINGW AND NOT PCRE2_STATIC) |
| 841 | MESSAGE(STATUS " Non-standard dll names (prefix) . : ${NON_STANDARD_LIB_PREFIX}") |
| 842 | MESSAGE(STATUS " Non-standard dll names (suffix) . : ${NON_STANDARD_LIB_SUFFIX}") |
| 843 | ENDIF(MINGW AND NOT PCRE2_STATIC) |
| 844 | |
| 845 | IF(MSVC) |
| 846 | MESSAGE(STATUS " Install MSVC .pdb files ..........: ${INSTALL_MSVC_PDB}") |
| 847 | ENDIF(MSVC) |
| 848 | |
| 849 | MESSAGE(STATUS "") |
| 850 | ENDIF(PCRE2_SHOW_REPORT) |
| 851 | |
| 852 | # end CMakeLists.txt |