add pcre build step if it's not found locally

* Unfortunately the new upcoming debian has made the really poor decision to
  actively *delete* the pcre package, breaking any programs depending on it even
  at build time. As far as I can see it's still available in most other common
  distributions.
* Users could easily build it themselves but would have to install it system
  wide for it to be picked up. This kind of dependency absolutely should not be
  something the build system has to set up itself but when distributions make
  poor choices we have little choice but to adapt somehow.
This commit is contained in:
baldurk
2025-08-07 15:38:11 +01:00
parent 08f69e0f0f
commit adf8acbccd
+27 -1
View File
@@ -11,6 +11,7 @@ endif()
set(QMAKE_QT5_COMMAND ${QT_QMAKE_EXECUTABLE} CACHE STRING "Command to run to invoke Qt5's qmake. Normally this is qmake, possibly with qtchooser, but might be qmake-qt5")
set(RENDERDOC_SWIG_PACKAGE https://github.com/baldurk/swig/archive/renderdoc-modified-7.zip CACHE STRING "The location where RenderDoc's swig fork source can be found. By default points to the URL on github but can be pointed to a local file.")
set(RENDERDOC_PCRE_PACKAGE https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.tar.gz CACHE STRING "The location where the pcre library package can be found. By default points to the URL on sourceforge but can be pointed to a local file.")
# Only check qt version if we're building qrenderdoc
if(ENABLE_QRENDERDOC)
@@ -111,6 +112,7 @@ else()
endif()
include(ExternalProject)
include(CheckIncludeFile)
# Need bison for swig
find_package(BISON)
@@ -157,13 +159,37 @@ if(NOT ${CMAKE_VERSION} VERSION_LESS "3.24")
cmake_policy(SET CMP0135 NEW)
endif()
CHECK_INCLUDE_FILE(pcre.h PCRE_HEADER)
set(PCRE_PREFIX_PATH "")
if(PCRE_HEADER)
message(STATUS "pcre library is found, using it as-is")
add_custom_target(local_pcre)
else()
message(STATUS "pcre header is not found! building pcre locally")
# fetch pcre if missing
ExternalProject_Add(local_pcre
# using an URL to a zip directly so we don't clone the history etc
URL ${RENDERDOC_PCRE_PACKAGE}
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND CC=${SWIG_CONFIGURE_CC} CXX=${SWIG_CONFIGURE_CXX} CFLAGS=-fPIC CXXFLAGS=-fPIC ${SET_SYSTEM_PATH_COMMAND} ./configure --prefix=${CMAKE_BINARY_DIR} --disable-shared > /dev/null
BUILD_COMMAND ${GENERATOR_MAKE} ${GENERATOR_MAKE_PARAMS} > /dev/null 2>&1
INSTALL_COMMAND ${GENERATOR_MAKE} install > /dev/null 2>&1)
set(PCRE_PREFIX_PATH "--with-pcre-prefix=${CMAKE_BINARY_DIR}")
endif()
# Compile our custom SWIG that will do scoped/strong enum classes
ExternalProject_Add(custom_swig
# using an URL to a zip directly so we don't clone the history etc
URL ${RENDERDOC_SWIG_PACKAGE}
DEPENDS local_pcre
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ${SET_SYSTEM_PATH_COMMAND} ./autogen.sh > /dev/null 2>&1
COMMAND CC=${SWIG_CONFIGURE_CC} CXX=${SWIG_CONFIGURE_CXX} CFLAGS=-fPIC CXXFLAGS=-fPIC ${SET_SYSTEM_PATH_COMMAND} ./configure --with-pcre=yes --prefix=${CMAKE_BINARY_DIR} > /dev/null
COMMAND CC=${SWIG_CONFIGURE_CC} CXX=${SWIG_CONFIGURE_CXX} CFLAGS=-fPIC CXXFLAGS=-fPIC ${SET_SYSTEM_PATH_COMMAND} ./configure --with-pcre=yes ${PCRE_PREFIX_PATH} --prefix=${CMAKE_BINARY_DIR} > /dev/null
BUILD_COMMAND ${GENERATOR_MAKE} ${GENERATOR_MAKE_PARAMS} > /dev/null 2>&1
INSTALL_COMMAND ${GENERATOR_MAKE} install > /dev/null 2>&1)