@@ -204,6 +204,12 @@ check_c_source_compiles(
204204 HAVE_VISIBILITY
205205)
206206
207+ if (HAVE_VISIBILITY)
208+ set (PCRE2_EXPORT [=[__attribute__ ((visibility ("default")))]=])
209+ else ()
210+ set (PCRE2_EXPORT)
211+ endif ()
212+
207213set (CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS} )
208214
209215check_c_source_compiles("int main(void) { __assume(1); return 0; }" HAVE_BUILTIN_ASSUME)
@@ -221,11 +227,33 @@ check_c_source_compiles(
221227 HAVE_BUILTIN_UNREACHABLE
222228)
223229
224- if (HAVE_VISIBILITY)
225- set (PCRE2_EXPORT [=[__attribute__ ((visibility ("default")))]=])
226- else ()
227- set (PCRE2_EXPORT)
230+ # Detect support for linker scripts.
231+
232+ file (WRITE ${CMAKE_CURRENT_BINARY_DIR} /test -map-file.sym "PCRE2_10.00 { global: main; };" )
233+ file (WRITE ${CMAKE_CURRENT_BINARY_DIR} /test -map-file-broken.sym "PCRE2_10.00 { global: main; }; {" )
234+ pcre2_check_linker_flag(C -Wl,--version -script,${CMAKE_CURRENT_BINARY_DIR} /test -map-file.sym HAVE_VSCRIPT_GNU)
235+ pcre2_check_linker_flag(C -Wl,-M,${CMAKE_CURRENT_BINARY_DIR} /test -map-file.sym HAVE_VSCRIPT_SUN)
236+ if (HAVE_VSCRIPT_GNU)
237+ set (VSCRIPT_FLAG --version -script)
238+ set (HAVE_VSCRIPT TRUE )
239+ elseif (HAVE_VSCRIPT_SUN)
240+ set (VSCRIPT_FLAG -M)
241+ set (HAVE_VSCRIPT TRUE )
228242endif ()
243+ if (HAVE_VSCRIPT)
244+ # Perform the same logic as ax_check_vscript.m4, to test whether the linker
245+ # silently ignores (and overwrites) linker scripts it doesn't understand.
246+ pcre2_check_linker_flag(
247+ C
248+ -Wl,${VSCRIPT_FLAG} ,${CMAKE_CURRENT_BINARY_DIR} /test -map-file-broken.sym
249+ HAVE_VSCRIPT_BROKEN
250+ )
251+ if (HAVE_VSCRIPT_BROKEN)
252+ set (HAVE_VSCRIPT FALSE )
253+ endif ()
254+ endif ()
255+ file (REMOVE ${CMAKE_CURRENT_BINARY_DIR} /test -map-file.sym)
256+ file (REMOVE ${CMAKE_CURRENT_BINARY_DIR} /test -map-file-broken.sym)
229257
230258# Check whether Intel CET is enabled, and if so, adjust compiler flags. This
231259# code was written by PH, trying to imitate the logic from the autotools
@@ -397,6 +425,10 @@ if(MSVC)
397425 option (INSTALL_MSVC_PDB "ON=Install .pdb files built by MSVC, if generated" OFF )
398426endif ()
399427
428+ if (HAVE_VSCRIPT)
429+ option (PCRE2_SYMVERS "Enable library symbol versioning" ON )
430+ endif ()
431+
400432# bzip2 lib
401433if (BZIP2_FOUND)
402434 option (PCRE2_SUPPORT_LIBBZ2 "Enable support for linking pcre2grep with libbz2." ON )
@@ -630,34 +662,6 @@ if(EBCDIC)
630662 endif ()
631663endif ()
632664
633- # Detect support for linker scripts.
634-
635- file (WRITE ${CMAKE_CURRENT_BINARY_DIR} /test -map-file.sym "PCRE2_10.00 { global: main; };" )
636- file (WRITE ${CMAKE_CURRENT_BINARY_DIR} /test -map-file-broken.sym "PCRE2_10.00 { global: main; }; {" )
637- pcre2_check_linker_flag(C -Wl,--version -script,${CMAKE_CURRENT_BINARY_DIR} /test -map-file.sym HAVE_VSCRIPT_GNU)
638- pcre2_check_linker_flag(C -Wl,-M,${CMAKE_CURRENT_BINARY_DIR} /test -map-file.sym HAVE_VSCRIPT_SUN)
639- if (HAVE_VSCRIPT_GNU)
640- set (VSCRIPT_FLAG --version -script)
641- set (HAVE_VSCRIPT TRUE )
642- elseif (HAVE_VSCRIPT_SUN)
643- set (VSCRIPT_FLAG -M)
644- set (HAVE_VSCRIPT TRUE )
645- endif ()
646- if (HAVE_VSCRIPT)
647- # Perform the same logic as ax_check_vscript.m4, to test whether the linker
648- # silently ignores (and overwrites) linker scripts it doesn't understand.
649- pcre2_check_linker_flag(
650- C
651- -Wl,${VSCRIPT_FLAG} ,${CMAKE_CURRENT_BINARY_DIR} /test -map-file-broken.sym
652- HAVE_VSCRIPT_BROKEN
653- )
654- if (HAVE_VSCRIPT_BROKEN)
655- set (HAVE_VSCRIPT FALSE )
656- endif ()
657- endif ()
658- file (REMOVE ${CMAKE_CURRENT_BINARY_DIR} /test -map-file.sym)
659- file (REMOVE ${CMAKE_CURRENT_BINARY_DIR} /test -map-file-broken.sym)
660-
661665# Output files
662666
663667configure_file (src/config-cmake.h.in ${PROJECT_BINARY_DIR} /config.h @ONLY)
@@ -927,7 +931,7 @@ if(PCRE2_BUILD_PCRE2_8)
927931 if (REQUIRE_PTHREAD)
928932 target_link_libraries (pcre2-8-shared Threads::Threads)
929933 endif ()
930- if (HAVE_VSCRIPT)
934+ if (HAVE_VSCRIPT AND PCRE2_SYMVERS )
931935 target_link_options (pcre2-8-shared PRIVATE -Wl,${VSCRIPT_FLAG} ,${PROJECT_SOURCE_DIR} /src/libpcre2-8.sym)
932936 set_target_properties (pcre2-8-shared PROPERTIES LINK_DEPENDS ${PROJECT_SOURCE_DIR} /src/libpcre2-8.sym)
933937 endif ()
@@ -947,7 +951,7 @@ if(PCRE2_BUILD_PCRE2_8)
947951 SOVERSION ${LIBPCRE2_POSIX_SOVERSION}
948952 OUTPUT_NAME pcre2-posix
949953 )
950- if (HAVE_VSCRIPT)
954+ if (HAVE_VSCRIPT AND PCRE2_SYMVERS )
951955 target_link_options (pcre2-posix-shared PRIVATE -Wl,${VSCRIPT_FLAG} ,${PROJECT_SOURCE_DIR} /src/libpcre2-posix.sym)
952956 set_target_properties (pcre2-posix-shared PROPERTIES LINK_DEPENDS ${PROJECT_SOURCE_DIR} /src/libpcre2-posix.sym)
953957 endif ()
@@ -1024,7 +1028,7 @@ if(PCRE2_BUILD_PCRE2_16)
10241028 if (REQUIRE_PTHREAD)
10251029 target_link_libraries (pcre2-16-shared Threads::Threads)
10261030 endif ()
1027- if (HAVE_VSCRIPT)
1031+ if (HAVE_VSCRIPT AND PCRE2_SYMVERS )
10281032 target_link_options (pcre2-16-shared PRIVATE -Wl,${VSCRIPT_FLAG} ,${PROJECT_SOURCE_DIR} /src/libpcre2-16.sym)
10291033 set_target_properties (pcre2-16-shared PROPERTIES LINK_DEPENDS ${PROJECT_SOURCE_DIR} /src/libpcre2-16.sym)
10301034 endif ()
@@ -1096,7 +1100,7 @@ if(PCRE2_BUILD_PCRE2_32)
10961100 if (REQUIRE_PTHREAD)
10971101 target_link_libraries (pcre2-32-shared Threads::Threads)
10981102 endif ()
1099- if (HAVE_VSCRIPT)
1103+ if (HAVE_VSCRIPT AND PCRE2_SYMVERS )
11001104 target_link_options (pcre2-32-shared PRIVATE -Wl,${VSCRIPT_FLAG} ,${PROJECT_SOURCE_DIR} /src/libpcre2-32.sym)
11011105 set_target_properties (pcre2-32-shared PROPERTIES LINK_DEPENDS ${PROJECT_SOURCE_DIR} /src/libpcre2-32.sym)
11021106 endif ()
@@ -1433,9 +1437,9 @@ if(PCRE2_SHOW_REPORT)
14331437 else ()
14341438 message (STATUS " Build type ........................ : ${CMAKE_BUILD_TYPE} " )
14351439 endif ()
1436- message (STATUS " Build 8 bit PCRE2 library ......... : ${PCRE2_BUILD_PCRE2_8} " )
1437- message (STATUS " Build 16 bit PCRE2 library ........ : ${PCRE2_BUILD_PCRE2_16} " )
1438- message (STATUS " Build 32 bit PCRE2 library ........ : ${PCRE2_BUILD_PCRE2_32} " )
1440+ message (STATUS " Build 8 bit pcre2 library ......... : ${PCRE2_BUILD_PCRE2_8} " )
1441+ message (STATUS " Build 16 bit pcre2 library ........ : ${PCRE2_BUILD_PCRE2_16} " )
1442+ message (STATUS " Build 32 bit pcre2 library ........ : ${PCRE2_BUILD_PCRE2_32} " )
14391443 message (STATUS " Include debugging code ............ : ${PCRE2_DEBUG} " )
14401444 message (STATUS " Enable JIT compiling support ...... : ${PCRE2_SUPPORT_JIT} " )
14411445 message (STATUS " Use SELinux allocator in JIT ...... : ${PCRE2_SUPPORT_JIT_SEALLOC} " )
@@ -1458,18 +1462,24 @@ if(PCRE2_SHOW_REPORT)
14581462
14591463 message (STATUS " Internal link size ................ : ${PCRE2_LINK_SIZE} " )
14601464 message (STATUS " Maximum variable lookbehind ....... : ${PCRE2_MAX_VARLOOKBEHIND} " )
1461- message (STATUS " Parentheses nest limit .. .......... : ${PCRE2_PARENS_NEST_LIMIT} " )
1465+ message (STATUS " Nested parentheses limit .......... : ${PCRE2_PARENS_NEST_LIMIT} " )
14621466 message (STATUS " Heap limit ........................ : ${PCRE2_HEAP_LIMIT} " )
14631467 message (STATUS " Match limit ....................... : ${PCRE2_MATCH_LIMIT} " )
14641468 message (STATUS " Match depth limit ................. : ${PCRE2_MATCH_LIMIT_DEPTH} " )
14651469 message (STATUS " Build shared libs ................. : ${BUILD_SHARED_LIBS} " )
1470+ if (NOT HAVE_VSCRIPT)
1471+ message (STATUS " with symbol versioning ........ : n/a" )
1472+ else ()
1473+ message (STATUS " with symbol versioning ........ : ${PCRE2_SYMVERS} " )
1474+ endif ()
14661475 message (STATUS " Build static libs ................. : ${BUILD_STATIC_LIBS} " )
1467- message (STATUS " with PIC enabled . .............. : ${PCRE2_STATIC_PIC} " )
1476+ message (STATUS " with PIC enabled .............. : ${PCRE2_STATIC_PIC} " )
14681477 message (STATUS " Build pcre2grep ................... : ${PCRE2_BUILD_PCRE2GREP} " )
14691478 message (STATUS " Enable JIT in pcre2grep ........... : ${PCRE2GREP_SUPPORT_JIT} " )
14701479 message (STATUS " Enable callouts in pcre2grep ...... : ${PCRE2GREP_SUPPORT_CALLOUT} " )
14711480 message (STATUS " Enable callout fork in pcre2grep .. : ${PCRE2GREP_SUPPORT_CALLOUT_FORK} " )
1472- message (STATUS " Buffer size for pcre2grep ......... : ${PCRE2GREP_BUFSIZE} " )
1481+ message (STATUS " Initial buffer size for pcre2grep . : ${PCRE2GREP_BUFSIZE} " )
1482+ message (STATUS " Maximum buffer size for pcre2grep . : ${PCRE2GREP_MAX_BUFSIZE} " )
14731483 message (STATUS " Build tests (implies pcre2test .... : ${PCRE2_BUILD_TESTS} " )
14741484 message (STATUS " and pcre2grep)" )
14751485 if (ZLIB_FOUND)
@@ -1492,7 +1502,7 @@ if(PCRE2_SHOW_REPORT)
14921502 else ()
14931503 message (STATUS " Link pcre2test with libreadline ... : Library not found" )
14941504 endif ()
1495- message (STATUS " Support Valgrind ....... ........... : ${PCRE2_SUPPORT_VALGRIND} " )
1505+ message (STATUS " Enable Valgrind support ........... : ${PCRE2_SUPPORT_VALGRIND} " )
14961506 if (PCRE2_DISABLE_PERCENT_ZT)
14971507 message (STATUS " Use %zu and %td ................... : OFF" )
14981508 else ()
0 commit comments