@@ -161,6 +161,7 @@ include(CheckSymbolExists)
161161include (CheckIncludeFile)
162162include (CheckTypeSize)
163163include (CMakePackageConfigHelpers)
164+ include (CMakePushCheckState)
164165include (GNUInstallDirs) # for CMAKE_INSTALL_LIBDIR
165166include (PCRE2CheckLinkerFlag)
166167include (PCRE2UseSystemExtensions)
@@ -172,6 +173,10 @@ check_include_file(sys/types.h HAVE_SYS_TYPES_H)
172173check_include_file(unistd.h HAVE_UNISTD_H)
173174check_include_file(windows.h HAVE_WINDOWS_H)
174175
176+ # Check whether any system-wide extensions need to be enabled, in order for
177+ # OS functionality to be exposed.
178+ pcre2_use_system_extensions()
179+
175180check_symbol_exists(memfd_create "sys/mman.h" HAVE_MEMFD_CREATE)
176181check_symbol_exists(secure_getenv "stdlib.h" HAVE_SECURE_GETENV)
177182
@@ -184,10 +189,10 @@ check_c_source_compiles(
184189 HAVE_REALPATH
185190)
186191
192+ cmake_push_check_state()
187193if (NOT DEFINED CMAKE_REQUIRED_FLAGS)
188194 set (CMAKE_REQUIRED_FLAGS "" )
189195endif ()
190- set (ORIG_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} )
191196if (NOT MSVC AND NOT CMAKE_C_COMPILER_ID STREQUAL "XL" AND NOT CMAKE_C_COMPILER_ID STREQUAL "SunPro" )
192197 set (CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror" )
193198endif ()
@@ -197,6 +202,7 @@ check_c_source_compiles(
197202 HAVE_ATTRIBUTE_UNINITIALIZED
198203)
199204
205+ # TODO Consider switching to modern "GenerateExportHeader"
200206check_c_source_compiles(
201207 [=[
202208 extern __attribute__ ((visibility ("default"))) int f(void);
@@ -206,14 +212,14 @@ check_c_source_compiles(
206212 HAVE_VISIBILITY
207213)
208214
215+ cmake_pop_check_state()
216+
209217if (HAVE_VISIBILITY)
210218 set (PCRE2_EXPORT [=[__attribute__ ((visibility ("default")))]=])
211219else ()
212220 set (PCRE2_EXPORT)
213221endif ()
214222
215- set (CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS} )
216-
217223check_c_source_compiles("int main(void) { __assume(1); return 0; }" HAVE_BUILTIN_ASSUME)
218224
219225check_c_source_compiles(
@@ -271,11 +277,6 @@ if(INTEL_CET_ENABLED)
271277 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mshstk" )
272278endif ()
273279
274- # Check whether any system-wide extensions need to be enabled, in order for
275- # OS functionality to be exposed.
276-
277- pcre2_use_system_extensions()
278-
279280# User-configurable options
280281#
281282# Note: CMakeSetup displays these in alphabetical order, regardless of
@@ -537,19 +538,7 @@ if(PCRE2_SUPPORT_JIT)
537538endif ()
538539
539540if (PCRE2_SUPPORT_JIT_SEALLOC)
540- set (CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
541- check_symbol_exists(mkostemp stdlib.h REQUIRED)
542- unset (CMAKE_REQUIRED_DEFINITIONS)
543- if (${REQUIRED} )
544- if (${CMAKE_SYSTEM_NAME} MATCHES Linux|NetBSD)
545- add_compile_definitions (_GNU_SOURCE)
546- set (SLJIT_PROT_EXECUTABLE_ALLOCATOR 1)
547- else ()
548- message (FATAL_ERROR "Your configuration is not supported" )
549- endif ()
550- else ()
551- set (PCRE2_SUPPORT_JIT_SEALLOC OFF )
552- endif ()
541+ set (SLJIT_PROT_EXECUTABLE_ALLOCATOR 1)
553542endif ()
554543
555544if (PCRE2GREP_SUPPORT_JIT)
0 commit comments