From 3a33ae86010051a1022c392f2936b5fc9f3ab19e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 12 Jan 2024 16:57:37 +0100 Subject: [PATCH] MDEV-33091 pcre2 headers aren't found on Solaris use pkg-config to find pcre2, if possible rename PCRE_INCLUDES to use PKG_CHECK_MODULES naming, PCRE_INCLUDE_DIRS --- client/CMakeLists.txt | 2 +- cmake/pcre.cmake | 34 +++++++++++++--------- cmake/plugin.cmake | 2 +- extra/mariabackup/CMakeLists.txt | 2 +- libmysqld/CMakeLists.txt | 2 +- libmysqld/examples/CMakeLists.txt | 2 +- plugin/feedback/CMakeLists.txt | 2 +- plugin/qc_info/CMakeLists.txt | 2 +- sql/CMakeLists.txt | 2 +- storage/perfschema/CMakeLists.txt | 2 +- storage/perfschema/unittest/CMakeLists.txt | 2 +- unittest/embedded/CMakeLists.txt | 2 +- 12 files changed, 32 insertions(+), 24 deletions(-) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 55fd02b23c3..4dfce2478cd 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -16,7 +16,7 @@ INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/mysys_ssl ${ZLIB_INCLUDE_DIR} ${SSL_INCLUDE_DIRS} diff --git a/cmake/pcre.cmake b/cmake/pcre.cmake index 65dc2ae28f6..c2eb26074ac 100644 --- a/cmake/pcre.cmake +++ b/cmake/pcre.cmake @@ -1,4 +1,3 @@ -INCLUDE (CheckCSourceRuns) INCLUDE (ExternalProject) SET(WITH_PCRE "auto" CACHE STRING @@ -6,7 +5,8 @@ SET(WITH_PCRE "auto" CACHE STRING MACRO(BUNDLE_PCRE2) SET(dir "${CMAKE_BINARY_DIR}/extra/pcre2") - SET(PCRE_INCLUDES ${dir}/src/pcre2-build ${dir}/src/pcre2/src) + SET(PCRE_INCLUDE_DIRS ${dir}/src/pcre2-build ${dir}/src/pcre2/src) + MESSAGE(STATUS "Will download and bundle pcre2") SET(byproducts) FOREACH(lib pcre2-posix pcre2-8) ADD_LIBRARY(${lib} STATIC IMPORTED GLOBAL) @@ -76,18 +76,26 @@ SET_TARGET_PROPERTIES(pcre2 PROPERTIES EXCLUDE_FROM_ALL TRUE) ENDMACRO() MACRO (CHECK_PCRE) - IF(WITH_PCRE STREQUAL "system" OR WITH_PCRE STREQUAL "auto") - CHECK_LIBRARY_EXISTS(pcre2-8 pcre2_match_8 "" HAVE_PCRE2) - ENDIF() - IF(NOT HAVE_PCRE2 OR WITH_PCRE STREQUAL "bundled") - IF (WITH_PCRE STREQUAL "system") - MESSAGE(FATAL_ERROR "system pcre2-8 library is not found or unusable") + IF (NOT TARGET pcre2 AND NOT PCRE_FOUND) + IF(WITH_PCRE STREQUAL "system" OR WITH_PCRE STREQUAL "auto") + FIND_PACKAGE(PkgConfig QUIET) + PKG_CHECK_MODULES(PCRE libpcre2-8) + # in case pkg-config or libpcre2-8.pc is not installed: + IF(NOT PCRE_FOUND) + UNSET(PCRE_FOUND CACHE) + CHECK_LIBRARY_EXISTS(pcre2-8 pcre2_match_8 "" PCRE_FOUND) + ENDIF() ENDIF() - BUNDLE_PCRE2() - ELSE() - CHECK_LIBRARY_EXISTS(pcre2-posix PCRE2regcomp "" NEEDS_PCRE2_DEBIAN_HACK) - IF(NEEDS_PCRE2_DEBIAN_HACK) - SET(PCRE2_DEBIAN_HACK "-Dregcomp=PCRE2regcomp -Dregexec=PCRE2regexec -Dregerror=PCRE2regerror -Dregfree=PCRE2regfree") + IF(NOT PCRE_FOUND OR WITH_PCRE STREQUAL "bundled") + IF (WITH_PCRE STREQUAL "system") + MESSAGE(FATAL_ERROR "system pcre2-8 library is not found or unusable") + ENDIF() + BUNDLE_PCRE2() + ELSE() + CHECK_LIBRARY_EXISTS(pcre2-posix PCRE2regcomp "" NEEDS_PCRE2_DEBIAN_HACK) + IF(NEEDS_PCRE2_DEBIAN_HACK) + SET(PCRE2_DEBIAN_HACK "-Dregcomp=PCRE2regcomp -Dregexec=PCRE2regexec -Dregerror=PCRE2regerror -Dregfree=PCRE2regfree") + ENDIF() ENDIF() ENDIF() ENDMACRO() diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 813d8ef6e42..6efd40fd1bd 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -44,7 +44,7 @@ MACRO(MYSQL_ADD_PLUGIN) # Add common include directories INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${SSL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) diff --git a/extra/mariabackup/CMakeLists.txt b/extra/mariabackup/CMakeLists.txt index a7a35c58ac3..4dfef82d3d5 100644 --- a/extra/mariabackup/CMakeLists.txt +++ b/extra/mariabackup/CMakeLists.txt @@ -36,7 +36,7 @@ INCLUDE_DIRECTORIES( ) IF(NOT HAVE_SYSTEM_REGEX) - INCLUDE_DIRECTORIES(${PCRE_INCLUDES}) + INCLUDE_DIRECTORIES(${PCRE_INCLUDE_DIRS}) ADD_DEFINITIONS(${PCRE2_DEBIAN_HACK}) ENDIF() diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index b414903f705..ff6e2cbf36d 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -23,7 +23,7 @@ ${CMAKE_SOURCE_DIR}/libmysqld ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/tpool ${CMAKE_BINARY_DIR}/sql -${PCRE_INCLUDES} +${PCRE_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} ${SSL_INCLUDE_DIRS} ${SSL_INTERNAL_INCLUDE_DIRS} diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt index 2a10def8e2e..d6646a128ca 100644 --- a/libmysqld/examples/CMakeLists.txt +++ b/libmysqld/examples/CMakeLists.txt @@ -15,7 +15,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/libmysqld/include - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/sql ${MY_READLINE_INCLUDE_DIR} ) diff --git a/plugin/feedback/CMakeLists.txt b/plugin/feedback/CMakeLists.txt index 2103250e5a6..fc35cbadc31 100644 --- a/plugin/feedback/CMakeLists.txt +++ b/plugin/feedback/CMakeLists.txt @@ -1,5 +1,5 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${SSL_INCLUDE_DIRS}) SET(FEEDBACK_SOURCES feedback.cc sender_thread.cc diff --git a/plugin/qc_info/CMakeLists.txt b/plugin/qc_info/CMakeLists.txt index b8c5f926cff..329f49c1fc9 100644 --- a/plugin/qc_info/CMakeLists.txt +++ b/plugin/qc_info/CMakeLists.txt @@ -1,4 +1,4 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/sql - ${PCRE_INCLUDES}) + ${PCRE_INCLUDE_DIRS}) MYSQL_ADD_PLUGIN(QUERY_CACHE_INFO qc_info.cc RECOMPILE_FOR_EMBEDDED) diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 557fd5eb506..f1c1c65310b 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -52,7 +52,7 @@ ENDIF() INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql -${PCRE_INCLUDES} +${PCRE_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} ${SSL_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}/sql diff --git a/storage/perfschema/CMakeLists.txt b/storage/perfschema/CMakeLists.txt index b4f5e96b607..e703e43fe50 100644 --- a/storage/perfschema/CMakeLists.txt +++ b/storage/perfschema/CMakeLists.txt @@ -24,7 +24,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql ${CMAKE_BINARY_DIR}/sql ${CMAKE_CURRENT_BINARY_DIR} - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${SSL_INCLUDE_DIRS}) ADD_DEFINITIONS(-DMYSQL_SERVER) diff --git a/storage/perfschema/unittest/CMakeLists.txt b/storage/perfschema/unittest/CMakeLists.txt index 2a22990f807..600795c78fc 100644 --- a/storage/perfschema/unittest/CMakeLists.txt +++ b/storage/perfschema/unittest/CMakeLists.txt @@ -22,7 +22,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include/mysql - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/sql ${SSL_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/unittest/mytap diff --git a/unittest/embedded/CMakeLists.txt b/unittest/embedded/CMakeLists.txt index cf48550c377..428bb811de6 100644 --- a/unittest/embedded/CMakeLists.txt +++ b/unittest/embedded/CMakeLists.txt @@ -1,7 +1,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/libmysqld/include - ${PCRE_INCLUDES} + ${PCRE_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/sql ${MY_READLINE_INCLUDE_DIR} )