tpy-lang 0.3.0.dev0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (333) hide show
  1. tpy_lang-0.3.0.dev0.dist-info/METADATA +151 -0
  2. tpy_lang-0.3.0.dev0.dist-info/RECORD +333 -0
  3. tpy_lang-0.3.0.dev0.dist-info/WHEEL +4 -0
  4. tpy_lang-0.3.0.dev0.dist-info/entry_points.txt +3 -0
  5. tpyc/__init__.py +104 -0
  6. tpyc/__main__.py +6 -0
  7. tpyc/_buildinfo.py +1 -0
  8. tpyc/_data/docs/LANGUAGE_FEATURES.md +6278 -0
  9. tpyc/_data/docs/STDLIB_ROADMAP.md +1258 -0
  10. tpyc/_data/docs/TPY_FOR_AGENTS.md +556 -0
  11. tpyc/_data/lib/tpy/_bindings/__init__.py +6 -0
  12. tpyc/_data/lib/tpy/_bindings/pcre2.py +173 -0
  13. tpyc/_data/lib/tpy/_bindings/posix_socket.py +161 -0
  14. tpyc/_data/lib/tpy/_functools_macros.py +80 -0
  15. tpyc/_data/lib/tpy/_macro_helpers.py +161 -0
  16. tpyc/_data/lib/tpy/argparse.py +2062 -0
  17. tpyc/_data/lib/tpy/asyncio/__init__.py +744 -0
  18. tpyc/_data/lib/tpy/asyncio/_executor.py +515 -0
  19. tpyc/_data/lib/tpy/base64.py +410 -0
  20. tpyc/_data/lib/tpy/bisect.py +39 -0
  21. tpyc/_data/lib/tpy/builtins.py +38 -0
  22. tpyc/_data/lib/tpy/dataclasses.py +354 -0
  23. tpyc/_data/lib/tpy/enum.py +23 -0
  24. tpyc/_data/lib/tpy/functools.py +33 -0
  25. tpyc/_data/lib/tpy/hashlib.py +206 -0
  26. tpyc/_data/lib/tpy/heapq.py +118 -0
  27. tpyc/_data/lib/tpy/io.py +395 -0
  28. tpyc/_data/lib/tpy/json.py +221 -0
  29. tpyc/_data/lib/tpy/math.py +406 -0
  30. tpyc/_data/lib/tpy/random.py +597 -0
  31. tpyc/_data/lib/tpy/re.py +467 -0
  32. tpyc/_data/lib/tpy/socket.py +379 -0
  33. tpyc/_data/lib/tpy/struct.py +178 -0
  34. tpyc/_data/lib/tpy/sys.py +40 -0
  35. tpyc/_data/lib/tpy/time.py +39 -0
  36. tpyc/_data/lib/tpy/tpy/__init__.py +78 -0
  37. tpyc/_data/lib/tpy/tpy/_bootstrap/__init__.py +10 -0
  38. tpyc/_data/lib/tpy/tpy/_bootstrap/_decorators.py +37 -0
  39. tpyc/_data/lib/tpy/tpy/_bootstrap/_extern.py +64 -0
  40. tpyc/_data/lib/tpy/tpy/_builtins/__init__.py +11 -0
  41. tpyc/_data/lib/tpy/tpy/_builtins/_bytes.py +378 -0
  42. tpyc/_data/lib/tpy/tpy/_builtins/_dict.py +151 -0
  43. tpyc/_data/lib/tpy/tpy/_builtins/_exceptions.py +125 -0
  44. tpyc/_data/lib/tpy/tpy/_builtins/_funcs.py +681 -0
  45. tpyc/_data/lib/tpy/tpy/_builtins/_io.py +97 -0
  46. tpyc/_data/lib/tpy/tpy/_builtins/_list.py +127 -0
  47. tpyc/_data/lib/tpy/tpy/_builtins/_range.py +52 -0
  48. tpyc/_data/lib/tpy/tpy/_builtins/_set.py +139 -0
  49. tpyc/_data/lib/tpy/tpy/_builtins/_super.py +11 -0
  50. tpyc/_data/lib/tpy/tpy/_builtins/_types.py +661 -0
  51. tpyc/_data/lib/tpy/tpy/_core/__init__.py +23 -0
  52. tpyc/_data/lib/tpy/tpy/_core/_bytes_view.py +129 -0
  53. tpyc/_data/lib/tpy/tpy/_core/_containers.py +137 -0
  54. tpyc/_data/lib/tpy/tpy/_core/_functions.py +40 -0
  55. tpyc/_data/lib/tpy/tpy/_core/_types.py +2061 -0
  56. tpyc/_data/lib/tpy/tpy/_typing/__init__.py +77 -0
  57. tpyc/_data/lib/tpy/tpy/_version.py +29 -0
  58. tpyc/_data/lib/tpy/tpy/bits.py +28 -0
  59. tpyc/_data/lib/tpy/tpy/coro/__init__.py +127 -0
  60. tpyc/_data/lib/tpy/tpy/extern.py +8 -0
  61. tpyc/_data/lib/tpy/tpy/mem.py +49 -0
  62. tpyc/_data/lib/tpy/tpy/unsafe.py +195 -0
  63. tpyc/_data/lib/tpy/tpy/version.py +21 -0
  64. tpyc/_data/lib/tpy/typing.py +13 -0
  65. tpyc/_data/runtime/cpp/include/tpy/any.hpp +461 -0
  66. tpyc/_data/runtime/cpp/include/tpy/as_ostream.hpp +117 -0
  67. tpyc/_data/runtime/cpp/include/tpy/async.hpp +76 -0
  68. tpyc/_data/runtime/cpp/include/tpy/bigint.hpp +1343 -0
  69. tpyc/_data/runtime/cpp/include/tpy/builtins.hpp +400 -0
  70. tpyc/_data/runtime/cpp/include/tpy/bytes_ops.hpp +469 -0
  71. tpyc/_data/runtime/cpp/include/tpy/container_ops.hpp +487 -0
  72. tpyc/_data/runtime/cpp/include/tpy/copy_iter.hpp +82 -0
  73. tpyc/_data/runtime/cpp/include/tpy/core.hpp +558 -0
  74. tpyc/_data/runtime/cpp/include/tpy/dict_ops.hpp +289 -0
  75. tpyc/_data/runtime/cpp/include/tpy/dunder.hpp +750 -0
  76. tpyc/_data/runtime/cpp/include/tpy/dynamic.hpp +44 -0
  77. tpyc/_data/runtime/cpp/include/tpy/enum.hpp +40 -0
  78. tpyc/_data/runtime/cpp/include/tpy/file.hpp +245 -0
  79. tpyc/_data/runtime/cpp/include/tpy/fixed_int.hpp +317 -0
  80. tpyc/_data/runtime/cpp/include/tpy/format.hpp +954 -0
  81. tpyc/_data/runtime/cpp/include/tpy/frame_slot.hpp +120 -0
  82. tpyc/_data/runtime/cpp/include/tpy/generator.hpp +47 -0
  83. tpyc/_data/runtime/cpp/include/tpy/iterable_ops.hpp +122 -0
  84. tpyc/_data/runtime/cpp/include/tpy/itertools.hpp +749 -0
  85. tpyc/_data/runtime/cpp/include/tpy/next_iter.hpp +82 -0
  86. tpyc/_data/runtime/cpp/include/tpy/ordered_map.hpp +518 -0
  87. tpyc/_data/runtime/cpp/include/tpy/ordered_set.hpp +337 -0
  88. tpyc/_data/runtime/cpp/include/tpy/own_iter.hpp +54 -0
  89. tpyc/_data/runtime/cpp/include/tpy/pascal_graph_sdl.hpp +192 -0
  90. tpyc/_data/runtime/cpp/include/tpy/printing.hpp +302 -0
  91. tpyc/_data/runtime/cpp/include/tpy/protocols.hpp +61 -0
  92. tpyc/_data/runtime/cpp/include/tpy/range.hpp +115 -0
  93. tpyc/_data/runtime/cpp/include/tpy/ranges.hpp +212 -0
  94. tpyc/_data/runtime/cpp/include/tpy/set_ops.hpp +265 -0
  95. tpyc/_data/runtime/cpp/include/tpy/slice.hpp +47 -0
  96. tpyc/_data/runtime/cpp/include/tpy/span_iter.hpp +42 -0
  97. tpyc/_data/runtime/cpp/include/tpy/stdlib/math.hpp +41 -0
  98. tpyc/_data/runtime/cpp/include/tpy/stdlib/pcre2_h.hpp +96 -0
  99. tpyc/_data/runtime/cpp/include/tpy/stdlib/random.hpp +25 -0
  100. tpyc/_data/runtime/cpp/include/tpy/stdlib/socket_h.hpp +145 -0
  101. tpyc/_data/runtime/cpp/include/tpy/stdlib/time.hpp +62 -0
  102. tpyc/_data/runtime/cpp/include/tpy/system.hpp +121 -0
  103. tpyc/_data/runtime/cpp/include/tpy/throwable.hpp +55 -0
  104. tpyc/_data/runtime/cpp/include/tpy/tpy.hpp +156 -0
  105. tpyc/_data/runtime/cpp/include/tpy/type_name.hpp +77 -0
  106. tpyc/_data/runtime/cpp/include/tpy/type_traits.hpp +240 -0
  107. tpyc/_data/runtime/cpp/include/tpy/uninit_array_storage.hpp +250 -0
  108. tpyc/_data/runtime/cpp/include/tpy/uninit_heap_storage.hpp +277 -0
  109. tpyc/_data/runtime/cpp/include/tpy/varargs.hpp +174 -0
  110. tpyc/_data/runtime/cpp/include/tpy/variant_ref.hpp +118 -0
  111. tpyc/_data/runtime/cpp/src/stdlib/socket_impl.cpp +104 -0
  112. tpyc/_data/runtime/cpp/third_party/README.md +58 -0
  113. tpyc/_data/runtime/cpp/third_party/pcre2/AUTHORS +36 -0
  114. tpyc/_data/runtime/cpp/third_party/pcre2/CMakeLists.txt +1233 -0
  115. tpyc/_data/runtime/cpp/third_party/pcre2/COPYING +5 -0
  116. tpyc/_data/runtime/cpp/third_party/pcre2/ChangeLog +3097 -0
  117. tpyc/_data/runtime/cpp/third_party/pcre2/HACKING +853 -0
  118. tpyc/_data/runtime/cpp/third_party/pcre2/INSTALL +368 -0
  119. tpyc/_data/runtime/cpp/third_party/pcre2/LICENCE +94 -0
  120. tpyc/_data/runtime/cpp/third_party/pcre2/NEWS +492 -0
  121. tpyc/_data/runtime/cpp/third_party/pcre2/NON-AUTOTOOLS-BUILD +430 -0
  122. tpyc/_data/runtime/cpp/third_party/pcre2/README +956 -0
  123. tpyc/_data/runtime/cpp/third_party/pcre2/cmake/COPYING-CMAKE-SCRIPTS +22 -0
  124. tpyc/_data/runtime/cpp/third_party/pcre2/cmake/FindEditline.cmake +16 -0
  125. tpyc/_data/runtime/cpp/third_party/pcre2/cmake/FindPackageHandleStandardArgs.cmake +58 -0
  126. tpyc/_data/runtime/cpp/third_party/pcre2/cmake/FindReadline.cmake +29 -0
  127. tpyc/_data/runtime/cpp/third_party/pcre2/cmake/pcre2-config-version.cmake.in +15 -0
  128. tpyc/_data/runtime/cpp/third_party/pcre2/cmake/pcre2-config.cmake.in +148 -0
  129. tpyc/_data/runtime/cpp/third_party/pcre2/config-cmake.h.in +56 -0
  130. tpyc/_data/runtime/cpp/third_party/pcre2/libpcre2-16.pc.in +13 -0
  131. tpyc/_data/runtime/cpp/third_party/pcre2/libpcre2-32.pc.in +13 -0
  132. tpyc/_data/runtime/cpp/third_party/pcre2/libpcre2-8.pc.in +13 -0
  133. tpyc/_data/runtime/cpp/third_party/pcre2/libpcre2-posix.pc.in +13 -0
  134. tpyc/_data/runtime/cpp/third_party/pcre2/pcre2-config.in +121 -0
  135. tpyc/_data/runtime/cpp/third_party/pcre2/src/config.h +483 -0
  136. tpyc/_data/runtime/cpp/third_party/pcre2/src/config.h.generic +483 -0
  137. tpyc/_data/runtime/cpp/third_party/pcre2/src/config.h.in +460 -0
  138. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2.h +1010 -0
  139. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2.h.generic +1010 -0
  140. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2.h.in +1010 -0
  141. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_auto_possess.c +1371 -0
  142. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_chartables.c +196 -0
  143. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_chartables.c.dist +196 -0
  144. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_chkdint.c +96 -0
  145. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_compile.c +11001 -0
  146. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_config.c +252 -0
  147. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_context.c +510 -0
  148. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_convert.c +1189 -0
  149. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_dfa_match.c +4119 -0
  150. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_dftables.c +297 -0
  151. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_error.c +345 -0
  152. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_extuni.c +162 -0
  153. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_find_bracket.c +219 -0
  154. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_fuzzsupport.c +792 -0
  155. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_internal.h +2084 -0
  156. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_intmodedep.h +940 -0
  157. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_jit_compile.c +14972 -0
  158. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_jit_match.c +200 -0
  159. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_jit_misc.c +234 -0
  160. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_jit_neon_inc.h +354 -0
  161. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_jit_simd_inc.h +2355 -0
  162. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_jit_test.c +2528 -0
  163. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_maketables.c +165 -0
  164. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_match.c +7777 -0
  165. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_match_data.c +185 -0
  166. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_newline.c +243 -0
  167. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_ord2utf.c +120 -0
  168. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_pattern_info.c +432 -0
  169. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_printint.c +886 -0
  170. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_script_run.c +344 -0
  171. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_serialize.c +286 -0
  172. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_string_utils.c +237 -0
  173. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_study.c +1915 -0
  174. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_substitute.c +1009 -0
  175. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_substring.c +550 -0
  176. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_tables.c +234 -0
  177. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_ucd.c +5460 -0
  178. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_ucp.h +396 -0
  179. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_ucptables.c +1533 -0
  180. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_valid_utf.c +398 -0
  181. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2_xclass.c +308 -0
  182. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2demo.c +497 -0
  183. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2grep.c +4606 -0
  184. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2posix.c +425 -0
  185. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2posix.h +187 -0
  186. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2posix_test.c +209 -0
  187. tpyc/_data/runtime/cpp/third_party/pcre2/src/pcre2test.c +9708 -0
  188. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitExecAllocatorApple.c +137 -0
  189. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitExecAllocatorCore.c +327 -0
  190. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitExecAllocatorFreeBSD.c +89 -0
  191. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitExecAllocatorPosix.c +62 -0
  192. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitExecAllocatorWindows.c +40 -0
  193. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitProtExecAllocatorNetBSD.c +72 -0
  194. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitProtExecAllocatorPosix.c +172 -0
  195. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitWXExecAllocatorPosix.c +141 -0
  196. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/allocator_src/sljitWXExecAllocatorWindows.c +102 -0
  197. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitConfig.h +142 -0
  198. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitConfigCPU.h +188 -0
  199. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitConfigInternal.h +907 -0
  200. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitLir.c +3561 -0
  201. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitLir.h +2466 -0
  202. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeARM_32.c +4636 -0
  203. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeARM_64.c +3491 -0
  204. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeARM_T2_32.c +4302 -0
  205. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeLOONGARCH_64.c +3765 -0
  206. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeMIPS_32.c +472 -0
  207. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeMIPS_64.c +387 -0
  208. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeMIPS_common.c +4259 -0
  209. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativePPC_32.c +485 -0
  210. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativePPC_64.c +719 -0
  211. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativePPC_common.c +3161 -0
  212. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeRISCV_32.c +142 -0
  213. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeRISCV_64.c +222 -0
  214. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeRISCV_common.c +3121 -0
  215. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeS390X.c +4526 -0
  216. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeX86_32.c +1685 -0
  217. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeX86_64.c +1398 -0
  218. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitNativeX86_common.c +5001 -0
  219. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitSerialize.c +516 -0
  220. tpyc/_data/runtime/cpp/third_party/pcre2/src/sljit/sljitUtils.c +344 -0
  221. tpyc/_data/runtime/cpp/third_party/pcre2.sources.txt +54 -0
  222. tpyc/_data/runtime/cpp/third_party/pcre2.vendor.json +7 -0
  223. tpyc/build/__init__.py +7 -0
  224. tpyc/build/pcre2.py +122 -0
  225. tpyc/build/third_party.py +413 -0
  226. tpyc/cli.py +822 -0
  227. tpyc/codegen_cpp/__init__.py +18 -0
  228. tpyc/codegen_cpp/builtins.py +484 -0
  229. tpyc/codegen_cpp/context.py +2064 -0
  230. tpyc/codegen_cpp/expressions.py +5940 -0
  231. tpyc/codegen_cpp/functions.py +1913 -0
  232. tpyc/codegen_cpp/gen_async.py +3258 -0
  233. tpyc/codegen_cpp/gen_generators.py +657 -0
  234. tpyc/codegen_cpp/generator.py +2258 -0
  235. tpyc/codegen_cpp/match.py +1997 -0
  236. tpyc/codegen_cpp/param_const.py +172 -0
  237. tpyc/codegen_cpp/protocols.py +907 -0
  238. tpyc/codegen_cpp/records.py +1654 -0
  239. tpyc/codegen_cpp/resumable_cfg.py +1651 -0
  240. tpyc/codegen_cpp/statements.py +4963 -0
  241. tpyc/codegen_cpp/string_dispatch.py +76 -0
  242. tpyc/codegen_cpp/test_context.py +46 -0
  243. tpyc/codegen_cpp/test_param_const.py +113 -0
  244. tpyc/codegen_cpp/test_resumable_cfg.py +182 -0
  245. tpyc/codegen_cpp/type_resolution.py +53 -0
  246. tpyc/codegen_cpp/types.py +436 -0
  247. tpyc/codegen_cpp/variant_access.py +135 -0
  248. tpyc/coercions.py +749 -0
  249. tpyc/compilation_context.py +57 -0
  250. tpyc/compiler.py +3945 -0
  251. tpyc/cycle_detection.py +358 -0
  252. tpyc/diagnostics.py +135 -0
  253. tpyc/dump_types.py +353 -0
  254. tpyc/frontend_diagnostics.py +47 -0
  255. tpyc/frontend_ir/__init__.py +140 -0
  256. tpyc/frontend_ir/lower.py +1098 -0
  257. tpyc/frontend_ir/nodes.py +718 -0
  258. tpyc/frontend_ir/resolver_adapter.py +151 -0
  259. tpyc/frontend_plugin.py +209 -0
  260. tpyc/install_docs.py +81 -0
  261. tpyc/liveness.py +756 -0
  262. tpyc/macro_api.py +1724 -0
  263. tpyc/macro_loader.py +497 -0
  264. tpyc/module_names.py +64 -0
  265. tpyc/modules/__init__.py +31 -0
  266. tpyc/modules/defs.py +89 -0
  267. tpyc/modules/registry.py +36 -0
  268. tpyc/modules/resolver.py +192 -0
  269. tpyc/modules/type_resolution.py +629 -0
  270. tpyc/namespace.py +172 -0
  271. tpyc/parse/__init__.py +84 -0
  272. tpyc/parse/imports.py +490 -0
  273. tpyc/parse/nodes.py +1732 -0
  274. tpyc/parse/parser.py +4043 -0
  275. tpyc/parse/resolve_refs.py +466 -0
  276. tpyc/parse/type_resolver.py +1060 -0
  277. tpyc/prescan.py +254 -0
  278. tpyc/qnames.py +149 -0
  279. tpyc/repl.py +529 -0
  280. tpyc/repl_backends.py +848 -0
  281. tpyc/sema/__init__.py +21 -0
  282. tpyc/sema/analyzer.py +3625 -0
  283. tpyc/sema/bound_check.py +72 -0
  284. tpyc/sema/builder_trace.py +684 -0
  285. tpyc/sema/calls.py +5406 -0
  286. tpyc/sema/compatibility.py +2107 -0
  287. tpyc/sema/context.py +1243 -0
  288. tpyc/sema/expressions.py +3737 -0
  289. tpyc/sema/flow_facts.py +199 -0
  290. tpyc/sema/init_tracker.py +150 -0
  291. tpyc/sema/list_literals.py +69 -0
  292. tpyc/sema/literal_utils.py +27 -0
  293. tpyc/sema/local_deduction.py +1088 -0
  294. tpyc/sema/macros.py +179 -0
  295. tpyc/sema/match.py +1177 -0
  296. tpyc/sema/method_expansion.py +347 -0
  297. tpyc/sema/methods.py +2197 -0
  298. tpyc/sema/mutation_propagation.py +268 -0
  299. tpyc/sema/narrowing.py +857 -0
  300. tpyc/sema/numeric_lattice.py +160 -0
  301. tpyc/sema/operators.py +402 -0
  302. tpyc/sema/overloads.py +841 -0
  303. tpyc/sema/protocols.py +1209 -0
  304. tpyc/sema/reach_analysis.py +202 -0
  305. tpyc/sema/registration.py +3156 -0
  306. tpyc/sema/scope_tracker.py +193 -0
  307. tpyc/sema/statements.py +4426 -0
  308. tpyc/sema/type_ops.py +1879 -0
  309. tpyc/sema/value_range.py +181 -0
  310. tpyc/symbol_binding.py +259 -0
  311. tpyc/test_c3_mro.py +208 -0
  312. tpyc/test_cli_argv.py +52 -0
  313. tpyc/test_compiler.py +559 -0
  314. tpyc/test_contains_type_param.py +101 -0
  315. tpyc/test_cycle_detection.py +221 -0
  316. tpyc/test_dump_types.py +225 -0
  317. tpyc/test_install_docs.py +65 -0
  318. tpyc/test_local_cpp_form.py +135 -0
  319. tpyc/test_macro_loader.py +76 -0
  320. tpyc/test_method_expansion.py +254 -0
  321. tpyc/test_nominal_identity.py +182 -0
  322. tpyc/test_overloads.py +410 -0
  323. tpyc/test_parse.py +303 -0
  324. tpyc/test_parse_type_ref.py +506 -0
  325. tpyc/test_parse_version_info.py +58 -0
  326. tpyc/test_reach_analysis.py +72 -0
  327. tpyc/test_ref_type.py +216 -0
  328. tpyc/test_send_sync_substitution.py +276 -0
  329. tpyc/test_tuple_mutation_propagation.py +206 -0
  330. tpyc/test_type_def_registry.py +1729 -0
  331. tpyc/test_union_types.py +195 -0
  332. tpyc/type_def_registry.py +975 -0
  333. tpyc/typesys.py +5104 -0
@@ -0,0 +1,1233 @@
1
+ # CMakeLists.txt
2
+ #
3
+ # This file enables PCRE2 to be built with the CMake configuration and build
4
+ # tool. Download CMake in source or binary form from http://www.cmake.org/
5
+ # Converted to support PCRE2 from the original PCRE file, August 2014.
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
+ # 2007-12-26 (a) On UNIX, use names libpcre instead of just pcre
12
+ # (b) Ensure pcretest and pcregrep link with the local library,
13
+ # not a previously-installed one.
14
+ # (c) Add PCRE_SUPPORT_LIBREADLINE, PCRE_SUPPORT_LIBZ, and
15
+ # PCRE_SUPPORT_LIBBZ2.
16
+ # 2008-01-20 Brought up to date to include several new features by Christian
17
+ # Ehrlicher.
18
+ # 2008-01-22 Sheri added options for backward compatibility of library names
19
+ # when building with minGW:
20
+ # if "ON", NON_STANDARD_LIB_PREFIX causes shared libraries to
21
+ # be built without "lib" as prefix. (The libraries will be named
22
+ # pcre.dll, pcreposix.dll and pcrecpp.dll).
23
+ # if "ON", NON_STANDARD_LIB_SUFFIX causes shared libraries to
24
+ # be built with suffix of "-0.dll". (The libraries will be named
25
+ # libpcre-0.dll, libpcreposix-0.dll and libpcrecpp-0.dll - same names
26
+ # built by default with Configure and Make.
27
+ # 2008-01-23 PH removed the automatic build of pcredemo.
28
+ # 2008-04-22 PH modified READLINE support so it finds NCURSES when needed.
29
+ # 2008-07-03 PH updated for revised UCP property support (change of files)
30
+ # 2009-03-23 PH applied Steven Van Ingelgem's patch to change the name
31
+ # CMAKE_BINARY_DIR to PROJECT_BINARY_DIR so that it works when PCRE
32
+ # is included within another project.
33
+ # 2009-03-23 PH applied a modified version of Steven Van Ingelgem's patches to
34
+ # add options to stop the building of pcregrep and the tests, and
35
+ # to disable the final configuration report.
36
+ # 2009-04-11 PH applied Christian Ehrlicher's patch to show compiler flags that
37
+ # are set by specifying a release type.
38
+ # 2010-01-02 PH added test for stdint.h
39
+ # 2010-03-02 PH added test for inttypes.h
40
+ # 2011-08-01 PH added PCREGREP_BUFSIZE
41
+ # 2011-08-22 PH added PCRE_SUPPORT_JIT
42
+ # 2011-09-06 PH modified WIN32 ADD_TEST line as suggested by Sergey Cherepanov
43
+ # 2011-09-06 PH added PCRE_SUPPORT_PCREGREP_JIT
44
+ # 2011-10-04 Sheri added support for including coff data in windows shared libraries
45
+ # compiled with MINGW if pcre.rc and/or pcreposix.rc are placed in
46
+ # the source dir by the user prior to building
47
+ # 2011-10-04 Sheri changed various add_test's to use exes' location built instead
48
+ # of DEBUG location only (likely only matters in MSVC)
49
+ # 2011-10-04 Sheri added scripts to provide needed variables to RunTest and
50
+ # RunGrepTest (used for UNIX and Msys)
51
+ # 2011-10-04 Sheri added scripts to provide needed variables and to execute
52
+ # RunTest.bat in Win32 (for effortless testing with "make test")
53
+ # 2011-10-04 Sheri Increased minimum required cmake version
54
+ # 2012-01-06 PH removed pcre_info.c and added pcre_string_utils.c
55
+ # 2012-01-10 Zoltan Herczeg added libpcre16 support
56
+ # 2012-01-13 Stephen Kelly added out of source build support
57
+ # 2012-01-17 PH applied Stephen Kelly's patch to parse the version data out
58
+ # of the configure.ac file
59
+ # 2012-02-26 PH added support for libedit
60
+ # 2012-09-06 PH added support for PCRE_EBCDIC_NL25
61
+ # 2012-09-08 ChPe added PCRE32 support
62
+ # 2012-10-23 PH added support for VALGRIND and GCOV
63
+ # 2012-12-08 PH added patch from Daniel Richard G to quash some MSVC warnings
64
+ # 2013-07-01 PH realized that the "support" for GCOV was a total nonsense and
65
+ # so it has been removed.
66
+ # 2013-10-08 PH got rid of the "source" command, which is a bash-ism (use ".")
67
+ # 2013-11-05 PH added support for PARENS_NEST_LIMIT
68
+ # 2014-08-29 PH converted the file for PCRE2 (which has no C++).
69
+ # 2015-04-24 PH added support for PCRE2_DEBUG
70
+ # 2015-07-16 PH updated for new pcre2_find_bracket source module
71
+ # 2015-08-24 PH correct C_FLAGS setting (patch from Roy Ivy III)
72
+ # 2015-10=16 PH added support for never-backslash-C
73
+ # 2016-03-01 PH applied Chris Wilson's patch for MSVC static
74
+ # 2016-06-24 PH applied Chris Wilson's second patch, putting the first under
75
+ # a new option instead of being unconditional.
76
+ # 2016-10-05 PH fixed a typo (PCRE should be PCRE2) in above patch
77
+ # fix by David Gaussmann
78
+ # 2016-10-07 PH added PCREGREP_MAX_BUFSIZE
79
+ # 2017-03-11 PH turned HEAP_MATCH_RECURSE into a NO-OP for 10.30
80
+ # 2017-04-08 PH added HEAP_LIMIT
81
+ # 2017-06-15 ZH added SUPPORT_JIT_SEALLOC support
82
+ # 2018-06-19 PH added checks for stdint.h and inttypes.h (later removed)
83
+ # 2018-06-27 PH added Daniel's patch to increase the stack for MSVC
84
+ # 2018-11-14 PH removed unnecessary checks for stdint.h and inttypes.h
85
+ # 2018-11-16 PH added PCRE2GREP_SUPPORT_CALLOUT_FORK support and tidied
86
+ # 2019-02-16 PH hacked to avoid CMP0026 policy issue (see comments below)
87
+ # 2020-03-16 PH renamed dftables as pcre2_dftables (as elsewhere)
88
+ # 2020-03-24 PH changed CMAKE_MODULE_PATH definition to add, not replace
89
+ # 2020-04-08 Carlo added function check for secure_getenv, fixed strerror
90
+ # 2020-04-16 enh added check for __attribute__((uninitialized))
91
+ # 2020-04-25 PH applied patches from Uwe Korn to support pkg-config and
92
+ # library versioning.
93
+ # 2020-04-25 Carlo added function check for mkostemp used in ProtExecAllocator
94
+ # 2020-04-28 PH added function check for memfd_create based on Carlo's patch
95
+ # 2020-05-25 PH added a check for Intel CET
96
+ # 2020-12-03 PH altered the definition of pcre2test as suggested by Daniel
97
+ # 2021-06-29 JWSB added the option to build static library with PIC.
98
+ # 2021-07-05 JWSB modified such both the static and shared library can be
99
+ # build in one go.
100
+ # 2021-08-28 PH increased minimum version
101
+ # 2021-08-28 PH added test for realpath()
102
+ # 2022-12-10 PH added support for pcre2posix_test
103
+ # 2023-01-15 Carlo added C99 as the minimum required
104
+ # 2023-08-06 PH added support for setting variable length lookbehind maximum
105
+
106
+ # Increased minimum to 3.5 to workaround deprecated backward compatibility
107
+ # since 3.27.
108
+ cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
109
+ project(PCRE2 C)
110
+ set(CMAKE_C_STANDARD 99)
111
+ set(CMAKE_C_STANDARD_REQUIRED TRUE)
112
+
113
+ set(CMAKE_C_VISIBILITY_PRESET hidden)
114
+ cmake_policy(SET CMP0063 NEW)
115
+
116
+ # Set policy CMP0026 to avoid warnings for the use of LOCATION in
117
+ # GET_TARGET_PROPERTY. This should no longer be required.
118
+ # CMAKE_POLICY(SET CMP0026 OLD)
119
+
120
+ # With a recent cmake, you can provide a rootdir to look for non
121
+ # standard installed library dependencies, but to do so, the policy
122
+ # needs to be set to new (by uncommenting the following)
123
+ # CMAKE_POLICY(SET CMP0074 NEW)
124
+
125
+ # For FindReadline.cmake. This was changed to allow setting CMAKE_MODULE_PATH
126
+ # on the command line.
127
+ # SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
128
+
129
+ LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
130
+
131
+ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src)
132
+
133
+ # external packages
134
+ FIND_PACKAGE( BZip2 )
135
+ FIND_PACKAGE( ZLIB )
136
+ FIND_PACKAGE( Readline )
137
+ FIND_PACKAGE( Editline )
138
+
139
+ # Configuration checks
140
+
141
+ INCLUDE(CheckCSourceCompiles)
142
+ INCLUDE(CheckFunctionExists)
143
+ INCLUDE(CheckSymbolExists)
144
+ INCLUDE(CheckIncludeFile)
145
+ INCLUDE(CheckTypeSize)
146
+ INCLUDE(GNUInstallDirs) # for CMAKE_INSTALL_LIBDIR
147
+
148
+ CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
149
+ CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
150
+ CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
151
+ CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
152
+ CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
153
+
154
+ CHECK_SYMBOL_EXISTS(bcopy "strings.h" HAVE_BCOPY)
155
+ CHECK_SYMBOL_EXISTS(memfd_create "sys/mman.h" HAVE_MEMFD_CREATE)
156
+ CHECK_SYMBOL_EXISTS(memmove "string.h" HAVE_MEMMOVE)
157
+ CHECK_SYMBOL_EXISTS(secure_getenv "stdlib.h" HAVE_SECURE_GETENV)
158
+ CHECK_SYMBOL_EXISTS(strerror "string.h" HAVE_STRERROR)
159
+
160
+ CHECK_C_SOURCE_COMPILES(
161
+ "#include <stdlib.h>
162
+ #include <limits.h>
163
+ int main(int c, char *v[]) { char buf[PATH_MAX]; realpath(v[c], buf); return 0; }"
164
+ HAVE_REALPATH
165
+ )
166
+
167
+ set(ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
168
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror")
169
+
170
+ CHECK_C_SOURCE_COMPILES(
171
+ "#include <stddef.h>
172
+ int main(void) { int a,b; size_t m; __builtin_mul_overflow(a,b,&m); return 0; }"
173
+ HAVE_BUILTIN_MUL_OVERFLOW
174
+ )
175
+
176
+ CHECK_C_SOURCE_COMPILES(
177
+ "int main(void) { char buf[128] __attribute__((uninitialized)); (void)buf; return 0; }"
178
+ HAVE_ATTRIBUTE_UNINITIALIZED
179
+ )
180
+
181
+ CHECK_C_SOURCE_COMPILES([=[
182
+ extern __attribute__ ((visibility ("default"))) int f(void);
183
+ int main(void) { return f(); }
184
+ int f(void) { return 42; }
185
+ ]=] HAVE_VISIBILITY
186
+ )
187
+
188
+ if (HAVE_VISIBILITY)
189
+ set(PCRE2_EXPORT [=[__attribute__ ((visibility ("default")))]=])
190
+ else()
191
+ set(PCRE2_EXPORT)
192
+ endif()
193
+
194
+ set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
195
+
196
+ # Check whether Intel CET is enabled, and if so, adjust compiler flags. This
197
+ # code was written by PH, trying to imitate the logic from the autotools
198
+ # configuration.
199
+
200
+ CHECK_C_SOURCE_COMPILES(
201
+ "#ifndef __CET__
202
+ #error CET is not enabled
203
+ #endif
204
+ int main() { return 0; }"
205
+ INTEL_CET_ENABLED
206
+ )
207
+
208
+ IF (INTEL_CET_ENABLED)
209
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mshstk")
210
+ ENDIF(INTEL_CET_ENABLED)
211
+
212
+ # User-configurable options
213
+ #
214
+ # Note: CMakeSetup displays these in alphabetical order, regardless of
215
+ # the order we use here.
216
+
217
+ SET(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries.")
218
+
219
+ OPTION(BUILD_STATIC_LIBS "Build static libraries." ON)
220
+
221
+ OPTION(PCRE2_BUILD_PCRE2_8 "Build 8 bit PCRE2 library" ON)
222
+
223
+ OPTION(PCRE2_BUILD_PCRE2_16 "Build 16 bit PCRE2 library" OFF)
224
+
225
+ OPTION(PCRE2_BUILD_PCRE2_32 "Build 32 bit PCRE2 library" OFF)
226
+
227
+ OPTION(PCRE2_STATIC_PIC "Build the static library with the option position independent code enabled." OFF)
228
+
229
+ OPTION(PCRE2_DEBUG "Include debugging code" OFF)
230
+
231
+ OPTION(PCRE2_DISABLE_PERCENT_ZT "Disable the use of %zu and %td (rarely needed)" OFF)
232
+
233
+ SET(PCRE2_EBCDIC OFF CACHE BOOL
234
+ "Use EBCDIC coding instead of ASCII. (This is rarely used outside of mainframe systems.)")
235
+
236
+ SET(PCRE2_EBCDIC_NL25 OFF CACHE BOOL
237
+ "Use 0x25 as EBCDIC NL character instead of 0x15; implies EBCDIC.")
238
+
239
+ SET(PCRE2_LINK_SIZE "2" CACHE STRING
240
+ "Internal link size (2, 3 or 4 allowed). See LINK_SIZE in config.h.in for details.")
241
+
242
+ SET(PCRE2_PARENS_NEST_LIMIT "250" CACHE STRING
243
+ "Default nested parentheses limit. See PARENS_NEST_LIMIT in config.h.in for details.")
244
+
245
+ SET(PCRE2_HEAP_LIMIT "20000000" CACHE STRING
246
+ "Default limit on heap memory (kibibytes). See HEAP_LIMIT in config.h.in for details.")
247
+
248
+ SET(PCRE2_MAX_VARLOOKBEHIND "255" CACHE STRING
249
+ "Default limit on variable lookbehinds.")
250
+
251
+ SET(PCRE2_MATCH_LIMIT "10000000" CACHE STRING
252
+ "Default limit on internal looping. See MATCH_LIMIT in config.h.in for details.")
253
+
254
+ SET(PCRE2_MATCH_LIMIT_DEPTH "MATCH_LIMIT" CACHE STRING
255
+ "Default limit on internal depth of search. See MATCH_LIMIT_DEPTH in config.h.in for details.")
256
+
257
+ SET(PCRE2GREP_BUFSIZE "20480" CACHE STRING
258
+ "Buffer starting size parameter for pcre2grep. See PCRE2GREP_BUFSIZE in config.h.in for details.")
259
+
260
+ SET(PCRE2GREP_MAX_BUFSIZE "1048576" CACHE STRING
261
+ "Buffer maximum size parameter for pcre2grep. See PCRE2GREP_MAX_BUFSIZE in config.h.in for details.")
262
+
263
+ SET(PCRE2_NEWLINE "LF" CACHE STRING
264
+ "What to recognize as a newline (one of CR, LF, CRLF, ANY, ANYCRLF, NUL).")
265
+
266
+ SET(PCRE2_HEAP_MATCH_RECURSE OFF CACHE BOOL
267
+ "Obsolete option: do not use")
268
+
269
+ SET(PCRE2_SUPPORT_JIT OFF CACHE BOOL
270
+ "Enable support for Just-in-time compiling.")
271
+
272
+ IF(${CMAKE_SYSTEM_NAME} MATCHES Linux|NetBSD)
273
+ SET(PCRE2_SUPPORT_JIT_SEALLOC OFF CACHE BOOL
274
+ "Enable SELinux compatible execmem allocator in JIT (experimental).")
275
+ ELSE(${CMAKE_SYSTEM_NAME} MATCHES Linux|NetBSD)
276
+ SET(PCRE2_SUPPORT_JIT_SEALLOC IGNORE)
277
+ ENDIF(${CMAKE_SYSTEM_NAME} MATCHES Linux|NetBSD)
278
+
279
+ SET(PCRE2GREP_SUPPORT_JIT ON CACHE BOOL
280
+ "Enable use of Just-in-time compiling in pcre2grep.")
281
+
282
+ SET(PCRE2GREP_SUPPORT_CALLOUT ON CACHE BOOL
283
+ "Enable callout string support in pcre2grep.")
284
+
285
+ SET(PCRE2GREP_SUPPORT_CALLOUT_FORK ON CACHE BOOL
286
+ "Enable callout string fork support in pcre2grep.")
287
+
288
+ SET(PCRE2_SUPPORT_UNICODE ON CACHE BOOL
289
+ "Enable support for Unicode and UTF-8/UTF-16/UTF-32 encoding.")
290
+
291
+ SET(PCRE2_SUPPORT_BSR_ANYCRLF OFF CACHE BOOL
292
+ "ON=Backslash-R matches only LF CR and CRLF, OFF=Backslash-R matches all Unicode Linebreaks")
293
+
294
+ SET(PCRE2_NEVER_BACKSLASH_C OFF CACHE BOOL
295
+ "If ON, backslash-C (upper case C) is locked out.")
296
+
297
+ SET(PCRE2_SUPPORT_VALGRIND OFF CACHE BOOL
298
+ "Enable Valgrind support.")
299
+
300
+ OPTION(PCRE2_SHOW_REPORT "Show the final configuration report" ON)
301
+ OPTION(PCRE2_BUILD_PCRE2GREP "Build pcre2grep" ON)
302
+ OPTION(PCRE2_BUILD_TESTS "Build the tests" ON)
303
+
304
+ IF (MINGW)
305
+ OPTION(NON_STANDARD_LIB_PREFIX
306
+ "ON=Shared libraries built in mingw will be named pcre2.dll, etc., instead of libpcre2.dll, etc."
307
+ OFF)
308
+
309
+ OPTION(NON_STANDARD_LIB_SUFFIX
310
+ "ON=Shared libraries built in mingw will be named libpcre2-0.dll, etc., instead of libpcre2.dll, etc."
311
+ OFF)
312
+ ENDIF(MINGW)
313
+
314
+ IF(MSVC)
315
+ OPTION(PCRE2_STATIC_RUNTIME
316
+ "ON=Compile against the static runtime (/MT)."
317
+ OFF)
318
+ OPTION(INSTALL_MSVC_PDB
319
+ "ON=Install .pdb files built by MSVC, if generated"
320
+ OFF)
321
+ ENDIF(MSVC)
322
+
323
+ # bzip2 lib
324
+ IF(BZIP2_FOUND)
325
+ OPTION (PCRE2_SUPPORT_LIBBZ2 "Enable support for linking pcre2grep with libbz2." ON)
326
+ ENDIF(BZIP2_FOUND)
327
+ IF(PCRE2_SUPPORT_LIBBZ2)
328
+ INCLUDE_DIRECTORIES(${BZIP2_INCLUDE_DIR})
329
+ ENDIF(PCRE2_SUPPORT_LIBBZ2)
330
+
331
+ # zlib
332
+ IF(ZLIB_FOUND)
333
+ OPTION (PCRE2_SUPPORT_LIBZ "Enable support for linking pcre2grep with libz." ON)
334
+ ENDIF(ZLIB_FOUND)
335
+ IF(PCRE2_SUPPORT_LIBZ)
336
+ INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
337
+ ENDIF(PCRE2_SUPPORT_LIBZ)
338
+
339
+ # editline lib
340
+ IF(EDITLINE_FOUND)
341
+ OPTION (PCRE2_SUPPORT_LIBEDIT "Enable support for linking pcre2test with libedit." OFF)
342
+ ENDIF(EDITLINE_FOUND)
343
+ IF(EDITLINE_FOUND)
344
+ IF(PCRE2_SUPPORT_LIBEDIT)
345
+ INCLUDE_DIRECTORIES(${EDITLINE_INCLUDE_DIR})
346
+ ENDIF(PCRE2_SUPPORT_LIBEDIT)
347
+ ELSE(EDITLINE_FOUND)
348
+ IF(PCRE2_SUPPORT_LIBEDIT)
349
+ MESSAGE(FATAL_ERROR
350
+ " libedit not found, set EDITLINE_INCLUDE_DIR to a compatible header\n"
351
+ " or set Editline_ROOT to a full libedit installed tree, as needed\n"
352
+ " Might need to enable policy CMP0074 in CMakeLists.txt"
353
+ )
354
+ ENDIF(PCRE2_SUPPORT_LIBEDIT)
355
+ ENDIF(EDITLINE_FOUND)
356
+
357
+ # readline lib
358
+ IF(READLINE_FOUND)
359
+ OPTION (PCRE2_SUPPORT_LIBREADLINE "Enable support for linking pcre2test with libreadline." ON)
360
+ ENDIF(READLINE_FOUND)
361
+ IF(PCRE2_SUPPORT_LIBREADLINE)
362
+ INCLUDE_DIRECTORIES(${READLINE_INCLUDE_DIR})
363
+ ENDIF(PCRE2_SUPPORT_LIBREADLINE)
364
+
365
+ # Prepare build configuration
366
+
367
+ IF(NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS)
368
+ MESSAGE(FATAL_ERROR "At least one of BUILD_SHARED_LIBS or BUILD_STATIC_LIBS must be enabled.")
369
+ ENDIF(NOT BUILD_SHARED_LIBS AND NOT BUILD_STATIC_LIBS)
370
+
371
+ IF(NOT PCRE2_BUILD_PCRE2_8 AND NOT PCRE2_BUILD_PCRE2_16 AND NOT PCRE2_BUILD_PCRE2_32)
372
+ MESSAGE(FATAL_ERROR "At least one of PCRE2_BUILD_PCRE2_8, PCRE2_BUILD_PCRE2_16 or PCRE2_BUILD_PCRE2_32 must be enabled")
373
+ ENDIF(NOT PCRE2_BUILD_PCRE2_8 AND NOT PCRE2_BUILD_PCRE2_16 AND NOT PCRE2_BUILD_PCRE2_32)
374
+
375
+ IF(PCRE2_BUILD_PCRE2_8)
376
+ SET(SUPPORT_PCRE2_8 1)
377
+ ENDIF(PCRE2_BUILD_PCRE2_8)
378
+
379
+ IF(PCRE2_BUILD_PCRE2_16)
380
+ SET(SUPPORT_PCRE2_16 1)
381
+ ENDIF(PCRE2_BUILD_PCRE2_16)
382
+
383
+ IF(PCRE2_BUILD_PCRE2_32)
384
+ SET(SUPPORT_PCRE2_32 1)
385
+ ENDIF(PCRE2_BUILD_PCRE2_32)
386
+
387
+ IF(PCRE2_BUILD_PCRE2GREP AND NOT PCRE2_BUILD_PCRE2_8)
388
+ MESSAGE(STATUS "** PCRE2_BUILD_PCRE2_8 must be enabled for the pcre2grep program")
389
+ SET(PCRE2_BUILD_PCRE2GREP OFF)
390
+ ENDIF(PCRE2_BUILD_PCRE2GREP AND NOT PCRE2_BUILD_PCRE2_8)
391
+
392
+ IF(PCRE2_SUPPORT_LIBREADLINE AND PCRE2_SUPPORT_LIBEDIT)
393
+ IF(READLINE_FOUND)
394
+ MESSAGE(FATAL_ERROR
395
+ " Only one of the readline compatible libraries can be enabled.\n"
396
+ " Disable libreadline with -DPCRE2_SUPPORT_LIBREADLINE=OFF"
397
+ )
398
+ ENDIF(READLINE_FOUND)
399
+ ENDIF(PCRE2_SUPPORT_LIBREADLINE AND PCRE2_SUPPORT_LIBEDIT)
400
+
401
+ IF(PCRE2_SUPPORT_BSR_ANYCRLF)
402
+ SET(BSR_ANYCRLF 1)
403
+ ENDIF(PCRE2_SUPPORT_BSR_ANYCRLF)
404
+
405
+ IF(PCRE2_NEVER_BACKSLASH_C)
406
+ SET(NEVER_BACKSLASH_C 1)
407
+ ENDIF(PCRE2_NEVER_BACKSLASH_C)
408
+
409
+ IF(PCRE2_SUPPORT_UNICODE)
410
+ SET(SUPPORT_UNICODE 1)
411
+ ENDIF(PCRE2_SUPPORT_UNICODE)
412
+
413
+ IF(PCRE2_SUPPORT_JIT)
414
+ SET(SUPPORT_JIT 1)
415
+ IF(UNIX)
416
+ FIND_PACKAGE(Threads REQUIRED)
417
+ IF(CMAKE_USE_PTHREADS_INIT)
418
+ SET(REQUIRE_PTHREAD 1)
419
+ ENDIF(CMAKE_USE_PTHREADS_INIT)
420
+ ENDIF(UNIX)
421
+ ENDIF(PCRE2_SUPPORT_JIT)
422
+
423
+ IF(PCRE2_SUPPORT_JIT_SEALLOC)
424
+ SET(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
425
+ CHECK_SYMBOL_EXISTS(mkostemp stdlib.h REQUIRED)
426
+ UNSET(CMAKE_REQUIRED_DEFINITIONS)
427
+ IF(${REQUIRED})
428
+ IF(${CMAKE_SYSTEM_NAME} MATCHES Linux|NetBSD)
429
+ ADD_DEFINITIONS(-D_GNU_SOURCE)
430
+ SET(SLJIT_PROT_EXECUTABLE_ALLOCATOR 1)
431
+ ELSE(${CMAKE_SYSTEM_NAME} MATCHES Linux|NetBSD)
432
+ MESSAGE(FATAL_ERROR "Your configuration is not supported")
433
+ ENDIF(${CMAKE_SYSTEM_NAME} MATCHES Linux|NetBSD)
434
+ ELSE(${REQUIRED})
435
+ SET(PCRE2_SUPPORT_JIT_SEALLOC OFF)
436
+ ENDIF(${REQUIRED})
437
+ ENDIF(PCRE2_SUPPORT_JIT_SEALLOC)
438
+
439
+ IF(PCRE2GREP_SUPPORT_JIT)
440
+ SET(SUPPORT_PCRE2GREP_JIT 1)
441
+ ENDIF(PCRE2GREP_SUPPORT_JIT)
442
+
443
+ IF(PCRE2GREP_SUPPORT_CALLOUT)
444
+ SET(SUPPORT_PCRE2GREP_CALLOUT 1)
445
+ IF(PCRE2GREP_SUPPORT_CALLOUT_FORK)
446
+ SET(SUPPORT_PCRE2GREP_CALLOUT_FORK 1)
447
+ ENDIF(PCRE2GREP_SUPPORT_CALLOUT_FORK)
448
+ ENDIF(PCRE2GREP_SUPPORT_CALLOUT)
449
+
450
+ IF(PCRE2_SUPPORT_VALGRIND)
451
+ SET(SUPPORT_VALGRIND 1)
452
+ ENDIF(PCRE2_SUPPORT_VALGRIND)
453
+
454
+ IF(PCRE2_DISABLE_PERCENT_ZT)
455
+ SET(DISABLE_PERCENT_ZT 1)
456
+ ENDIF(PCRE2_DISABLE_PERCENT_ZT)
457
+
458
+ # This next one used to reference ${READLINE_LIBRARY})
459
+ # but I was advised to add the NCURSES test as well, along with
460
+ # some modifications to cmake/FindReadline.cmake which should
461
+ # make it possible to override the default if necessary. PH
462
+
463
+ IF(PCRE2_SUPPORT_LIBREADLINE)
464
+ SET(SUPPORT_LIBREADLINE 1)
465
+ SET(PCRE2TEST_LIBS ${READLINE_LIBRARY} ${NCURSES_LIBRARY})
466
+ ENDIF(PCRE2_SUPPORT_LIBREADLINE)
467
+
468
+ # libedit is a plug-compatible alternative to libreadline
469
+
470
+ IF(PCRE2_SUPPORT_LIBEDIT)
471
+ SET(SUPPORT_LIBEDIT 1)
472
+ SET(PCRE2TEST_LIBS ${EDITLINE_LIBRARY} ${NCURSES_LIBRARY})
473
+ ENDIF(PCRE2_SUPPORT_LIBEDIT)
474
+
475
+ IF(PCRE2_SUPPORT_LIBZ)
476
+ SET(SUPPORT_LIBZ 1)
477
+ SET(PCRE2GREP_LIBS ${PCRE2GREP_LIBS} ${ZLIB_LIBRARIES})
478
+ ENDIF(PCRE2_SUPPORT_LIBZ)
479
+
480
+ IF(PCRE2_SUPPORT_LIBBZ2)
481
+ SET(SUPPORT_LIBBZ2 1)
482
+ SET(PCRE2GREP_LIBS ${PCRE2GREP_LIBS} ${BZIP2_LIBRARIES})
483
+ ENDIF(PCRE2_SUPPORT_LIBBZ2)
484
+
485
+ SET(NEWLINE_DEFAULT "")
486
+
487
+ IF(PCRE2_NEWLINE STREQUAL "CR")
488
+ SET(NEWLINE_DEFAULT "1")
489
+ ENDIF(PCRE2_NEWLINE STREQUAL "CR")
490
+ IF(PCRE2_NEWLINE STREQUAL "LF")
491
+ SET(NEWLINE_DEFAULT "2")
492
+ ENDIF(PCRE2_NEWLINE STREQUAL "LF")
493
+ IF(PCRE2_NEWLINE STREQUAL "CRLF")
494
+ SET(NEWLINE_DEFAULT "3")
495
+ ENDIF(PCRE2_NEWLINE STREQUAL "CRLF")
496
+ IF(PCRE2_NEWLINE STREQUAL "ANY")
497
+ SET(NEWLINE_DEFAULT "4")
498
+ ENDIF(PCRE2_NEWLINE STREQUAL "ANY")
499
+ IF(PCRE2_NEWLINE STREQUAL "ANYCRLF")
500
+ SET(NEWLINE_DEFAULT "5")
501
+ ENDIF(PCRE2_NEWLINE STREQUAL "ANYCRLF")
502
+ IF(PCRE2_NEWLINE STREQUAL "NUL")
503
+ SET(NEWLINE_DEFAULT "6")
504
+ ENDIF(PCRE2_NEWLINE STREQUAL "NUL")
505
+
506
+ IF(NEWLINE_DEFAULT STREQUAL "")
507
+ MESSAGE(FATAL_ERROR "The PCRE2_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".")
508
+ ENDIF(NEWLINE_DEFAULT STREQUAL "")
509
+
510
+ IF(PCRE2_EBCDIC)
511
+ SET(EBCDIC 1)
512
+ ENDIF(PCRE2_EBCDIC)
513
+
514
+ IF(PCRE2_EBCDIC_NL25)
515
+ SET(EBCDIC 1)
516
+ SET(EBCDIC_NL25 1)
517
+ ENDIF(PCRE2_EBCDIC_NL25)
518
+
519
+ # Output files
520
+
521
+ CONFIGURE_FILE(config-cmake.h.in
522
+ ${PROJECT_BINARY_DIR}/config.h
523
+ @ONLY)
524
+
525
+ # Parse version numbers and date out of configure.ac
526
+
527
+ file(STRINGS ${PROJECT_SOURCE_DIR}/configure.ac
528
+ configure_lines
529
+ LIMIT_COUNT 50 # Read only the first 50 lines of the file
530
+ )
531
+
532
+ set(SEARCHED_VARIABLES "pcre2_major" "pcre2_minor" "pcre2_prerelease" "pcre2_date"
533
+ "libpcre2_posix_version" "libpcre2_8_version" "libpcre2_16_version" "libpcre2_32_version")
534
+ foreach(configure_line ${configure_lines})
535
+ foreach(_substitution_variable ${SEARCHED_VARIABLES})
536
+ string(TOUPPER ${_substitution_variable} _substitution_variable_upper)
537
+ if (NOT ${_substitution_variable_upper})
538
+ string(REGEX MATCH "m4_define\\(${_substitution_variable}, *\\[(.*)\\]" MATCHED_STRING ${configure_line})
539
+ if (CMAKE_MATCH_1)
540
+ set(${_substitution_variable_upper} ${CMAKE_MATCH_1})
541
+ endif()
542
+ endif()
543
+ endforeach()
544
+ endforeach()
545
+
546
+ macro(PARSE_LIB_VERSION VARIABLE_PREFIX)
547
+ string(REPLACE ":" ";" ${VARIABLE_PREFIX}_VERSION_LIST ${${VARIABLE_PREFIX}_VERSION})
548
+ list(GET ${VARIABLE_PREFIX}_VERSION_LIST 0 ${VARIABLE_PREFIX}_VERSION_CURRENT)
549
+ list(GET ${VARIABLE_PREFIX}_VERSION_LIST 1 ${VARIABLE_PREFIX}_VERSION_REVISION)
550
+ list(GET ${VARIABLE_PREFIX}_VERSION_LIST 2 ${VARIABLE_PREFIX}_VERSION_AGE)
551
+
552
+ math(EXPR ${VARIABLE_PREFIX}_SOVERSION "${${VARIABLE_PREFIX}_VERSION_CURRENT} - ${${VARIABLE_PREFIX}_VERSION_AGE}")
553
+ math(EXPR ${VARIABLE_PREFIX}_MACHO_COMPATIBILITY_VERSION "${${VARIABLE_PREFIX}_VERSION_CURRENT} + 1")
554
+ math(EXPR ${VARIABLE_PREFIX}_MACHO_CURRENT_VERSION "${${VARIABLE_PREFIX}_VERSION_CURRENT} + 1")
555
+ set(${VARIABLE_PREFIX}_MACHO_CURRENT_VERSION "${${VARIABLE_PREFIX}_MACHO_CURRENT_VERSION}.${${VARIABLE_PREFIX}_VERSION_REVISION}}")
556
+ set(${VARIABLE_PREFIX}_VERSION "${${VARIABLE_PREFIX}_SOVERSION}.${${VARIABLE_PREFIX}_VERSION_AGE}.${${VARIABLE_PREFIX}_VERSION_REVISION}")
557
+ endmacro()
558
+
559
+ PARSE_LIB_VERSION(LIBPCRE2_POSIX)
560
+ PARSE_LIB_VERSION(LIBPCRE2_8)
561
+ PARSE_LIB_VERSION(LIBPCRE2_16)
562
+ PARSE_LIB_VERSION(LIBPCRE2_32)
563
+
564
+ CONFIGURE_FILE(src/pcre2.h.in
565
+ ${PROJECT_BINARY_DIR}/pcre2.h
566
+ @ONLY)
567
+
568
+ # Make sure to not link debug libs
569
+ # against release libs and vice versa
570
+ IF(WIN32)
571
+ SET(CMAKE_DEBUG_POSTFIX "d")
572
+ ENDIF(WIN32)
573
+
574
+ # Character table generation
575
+
576
+ OPTION(PCRE2_REBUILD_CHARTABLES "Rebuild char tables" OFF)
577
+ IF(PCRE2_REBUILD_CHARTABLES)
578
+ ADD_EXECUTABLE(pcre2_dftables src/pcre2_dftables.c)
579
+ ADD_CUSTOM_COMMAND(
580
+ COMMENT "Generating character tables (pcre2_chartables.c) for current locale"
581
+ DEPENDS pcre2_dftables
582
+ COMMAND pcre2_dftables
583
+ ARGS ${PROJECT_BINARY_DIR}/pcre2_chartables.c
584
+ OUTPUT ${PROJECT_BINARY_DIR}/pcre2_chartables.c
585
+ )
586
+ ELSE(PCRE2_REBUILD_CHARTABLES)
587
+ CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/src/pcre2_chartables.c.dist
588
+ ${PROJECT_BINARY_DIR}/pcre2_chartables.c
589
+ COPYONLY)
590
+ ENDIF(PCRE2_REBUILD_CHARTABLES)
591
+
592
+ # Source code
593
+
594
+ SET(PCRE2_HEADERS ${PROJECT_BINARY_DIR}/pcre2.h)
595
+
596
+ SET(PCRE2_SOURCES
597
+ src/pcre2_auto_possess.c
598
+ ${PROJECT_BINARY_DIR}/pcre2_chartables.c
599
+ src/pcre2_chkdint.c
600
+ src/pcre2_compile.c
601
+ src/pcre2_config.c
602
+ src/pcre2_context.c
603
+ src/pcre2_convert.c
604
+ src/pcre2_dfa_match.c
605
+ src/pcre2_error.c
606
+ src/pcre2_extuni.c
607
+ src/pcre2_find_bracket.c
608
+ src/pcre2_jit_compile.c
609
+ src/pcre2_maketables.c
610
+ src/pcre2_match.c
611
+ src/pcre2_match_data.c
612
+ src/pcre2_newline.c
613
+ src/pcre2_ord2utf.c
614
+ src/pcre2_pattern_info.c
615
+ src/pcre2_script_run.c
616
+ src/pcre2_serialize.c
617
+ src/pcre2_string_utils.c
618
+ src/pcre2_study.c
619
+ src/pcre2_substitute.c
620
+ src/pcre2_substring.c
621
+ src/pcre2_tables.c
622
+ src/pcre2_ucd.c
623
+ src/pcre2_valid_utf.c
624
+ src/pcre2_xclass.c
625
+ )
626
+
627
+ SET(PCRE2POSIX_HEADERS src/pcre2posix.h)
628
+ SET(PCRE2POSIX_SOURCES src/pcre2posix.c)
629
+
630
+ IF(MINGW AND BUILD_SHARED_LIBS)
631
+ IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2.rc)
632
+ ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcre2.o
633
+ PRE-LINK
634
+ COMMAND windres ARGS pcre2.rc pcre2.o
635
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
636
+ COMMENT Using pcre2 coff info in mingw build)
637
+ SET(PCRE2_SOURCES ${PCRE2_SOURCES} ${PROJECT_SOURCE_DIR}/pcre2.o)
638
+ ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre2.rc)
639
+
640
+ IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2posix.rc)
641
+ ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcre2posix.o
642
+ PRE-LINK
643
+ COMMAND windres ARGS pcre2posix.rc pcre2posix.o
644
+ WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
645
+ COMMENT Using pcre2posix coff info in mingw build)
646
+ SET(PCRE2POSIX_SOURCES ${PCRE2POSIX_SOURCES} ${PROJECT_SOURCE_DIR}/pcre2posix.o)
647
+ ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre2posix.rc)
648
+ ENDIF(MINGW AND BUILD_SHARED_LIBS)
649
+
650
+ IF(MSVC AND BUILD_SHARED_LIBS)
651
+ SET(dll_pdb_files ${PROJECT_BINARY_DIR}/pcre2-posix.pdb ${dll_pdb_files})
652
+ SET(dll_pdb_debug_files ${PROJECT_BINARY_DIR}/pcre2-posixd.pdb ${dll_pdb_debug_files})
653
+ IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2.rc)
654
+ SET(PCRE2_SOURCES ${PCRE2_SOURCES} pcre2.rc)
655
+ ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre2.rc)
656
+
657
+ IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2posix.rc)
658
+ SET(PCRE2POSIX_SOURCES ${PCRE2POSIX_SOURCES} pcre2posix.rc)
659
+ ENDIF (EXISTS ${PROJECT_SOURCE_DIR}/pcre2posix.rc)
660
+ ENDIF(MSVC AND BUILD_SHARED_LIBS)
661
+
662
+ # Fix static compilation with MSVC: https://bugs.exim.org/show_bug.cgi?id=1681
663
+ # This code was taken from the CMake wiki, not from WebM.
664
+
665
+ IF(MSVC AND PCRE2_STATIC_RUNTIME)
666
+ MESSAGE(STATUS "** MSVC and PCRE2_STATIC_RUNTIME: modifying compiler flags to use static runtime library")
667
+ foreach(flag_var
668
+ CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
669
+ CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
670
+ string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
671
+ endforeach()
672
+ ENDIF(MSVC AND PCRE2_STATIC_RUNTIME)
673
+
674
+ # Build setup
675
+
676
+ ADD_DEFINITIONS(-DHAVE_CONFIG_H)
677
+
678
+ IF(MSVC)
679
+ ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS)
680
+ ENDIF(MSVC)
681
+
682
+ SET(CMAKE_INCLUDE_CURRENT_DIR 1)
683
+
684
+ set(targets)
685
+
686
+ # 8-bit library
687
+
688
+ IF(PCRE2_BUILD_PCRE2_8)
689
+ IF(BUILD_STATIC_LIBS)
690
+ ADD_LIBRARY(pcre2-8-static STATIC ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
691
+ SET_TARGET_PROPERTIES(pcre2-8-static PROPERTIES
692
+ COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8
693
+ MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_8_MACHO_COMPATIBILITY_VERSION}"
694
+ MACHO_CURRENT_VERSION "${LIBPCRE2_8_MACHO_CURRENT_VERSION}"
695
+ VERSION ${LIBPCRE2_8_VERSION}
696
+ SOVERSION ${LIBPCRE2_8_SOVERSION})
697
+ TARGET_COMPILE_DEFINITIONS(pcre2-8-static PUBLIC PCRE2_STATIC)
698
+ TARGET_INCLUDE_DIRECTORIES(pcre2-8-static PUBLIC ${PROJECT_BINARY_DIR})
699
+ IF(REQUIRE_PTHREAD)
700
+ TARGET_LINK_LIBRARIES(pcre2-8-static Threads::Threads)
701
+ ENDIF(REQUIRE_PTHREAD)
702
+ SET(targets ${targets} pcre2-8-static)
703
+ ADD_LIBRARY(pcre2-posix-static STATIC ${PCRE2POSIX_HEADERS} ${PCRE2POSIX_SOURCES})
704
+ SET_TARGET_PROPERTIES(pcre2-posix-static PROPERTIES
705
+ COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8
706
+ MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_POSIX_MACHO_COMPATIBILITY_VERSION}"
707
+ MACHO_CURRENT_VERSION "${LIBPCRE2_POSIX_MACHO_CURRENT_VERSION}"
708
+ VERSION ${LIBPCRE2_POSIX_VERSION}
709
+ SOVERSION ${LIBPCRE2_POSIX_SOVERSION})
710
+ TARGET_LINK_LIBRARIES(pcre2-posix-static pcre2-8-static)
711
+ TARGET_INCLUDE_DIRECTORIES(pcre2-posix-static PUBLIC ${PROJECT_SOURCE_DIR}/src)
712
+ set(targets ${targets} pcre2-posix-static)
713
+
714
+ IF(MSVC)
715
+ SET_TARGET_PROPERTIES(pcre2-8-static PROPERTIES OUTPUT_NAME pcre2-8-static)
716
+ SET_TARGET_PROPERTIES(pcre2-posix-static PROPERTIES OUTPUT_NAME pcre2-posix-static)
717
+ ELSE(MSVC)
718
+ SET_TARGET_PROPERTIES(pcre2-8-static PROPERTIES OUTPUT_NAME pcre2-8)
719
+ SET_TARGET_PROPERTIES(pcre2-posix-static PROPERTIES OUTPUT_NAME pcre2-posix)
720
+ ENDIF(MSVC)
721
+ IF(PCRE2_STATIC_PIC)
722
+ SET_TARGET_PROPERTIES(pcre2-8-static pcre2-posix-static PROPERTIES POSITION_INDEPENDENT_CODE 1)
723
+ ENDIF(PCRE2_STATIC_PIC)
724
+ ENDIF(BUILD_STATIC_LIBS)
725
+
726
+ IF(BUILD_SHARED_LIBS)
727
+ ADD_LIBRARY(pcre2-8-shared SHARED ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
728
+ TARGET_INCLUDE_DIRECTORIES(pcre2-8-shared PUBLIC ${PROJECT_BINARY_DIR})
729
+ SET_TARGET_PROPERTIES(pcre2-8-shared PROPERTIES
730
+ COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8
731
+ MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_8_MACHO_COMPATIBILITY_VERSION}"
732
+ MACHO_CURRENT_VERSION "${LIBPCRE2_8_MACHO_CURRENT_VERSION}"
733
+ VERSION ${LIBPCRE2_8_VERSION}
734
+ SOVERSION ${LIBPCRE2_8_SOVERSION}
735
+ OUTPUT_NAME pcre2-8)
736
+ IF(REQUIRE_PTHREAD)
737
+ TARGET_LINK_LIBRARIES(pcre2-8-shared Threads::Threads)
738
+ ENDIF(REQUIRE_PTHREAD)
739
+ set(targets ${targets} pcre2-8-shared)
740
+
741
+ ADD_LIBRARY(pcre2-posix-shared SHARED ${PCRE2POSIX_HEADERS} ${PCRE2POSIX_SOURCES})
742
+ TARGET_INCLUDE_DIRECTORIES(pcre2-posix-shared PUBLIC ${PROJECT_SOURCE_DIR}/src)
743
+ SET_TARGET_PROPERTIES(pcre2-posix-shared PROPERTIES
744
+ COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8
745
+ MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_POSIX_MACHO_COMPATIBILITY_VERSION}"
746
+ MACHO_CURRENT_VERSION "${LIBPCRE2_POSIX_MACHO_CURRENT_VERSION}"
747
+ VERSION ${LIBPCRE2_POSIX_VERSION}
748
+ SOVERSION ${LIBPCRE2_POSIX_SOVERSION}
749
+ OUTPUT_NAME pcre2-posix)
750
+ set(PCRE2POSIX_CFLAG "-DPCRE2POSIX_SHARED")
751
+ TARGET_COMPILE_DEFINITIONS(pcre2-posix-shared PUBLIC ${PCRE2POSIX_CFLAG})
752
+ TARGET_LINK_LIBRARIES(pcre2-posix-shared pcre2-8-shared)
753
+ SET(targets ${targets} pcre2-posix-shared)
754
+ SET(dll_pdb_files ${PROJECT_BINARY_DIR}/pcre2-8.pdb ${dll_pdb_files})
755
+ SET(dll_pdb_debug_files ${PROJECT_BINARY_DIR}/pcre2-8d.pdb ${dll_pdb_debug_files})
756
+
757
+ IF(MINGW)
758
+ IF(NON_STANDARD_LIB_PREFIX)
759
+ SET_TARGET_PROPERTIES(pcre2-8-shared pcre2-posix-shared PROPERTIES PREFIX "")
760
+ ENDIF(NON_STANDARD_LIB_PREFIX)
761
+ IF(NON_STANDARD_LIB_SUFFIX)
762
+ SET_TARGET_PROPERTIES(pcre2-8-shared pcre2-posix-shared PROPERTIES SUFFIX "-0.dll")
763
+ ENDIF(NON_STANDARD_LIB_SUFFIX)
764
+ ENDIF(MINGW)
765
+ ENDIF(BUILD_SHARED_LIBS)
766
+
767
+ IF(BUILD_STATIC_LIBS)
768
+ ADD_LIBRARY(pcre2-8 ALIAS pcre2-8-static)
769
+ ADD_LIBRARY(pcre2-posix ALIAS pcre2-posix-static)
770
+ ELSE(BUILD_STATIC_LIBS)
771
+ ADD_LIBRARY(pcre2-8 ALIAS pcre2-8-shared)
772
+ ADD_LIBRARY(pcre2-posix ALIAS pcre2-posix-shared)
773
+ ENDIF(BUILD_STATIC_LIBS)
774
+ ENDIF(PCRE2_BUILD_PCRE2_8)
775
+
776
+ # 16-bit library
777
+
778
+ IF(PCRE2_BUILD_PCRE2_16)
779
+ IF(BUILD_STATIC_LIBS)
780
+ ADD_LIBRARY(pcre2-16-static STATIC ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
781
+ TARGET_INCLUDE_DIRECTORIES(pcre2-16-static PUBLIC ${PROJECT_BINARY_DIR})
782
+ SET_TARGET_PROPERTIES(pcre2-16-static PROPERTIES UNITY_BUILD OFF
783
+ COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=16
784
+ MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_32_MACHO_COMPATIBILITY_VERSION}"
785
+ MACHO_CURRENT_VERSION "${LIBPCRE2_32_MACHO_CURRENT_VERSION}"
786
+ VERSION ${LIBPCRE2_16_VERSION}
787
+ SOVERSION ${LIBPCRE2_16_SOVERSION})
788
+ TARGET_COMPILE_DEFINITIONS(pcre2-16-static PUBLIC PCRE2_STATIC)
789
+ IF(REQUIRE_PTHREAD)
790
+ TARGET_LINK_LIBRARIES(pcre2-16-static Threads::Threads)
791
+ ENDIF(REQUIRE_PTHREAD)
792
+ set(targets ${targets} pcre2-16-static)
793
+
794
+ IF(MSVC)
795
+ SET_TARGET_PROPERTIES(pcre2-16-static PROPERTIES OUTPUT_NAME pcre2-16-static)
796
+ ELSE(MSVC)
797
+ SET_TARGET_PROPERTIES(pcre2-16-static PROPERTIES OUTPUT_NAME pcre2-16)
798
+ ENDIF(MSVC)
799
+ IF(PCRE2_STATIC_PIC)
800
+ SET_TARGET_PROPERTIES(pcre2-16-static PROPERTIES POSITION_INDEPENDENT_CODE 1)
801
+ ENDIF(PCRE2_STATIC_PIC)
802
+ ENDIF(BUILD_STATIC_LIBS)
803
+
804
+ IF(BUILD_SHARED_LIBS)
805
+ ADD_LIBRARY(pcre2-16-shared SHARED ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
806
+ TARGET_INCLUDE_DIRECTORIES(pcre2-16-shared PUBLIC ${PROJECT_BINARY_DIR})
807
+ SET_TARGET_PROPERTIES(pcre2-16-shared PROPERTIES UNITY_BUILD OFF
808
+ COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=16
809
+ MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_32_MACHO_COMPATIBILITY_VERSION}"
810
+ MACHO_CURRENT_VERSION "${LIBPCRE2_32_MACHO_CURRENT_VERSION}"
811
+ VERSION ${LIBPCRE2_16_VERSION}
812
+ SOVERSION ${LIBPCRE2_16_SOVERSION}
813
+ OUTPUT_NAME pcre2-16)
814
+ IF(REQUIRE_PTHREAD)
815
+ TARGET_LINK_LIBRARIES(pcre2-16-shared Threads::Threads)
816
+ ENDIF(REQUIRE_PTHREAD)
817
+ set(targets ${targets} pcre2-16-shared)
818
+ SET(dll_pdb_files ${PROJECT_BINARY_DIR}/pcre2-16.pdb ${dll_pdb_files})
819
+ SET(dll_pdb_debug_files ${PROJECT_BINARY_DIR}/pcre2-16d.pdb ${dll_pdb_debug_files})
820
+
821
+ IF(MINGW)
822
+ IF(NON_STANDARD_LIB_PREFIX)
823
+ SET_TARGET_PROPERTIES(pcre2-16-shared PROPERTIES PREFIX "")
824
+ ENDIF(NON_STANDARD_LIB_PREFIX)
825
+ IF(NON_STANDARD_LIB_SUFFIX)
826
+ SET_TARGET_PROPERTIES(pcre2-16-shared PROPERTIES SUFFIX "-0.dll")
827
+ ENDIF(NON_STANDARD_LIB_SUFFIX)
828
+ ENDIF(MINGW)
829
+ ENDIF(BUILD_SHARED_LIBS)
830
+
831
+ IF(BUILD_STATIC_LIBS)
832
+ ADD_LIBRARY(pcre2-16 ALIAS pcre2-16-static)
833
+ ELSE(BUILD_STATIC_LIBS)
834
+ ADD_LIBRARY(pcre2-16 ALIAS pcre2-16-shared)
835
+ ENDIF(BUILD_STATIC_LIBS)
836
+ ENDIF(PCRE2_BUILD_PCRE2_16)
837
+
838
+ # 32-bit library
839
+
840
+ IF(PCRE2_BUILD_PCRE2_32)
841
+ IF(BUILD_STATIC_LIBS)
842
+ ADD_LIBRARY(pcre2-32-static STATIC ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
843
+ TARGET_INCLUDE_DIRECTORIES(pcre2-32-static PUBLIC ${PROJECT_BINARY_DIR})
844
+ SET_TARGET_PROPERTIES(pcre2-32-static PROPERTIES UNITY_BUILD OFF
845
+ COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=32
846
+ MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_32_MACHO_COMPATIBILITY_VERSION}"
847
+ MACHO_CURRENT_VERSION "${LIBPCRE2_32_MACHO_CURRENT_VERSION}"
848
+ VERSION ${LIBPCRE2_32_VERSION}
849
+ SOVERSION ${LIBPCRE2_32_SOVERSION})
850
+ TARGET_COMPILE_DEFINITIONS(pcre2-32-static PUBLIC PCRE2_STATIC)
851
+ IF(REQUIRE_PTHREAD)
852
+ TARGET_LINK_LIBRARIES(pcre2-32-static Threads::Threads)
853
+ ENDIF(REQUIRE_PTHREAD)
854
+ set(targets ${targets} pcre2-32-static)
855
+
856
+ IF(MSVC)
857
+ SET_TARGET_PROPERTIES(pcre2-32-static PROPERTIES OUTPUT_NAME pcre2-32-static)
858
+ ELSE(MSVC)
859
+ SET_TARGET_PROPERTIES(pcre2-32-static PROPERTIES OUTPUT_NAME pcre2-32)
860
+ ENDIF(MSVC)
861
+ IF(PCRE2_STATIC_PIC)
862
+ SET_TARGET_PROPERTIES(pcre2-32-static PROPERTIES POSITION_INDEPENDENT_CODE 1)
863
+ ENDIF(PCRE2_STATIC_PIC)
864
+ ENDIF(BUILD_STATIC_LIBS)
865
+
866
+ IF(BUILD_SHARED_LIBS)
867
+ ADD_LIBRARY(pcre2-32-shared SHARED ${PCRE2_HEADERS} ${PCRE2_SOURCES} ${PROJECT_BINARY_DIR}/config.h)
868
+ TARGET_INCLUDE_DIRECTORIES(pcre2-32-shared PUBLIC ${PROJECT_BINARY_DIR})
869
+ SET_TARGET_PROPERTIES(pcre2-32-shared PROPERTIES UNITY_BUILD OFF
870
+ COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=32
871
+ MACHO_COMPATIBILITY_VERSION "${LIBPCRE2_32_MACHO_COMPATIBILITY_VERSION}"
872
+ MACHO_CURRENT_VERSION "${LIBPCRE2_32_MACHO_CURRENT_VERSION}"
873
+ VERSION ${LIBPCRE2_32_VERSION}
874
+ SOVERSION ${LIBPCRE2_32_SOVERSION}
875
+ OUTPUT_NAME pcre2-32)
876
+ IF(REQUIRE_PTHREAD)
877
+ TARGET_LINK_LIBRARIES(pcre2-32-shared Threads::Threads)
878
+ ENDIF(REQUIRE_PTHREAD)
879
+ set(targets ${targets} pcre2-32-shared)
880
+ SET(dll_pdb_files ${PROJECT_BINARY_DIR}/pcre2-32.pdb ${dll_pdb_files})
881
+ SET(dll_pdb_debug_files ${PROJECT_BINARY_DIR}/pcre2-32d.pdb ${dll_pdb_debug_files})
882
+
883
+ IF(MINGW)
884
+ IF(NON_STANDARD_LIB_PREFIX)
885
+ SET_TARGET_PROPERTIES(pcre2-32-shared PROPERTIES PREFIX "")
886
+ ENDIF(NON_STANDARD_LIB_PREFIX)
887
+ IF(NON_STANDARD_LIB_SUFFIX)
888
+ SET_TARGET_PROPERTIES(pcre2-32-shared PROPERTIES SUFFIX "-0.dll")
889
+ ENDIF(NON_STANDARD_LIB_SUFFIX)
890
+ ENDIF(MINGW)
891
+ ENDIF(BUILD_SHARED_LIBS)
892
+
893
+ IF(BUILD_STATIC_LIBS)
894
+ ADD_LIBRARY(pcre2-32 ALIAS pcre2-32-static)
895
+ ELSE(BUILD_STATIC_LIBS)
896
+ ADD_LIBRARY(pcre2-32 ALIAS pcre2-32-shared)
897
+ ENDIF(BUILD_STATIC_LIBS)
898
+ ENDIF(PCRE2_BUILD_PCRE2_32)
899
+
900
+ # Generate pkg-config files
901
+
902
+ set(PACKAGE_VERSION "${PCRE2_MAJOR}.${PCRE2_MINOR}")
903
+ set(prefix ${CMAKE_INSTALL_PREFIX})
904
+
905
+ set(exec_prefix "\${prefix}")
906
+ set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
907
+ set(includedir "\${prefix}/include")
908
+ if(WIN32 AND (CMAKE_BUILD_TYPE MATCHES Debug))
909
+ set(LIB_POSTFIX ${CMAKE_DEBUG_POSTFIX})
910
+ endif()
911
+
912
+ if(PCRE2_BUILD_PCRE2_8)
913
+ configure_file(libpcre2-posix.pc.in libpcre2-posix.pc @ONLY)
914
+ list(APPEND pkg_config_files "${CMAKE_CURRENT_BINARY_DIR}/libpcre2-posix.pc")
915
+ configure_file(libpcre2-8.pc.in libpcre2-8.pc @ONLY)
916
+ list(APPEND pkg_config_files "${CMAKE_CURRENT_BINARY_DIR}/libpcre2-8.pc")
917
+ set(enable_pcre2_8 "yes")
918
+ else()
919
+ set(enable_pcre2_8 "no")
920
+ endif()
921
+
922
+ if(PCRE2_BUILD_PCRE2_16)
923
+ configure_file(libpcre2-16.pc.in libpcre2-16.pc @ONLY)
924
+ list(APPEND pkg_config_files "${CMAKE_CURRENT_BINARY_DIR}/libpcre2-16.pc")
925
+ set(enable_pcre2_16 "yes")
926
+ else()
927
+ set(enable_pcre2_16 "no")
928
+ endif()
929
+
930
+ if(PCRE2_BUILD_PCRE2_32)
931
+ configure_file(libpcre2-32.pc.in libpcre2-32.pc @ONLY)
932
+ list(APPEND pkg_config_files "${CMAKE_CURRENT_BINARY_DIR}/libpcre2-32.pc")
933
+ set(enable_pcre2_32 "yes")
934
+ else()
935
+ set(enable_pcre2_32 "no")
936
+ endif()
937
+
938
+ configure_file(pcre2-config.in pcre2-config @ONLY NEWLINE_STYLE LF)
939
+
940
+ # Executables
941
+
942
+ IF(PCRE2_BUILD_PCRE2GREP)
943
+ ADD_EXECUTABLE(pcre2grep src/pcre2grep.c)
944
+ SET_PROPERTY(TARGET pcre2grep
945
+ PROPERTY COMPILE_DEFINITIONS PCRE2_CODE_UNIT_WIDTH=8)
946
+ set(targets ${targets} pcre2grep)
947
+ TARGET_LINK_LIBRARIES(pcre2grep pcre2-posix ${PCRE2GREP_LIBS})
948
+ ENDIF(PCRE2_BUILD_PCRE2GREP)
949
+
950
+ # Testing
951
+
952
+ IF(PCRE2_BUILD_TESTS)
953
+ ENABLE_TESTING()
954
+
955
+ SET(PCRE2TEST_SOURCES src/pcre2test.c)
956
+
957
+ IF(MSVC)
958
+ # This is needed to avoid a stack overflow error in the standard tests. The
959
+ # flag should be indicated with a forward-slash instead of a hyphen, but
960
+ # then CMake treats it as a file path.
961
+ SET(PCRE2TEST_LINKER_FLAGS -STACK:2500000)
962
+ ENDIF(MSVC)
963
+
964
+ ADD_EXECUTABLE(pcre2test ${PCRE2TEST_SOURCES})
965
+ set(targets ${targets} pcre2test)
966
+ IF(PCRE2_BUILD_PCRE2_8)
967
+ LIST(APPEND PCRE2TEST_LIBS pcre2-posix pcre2-8)
968
+ ENDIF(PCRE2_BUILD_PCRE2_8)
969
+ IF(PCRE2_BUILD_PCRE2_16)
970
+ LIST(APPEND PCRE2TEST_LIBS pcre2-16)
971
+ ENDIF(PCRE2_BUILD_PCRE2_16)
972
+ IF(PCRE2_BUILD_PCRE2_32)
973
+ LIST(APPEND PCRE2TEST_LIBS pcre2-32)
974
+ ENDIF(PCRE2_BUILD_PCRE2_32)
975
+ TARGET_LINK_LIBRARIES(pcre2test ${PCRE2TEST_LIBS} ${PCRE2TEST_LINKER_FLAGS})
976
+
977
+ IF(PCRE2_BUILD_PCRE2_8)
978
+ ADD_EXECUTABLE(pcre2posix_test src/pcre2posix_test.c)
979
+ TARGET_LINK_LIBRARIES(pcre2posix_test pcre2-posix pcre2-8)
980
+ ENDIF(PCRE2_BUILD_PCRE2_8)
981
+
982
+ IF(PCRE2_SUPPORT_JIT)
983
+ ADD_EXECUTABLE(pcre2_jit_test src/pcre2_jit_test.c)
984
+ SET(PCRE2_JIT_TEST_LIBS)
985
+ IF(PCRE2_BUILD_PCRE2_8)
986
+ LIST(APPEND PCRE2_JIT_TEST_LIBS pcre2-8)
987
+ ENDIF(PCRE2_BUILD_PCRE2_8)
988
+ IF(PCRE2_BUILD_PCRE2_16)
989
+ LIST(APPEND PCRE2_JIT_TEST_LIBS pcre2-16)
990
+ ENDIF(PCRE2_BUILD_PCRE2_16)
991
+ IF(PCRE2_BUILD_PCRE2_32)
992
+ LIST(APPEND PCRE2_JIT_TEST_LIBS pcre2-32)
993
+ ENDIF(PCRE2_BUILD_PCRE2_32)
994
+ TARGET_LINK_LIBRARIES(pcre2_jit_test ${PCRE2_JIT_TEST_LIBS})
995
+ ENDIF(PCRE2_SUPPORT_JIT)
996
+
997
+ # exes in Debug location tested by the RunTest and RunGrepTest shell scripts
998
+ # via "make test"
999
+
1000
+ # The commented out code below provokes a warning about future removal
1001
+ # of the facility, and requires policy CMP0026 to be set to "OLD". I have
1002
+ # got fed-up with the warnings, but my plea for help on the mailing list
1003
+ # produced no response. So, I've hacked. The new code below seems to work on
1004
+ # Linux.
1005
+
1006
+ # IF(PCRE2_BUILD_PCRE2GREP)
1007
+ # GET_TARGET_PROPERTY(PCRE2GREP_EXE pcre2grep DEBUG_LOCATION)
1008
+ # ENDIF(PCRE2_BUILD_PCRE2GREP)
1009
+ #
1010
+ # GET_TARGET_PROPERTY(PCRE2TEST_EXE pcre2test DEBUG_LOCATION)
1011
+
1012
+ IF(PCRE2_BUILD_PCRE2GREP)
1013
+ SET(PCRE2GREP_EXE $<TARGET_FILE:pcre2grep>)
1014
+ ENDIF(PCRE2_BUILD_PCRE2GREP)
1015
+
1016
+ SET(PCRE2TEST_EXE $<TARGET_FILE:pcre2test>)
1017
+
1018
+
1019
+ # =================================================
1020
+ # Write out a CTest configuration file
1021
+ #
1022
+ FILE(WRITE ${PROJECT_BINARY_DIR}/CTestCustom.ctest
1023
+ "# This is a generated file.
1024
+ MESSAGE(\"When testing is complete, review test output in the
1025
+ \\\"${PROJECT_BINARY_DIR}/Testing/Temporary\\\" folder.\")
1026
+ MESSAGE(\" \")
1027
+ ")
1028
+
1029
+ FILE(WRITE ${PROJECT_BINARY_DIR}/pcre2_test.sh
1030
+ "#! /bin/sh
1031
+ # This is a generated file.
1032
+ srcdir=${PROJECT_SOURCE_DIR}
1033
+ . ${PROJECT_SOURCE_DIR}/RunTest
1034
+ if test \"$?\" != \"0\"; then exit 1; fi
1035
+ # End
1036
+ ")
1037
+
1038
+ IF(UNIX)
1039
+ ADD_TEST(pcre2_test sh ${PROJECT_BINARY_DIR}/pcre2_test.sh)
1040
+ ENDIF(UNIX)
1041
+
1042
+ IF(PCRE2_BUILD_PCRE2GREP)
1043
+ FILE(WRITE ${PROJECT_BINARY_DIR}/pcre2_grep_test.sh
1044
+ "#! /bin/sh
1045
+ # This is a generated file.
1046
+ srcdir=${PROJECT_SOURCE_DIR}
1047
+ . ${PROJECT_SOURCE_DIR}/RunGrepTest
1048
+ if test \"$?\" != \"0\"; then exit 1; fi
1049
+ # End
1050
+ ")
1051
+
1052
+ IF(UNIX)
1053
+ ADD_TEST(pcre2_grep_test sh ${PROJECT_BINARY_DIR}/pcre2_grep_test.sh)
1054
+ ENDIF(UNIX)
1055
+ ENDIF(PCRE2_BUILD_PCRE2GREP)
1056
+
1057
+ IF(WIN32)
1058
+ # Provide environment for executing the bat file version of RunTest
1059
+ FILE(TO_NATIVE_PATH ${PROJECT_SOURCE_DIR} winsrc)
1060
+ FILE(TO_NATIVE_PATH ${PROJECT_BINARY_DIR} winbin)
1061
+ FILE(TO_NATIVE_PATH ${PCRE2TEST_EXE} winexe)
1062
+
1063
+ FILE(WRITE ${PROJECT_BINARY_DIR}/pcre2_test.bat
1064
+ "\@REM This is a generated file.
1065
+ \@echo off
1066
+ setlocal
1067
+ SET srcdir=\"${winsrc}\"
1068
+ # The next line was replaced by the following one after a user comment.
1069
+ # SET pcre2test=\"${winexe}\"
1070
+ SET pcre2test=\"${winbin}\\pcre2test.exe\"
1071
+ if not [%CMAKE_CONFIG_TYPE%]==[] SET pcre2test=\"${winbin}\\%CMAKE_CONFIG_TYPE%\\pcre2test.exe\"
1072
+ call %srcdir%\\RunTest.Bat
1073
+ if errorlevel 1 exit /b 1
1074
+ echo RunTest.bat tests successfully completed
1075
+ ")
1076
+
1077
+ ADD_TEST(NAME pcre2_test_bat
1078
+ COMMAND pcre2_test.bat)
1079
+ SET_TESTS_PROPERTIES(pcre2_test_bat PROPERTIES
1080
+ PASS_REGULAR_EXPRESSION "RunTest\\.bat tests successfully completed")
1081
+
1082
+ IF("$ENV{OSTYPE}" STREQUAL "msys")
1083
+ # Both the sh and bat file versions of RunTest are run if make test is used
1084
+ # in msys
1085
+ ADD_TEST(pcre2_test_sh sh.exe ${PROJECT_BINARY_DIR}/pcre2_test.sh)
1086
+ IF(PCRE2_BUILD_PCRE2GREP)
1087
+ ADD_TEST(pcre2_grep_test sh.exe ${PROJECT_BINARY_DIR}/pcre2_grep_test.sh)
1088
+ ENDIF(PCRE2_BUILD_PCRE2GREP)
1089
+ ENDIF("$ENV{OSTYPE}" STREQUAL "msys")
1090
+ ENDIF(WIN32)
1091
+
1092
+ # Changed to accommodate testing whichever location was just built
1093
+
1094
+ IF(PCRE2_SUPPORT_JIT)
1095
+ ADD_TEST(pcre2_jit_test pcre2_jit_test)
1096
+ ENDIF(PCRE2_SUPPORT_JIT)
1097
+
1098
+ IF(PCRE2_BUILD_PCRE2_8)
1099
+ ADD_TEST(pcre2posix_test pcre2posix_test)
1100
+ ENDIF(PCRE2_BUILD_PCRE2_8)
1101
+
1102
+ ENDIF(PCRE2_BUILD_TESTS)
1103
+
1104
+ # Installation
1105
+
1106
+ SET(CMAKE_INSTALL_ALWAYS 1)
1107
+
1108
+ INSTALL(TARGETS ${targets}
1109
+ RUNTIME DESTINATION bin
1110
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
1111
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
1112
+ INSTALL(FILES ${pkg_config_files} DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
1113
+ INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/pcre2-config"
1114
+ DESTINATION bin
1115
+ # Set 0755 permissions
1116
+ PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
1117
+
1118
+ INSTALL(FILES ${PCRE2_HEADERS} ${PCRE2POSIX_HEADERS} DESTINATION include)
1119
+
1120
+ # CMake config files.
1121
+ set(PCRE2_CONFIG_IN ${CMAKE_CURRENT_SOURCE_DIR}/cmake/pcre2-config.cmake.in)
1122
+ set(PCRE2_CONFIG_OUT ${CMAKE_CURRENT_BINARY_DIR}/cmake/pcre2-config.cmake)
1123
+ configure_file(${PCRE2_CONFIG_IN} ${PCRE2_CONFIG_OUT} @ONLY)
1124
+ set(PCRE2_CONFIG_VERSION_IN ${CMAKE_CURRENT_SOURCE_DIR}/cmake/pcre2-config-version.cmake.in)
1125
+ set(PCRE2_CONFIG_VERSION_OUT ${CMAKE_CURRENT_BINARY_DIR}/cmake/pcre2-config-version.cmake)
1126
+ configure_file(${PCRE2_CONFIG_VERSION_IN} ${PCRE2_CONFIG_VERSION_OUT} @ONLY)
1127
+ install(FILES ${PCRE2_CONFIG_OUT} ${PCRE2_CONFIG_VERSION_OUT} DESTINATION cmake)
1128
+
1129
+ FILE(GLOB html ${PROJECT_SOURCE_DIR}/doc/html/*.html)
1130
+ FILE(GLOB man1 ${PROJECT_SOURCE_DIR}/doc/*.1)
1131
+ FILE(GLOB man3 ${PROJECT_SOURCE_DIR}/doc/*.3)
1132
+
1133
+ INSTALL(FILES ${man1} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
1134
+ INSTALL(FILES ${man3} DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
1135
+ INSTALL(FILES ${html} DESTINATION share/doc/pcre2/html)
1136
+
1137
+ IF(MSVC AND INSTALL_MSVC_PDB)
1138
+ INSTALL(FILES ${dll_pdb_files} DESTINATION bin CONFIGURATIONS RelWithDebInfo)
1139
+ INSTALL(FILES ${dll_pdb_debug_files} DESTINATION bin CONFIGURATIONS Debug)
1140
+ ENDIF(MSVC AND INSTALL_MSVC_PDB)
1141
+
1142
+ # Help, only for nice output
1143
+ IF(BUILD_STATIC_LIBS)
1144
+ SET(BUILD_STATIC_LIBS ON)
1145
+ ELSE(BUILD_STATIC_LIBS)
1146
+ SET(BUILD_STATIC_LIBS OFF)
1147
+ ENDIF(BUILD_STATIC_LIBS)
1148
+
1149
+ IF(PCRE2_HEAP_MATCH_RECURSE)
1150
+ MESSAGE(WARNING "HEAP_MATCH_RECURSE is obsolete and does nothing.")
1151
+ ENDIF(PCRE2_HEAP_MATCH_RECURSE)
1152
+
1153
+ IF(PCRE2_SHOW_REPORT)
1154
+ STRING(TOUPPER "${CMAKE_BUILD_TYPE}" buildtype)
1155
+ IF (CMAKE_C_FLAGS)
1156
+ SET(cfsp " ")
1157
+ ENDIF(CMAKE_C_FLAGS)
1158
+ MESSAGE(STATUS "")
1159
+ MESSAGE(STATUS "")
1160
+ MESSAGE(STATUS "PCRE2-${PCRE2_MAJOR}.${PCRE2_MINOR} configuration summary:")
1161
+ MESSAGE(STATUS "")
1162
+ MESSAGE(STATUS " Install prefix .................. : ${CMAKE_INSTALL_PREFIX}")
1163
+ MESSAGE(STATUS " C compiler ...................... : ${CMAKE_C_COMPILER}")
1164
+ MESSAGE(STATUS " C compiler flags ................ : ${CMAKE_C_FLAGS}${cfsp}${CMAKE_C_FLAGS_${buildtype}}")
1165
+ MESSAGE(STATUS "")
1166
+ MESSAGE(STATUS " Build 8 bit PCRE2 library ....... : ${PCRE2_BUILD_PCRE2_8}")
1167
+ MESSAGE(STATUS " Build 16 bit PCRE2 library ...... : ${PCRE2_BUILD_PCRE2_16}")
1168
+ MESSAGE(STATUS " Build 32 bit PCRE2 library ...... : ${PCRE2_BUILD_PCRE2_32}")
1169
+ MESSAGE(STATUS " Enable JIT compiling support .... : ${PCRE2_SUPPORT_JIT}")
1170
+ MESSAGE(STATUS " Use SELinux allocator in JIT .... : ${PCRE2_SUPPORT_JIT_SEALLOC}")
1171
+ MESSAGE(STATUS " Enable Unicode support .......... : ${PCRE2_SUPPORT_UNICODE}")
1172
+ MESSAGE(STATUS " Newline char/sequence ........... : ${PCRE2_NEWLINE}")
1173
+ MESSAGE(STATUS " \\R matches only ANYCRLF ......... : ${PCRE2_SUPPORT_BSR_ANYCRLF}")
1174
+ MESSAGE(STATUS " \\C is disabled .................. : ${PCRE2_NEVER_BACKSLASH_C}")
1175
+ MESSAGE(STATUS " EBCDIC coding ................... : ${PCRE2_EBCDIC}")
1176
+ MESSAGE(STATUS " EBCDIC coding with NL=0x25 ...... : ${PCRE2_EBCDIC_NL25}")
1177
+ MESSAGE(STATUS " Rebuild char tables ............. : ${PCRE2_REBUILD_CHARTABLES}")
1178
+ MESSAGE(STATUS " Internal link size .............. : ${PCRE2_LINK_SIZE}")
1179
+ MESSAGE(STATUS " Maximum variable lookbehind ..... : ${PCRE2_MAX_VARLOOKBEHIND}")
1180
+ MESSAGE(STATUS " Parentheses nest limit .......... : ${PCRE2_PARENS_NEST_LIMIT}")
1181
+ MESSAGE(STATUS " Heap limit ...................... : ${PCRE2_HEAP_LIMIT}")
1182
+ MESSAGE(STATUS " Match limit ..................... : ${PCRE2_MATCH_LIMIT}")
1183
+ MESSAGE(STATUS " Match depth limit ............... : ${PCRE2_MATCH_LIMIT_DEPTH}")
1184
+ MESSAGE(STATUS " Build shared libs ............... : ${BUILD_SHARED_LIBS}")
1185
+ MESSAGE(STATUS " Build static libs ............... : ${BUILD_STATIC_LIBS}")
1186
+ MESSAGE(STATUS " with PIC enabled ............. : ${PCRE2_STATIC_PIC}")
1187
+ MESSAGE(STATUS " Build pcre2grep ................. : ${PCRE2_BUILD_PCRE2GREP}")
1188
+ MESSAGE(STATUS " Enable JIT in pcre2grep ......... : ${PCRE2GREP_SUPPORT_JIT}")
1189
+ MESSAGE(STATUS " Enable callouts in pcre2grep .... : ${PCRE2GREP_SUPPORT_CALLOUT}")
1190
+ MESSAGE(STATUS " Enable callout fork in pcre2grep. : ${PCRE2GREP_SUPPORT_CALLOUT_FORK}")
1191
+ MESSAGE(STATUS " Buffer size for pcre2grep ....... : ${PCRE2GREP_BUFSIZE}")
1192
+ MESSAGE(STATUS " Build tests (implies pcre2test .. : ${PCRE2_BUILD_TESTS}")
1193
+ MESSAGE(STATUS " and pcre2grep)")
1194
+ IF(ZLIB_FOUND)
1195
+ MESSAGE(STATUS " Link pcre2grep with libz ........ : ${PCRE2_SUPPORT_LIBZ}")
1196
+ ELSE(ZLIB_FOUND)
1197
+ MESSAGE(STATUS " Link pcre2grep with libz ........ : Library not found" )
1198
+ ENDIF(ZLIB_FOUND)
1199
+ IF(BZIP2_FOUND)
1200
+ MESSAGE(STATUS " Link pcre2grep with libbz2 ...... : ${PCRE2_SUPPORT_LIBBZ2}")
1201
+ ELSE(BZIP2_FOUND)
1202
+ MESSAGE(STATUS " Link pcre2grep with libbz2 ...... : Library not found" )
1203
+ ENDIF(BZIP2_FOUND)
1204
+ IF(EDITLINE_FOUND)
1205
+ MESSAGE(STATUS " Link pcre2test with libeditline . : ${PCRE2_SUPPORT_LIBEDIT}")
1206
+ ELSE(EDITLINE_FOUND)
1207
+ MESSAGE(STATUS " Link pcre2test with libeditline . : Library not found" )
1208
+ ENDIF(EDITLINE_FOUND)
1209
+ IF(READLINE_FOUND)
1210
+ MESSAGE(STATUS " Link pcre2test with libreadline . : ${PCRE2_SUPPORT_LIBREADLINE}")
1211
+ ELSE(READLINE_FOUND)
1212
+ MESSAGE(STATUS " Link pcre2test with libreadline . : Library not found" )
1213
+ ENDIF(READLINE_FOUND)
1214
+ MESSAGE(STATUS " Support Valgrind .................: ${PCRE2_SUPPORT_VALGRIND}")
1215
+ IF(PCRE2_DISABLE_PERCENT_ZT)
1216
+ MESSAGE(STATUS " Use %zu and %td ..................: OFF" )
1217
+ ELSE(PCRE2_DISABLE_PERCENT_ZT)
1218
+ MESSAGE(STATUS " Use %zu and %td ..................: AUTO" )
1219
+ ENDIF(PCRE2_DISABLE_PERCENT_ZT)
1220
+
1221
+ IF(MINGW AND BUILD_SHARED_LIBS)
1222
+ MESSAGE(STATUS " Non-standard dll names (prefix) . : ${NON_STANDARD_LIB_PREFIX}")
1223
+ MESSAGE(STATUS " Non-standard dll names (suffix) . : ${NON_STANDARD_LIB_SUFFIX}")
1224
+ ENDIF(MINGW AND BUILD_SHARED_LIBS)
1225
+
1226
+ IF(MSVC)
1227
+ MESSAGE(STATUS " Install MSVC .pdb files ..........: ${INSTALL_MSVC_PDB}")
1228
+ ENDIF(MSVC)
1229
+
1230
+ MESSAGE(STATUS "")
1231
+ ENDIF(PCRE2_SHOW_REPORT)
1232
+
1233
+ # end CMakeLists.txt