Skip to content

Commit

Permalink
MDEV-33091 pcre2 headers aren't found on Solaris
Browse files Browse the repository at this point in the history
use pkg-config to find pcre2, if possible

rename PCRE_INCLUDES to use PKG_CHECK_MODULES naming, PCRE_INCLUDE_DIRS
  • Loading branch information
vuvova committed Jan 19, 2024
1 parent 21560be commit 3a33ae8
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 24 deletions.
2 changes: 1 addition & 1 deletion client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
34 changes: 21 additions & 13 deletions cmake/pcre.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
INCLUDE (CheckCSourceRuns)
INCLUDE (ExternalProject)

SET(WITH_PCRE "auto" CACHE STRING
"Which pcre to use (possible values are 'bundled', 'system', or 'auto')")

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)
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion cmake/plugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
2 changes: 1 addition & 1 deletion extra/mariabackup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion libmysqld/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion libmysqld/examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
)
Expand Down
2 changes: 1 addition & 1 deletion plugin/feedback/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion plugin/qc_info/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion sql/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion storage/perfschema/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion storage/perfschema/unittest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion unittest/embedded/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}
)
Expand Down

0 comments on commit 3a33ae8

Please sign in to comment.