diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2e15ede1..48a0410f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -137,6 +137,226 @@ jobs: - name: Install PHP run: cmake --install php-build/all-enabled + linux-externalproject-module: + runs-on: ubuntu-latest + name: Downloading dependencies with ExternalProject module on Linux + steps: + - name: Install base dependencies + run: | + sudo apt-get update + sudo apt-get -y install \ + build-essential \ + libssl-dev \ + libpcre2-dev \ + libbz2-dev \ + libcurl4-openssl-dev \ + libdb5.3++-dev \ + libenchant-2-dev \ + libgmp-dev \ + libc-client-dev \ + libkrb5-dev \ + unixodbc-dev \ + freetds-dev \ + apache2-dev \ + firebird-dev \ + libsodium-dev \ + libicu-dev \ + aspell \ + libaspell-dev \ + libavif-dev \ + libfreetype-dev \ + libjpeg-dev \ + libwebp-dev \ + libxpm-dev \ + libtidy-dev \ + libargon2-dev \ + libcapstone-dev \ + libedit-dev \ + libcdb-dev \ + liblmdb-dev \ + libqdbm-dev \ + libtokyocabinet-dev \ + libsnmp-dev \ + snmp \ + snmpd \ + snmp-mibs-downloader \ + libexpat1-dev \ + libacl1-dev \ + libapparmor-dev \ + libselinux1-dev \ + libsystemd-dev \ + libldap2-dev \ + libsasl2-dev \ + libpq-dev \ + libmm-dev \ + libdmalloc-dev \ + dovecot-core \ + dovecot-pop3d \ + dovecot-imapd \ + sendmail; + + - name: Install CMake + uses: lukka/get-cmake@latest + + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Build and install + run: | + cmake --preset all-enabled + cmake --build --preset all-enabled -j + + linux-conan: + runs-on: ubuntu-latest + name: Downloading dependencies with Conan on Linux + steps: + - name: Install packages + run: | + sudo apt-get update + sudo apt-get -y install \ + build-essential \ + freetds-dev \ + apache2-dev \ + firebird-dev \ + libc-client-dev \ + aspell \ + libaspell-dev \ + libcdb-dev \ + libtokyocabinet-dev \ + libsnmp-dev \ + libacl1-dev \ + libedit-dev \ + snmp \ + snmpd \ + snmp-mibs-downloader \ + libapparmor-dev \ + libpq-dev \ + libmm-dev \ + libsystemd-dev \ + libwebp-dev \ + libxpm-dev \ + liblmdb-dev \ + libonig-dev \ + libldap2-dev \ + libtidy-dev \ + libdmalloc-dev \ + dovecot-core \ + dovecot-pop3d \ + dovecot-imapd \ + sendmail; + + - name: Install CMake + uses: lukka/get-cmake@latest + + - name: Install Conan + uses: conan-io/setup-conan@v1 + + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Install dependencies with Conan + run: | + conan install cmake --output-folder=php-build/php --build=missing --profile:build=default --profile:host=default + + - name: Build and install + run: | + cmake --preset conan + cmake --build --preset conan -j + + linux-vcpkg: + runs-on: ubuntu-latest + name: Downloading dependencies with vcpkg on Linux + steps: + - name: Install base dependencies + run: | + sudo apt-get update + sudo apt-get -y install \ + build-essential \ + re2c \ + bison \ + libxml2-dev \ + libssl-dev \ + libpcre2-dev \ + libsqlite3-dev \ + libbz2-dev \ + libcurl4-openssl-dev \ + libdb5.3++-dev \ + libenchant-2-dev \ + libgmp-dev \ + libc-client-dev \ + libkrb5-dev \ + unixodbc-dev \ + freetds-dev \ + apache2-dev \ + firebird-dev \ + libsodium-dev \ + libicu-dev \ + libzip-dev \ + aspell \ + libaspell-dev \ + libavif-dev \ + libfreetype-dev \ + libjpeg-dev \ + libpng-dev \ + libwebp-dev \ + libxpm-dev \ + libonig-dev \ + libtidy-dev \ + libargon2-dev \ + libcapstone-dev \ + libedit-dev \ + libcdb-dev \ + liblmdb-dev \ + libqdbm-dev \ + libtokyocabinet-dev \ + libsnmp-dev \ + snmp \ + snmpd \ + snmp-mibs-downloader \ + libexpat1-dev \ + libacl1-dev \ + libapparmor-dev \ + libselinux1-dev \ + libsystemd-dev \ + libldap2-dev \ + libsasl2-dev \ + libpq-dev \ + libmm-dev \ + zlib1g-dev \ + libdmalloc-dev \ + dovecot-core \ + dovecot-pop3d \ + dovecot-imapd \ + sendmail; + + - name: Install CMake + uses: lukka/get-cmake@latest + + - name: Install vcpkg + run: | + sudo apt update + sudo apt install -y curl zip git + curl --output vcpkg.tar.gz https://github.com/microsoft/vcpkg/archive/master.tar.gz + sudo mkdir -p /opt/vcpkg + sudo tar xf vcpkg.tar.gz --strip-components=1 -C /opt/vcpkg + sudo /opt/vcpkg/bootstrap-vcpkg.sh + sudo ln -s /opt/vcpkg/vcpkg /usr/local/bin/vcpkg + sudo chmod a+x /usr/local/bin/vcpkg + + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Build and install + run: | + cmake --preset all-enabled + cmake --build --preset all-enabled -j + windows: runs-on: windows-latest name: Windows diff --git a/cmake/CMakePresets.json b/cmake/CMakePresets.json index 093537b1..e7bb6c32 100644 --- a/cmake/CMakePresets.json +++ b/cmake/CMakePresets.json @@ -3,6 +3,7 @@ "include": [ "cmake/presets/all-disabled.json", "cmake/presets/all-enabled.json", + "cmake/presets/conan.json", "cmake/presets/windows.json" ], "configurePresets": [ diff --git a/cmake/cmake/Configuration.cmake b/cmake/cmake/Configuration.cmake index e22410ae..7b74687f 100644 --- a/cmake/cmake/Configuration.cmake +++ b/cmake/cmake/Configuration.cmake @@ -199,15 +199,9 @@ endblock() # Minimum required version for the OpenSSL dependency. set(PHP_OPENSSL_MIN_VERSION 1.0.2) -# Minimum required version for the SQLite dependency. -set(PHP_SQLITE_MIN_VERSION 3.7.7) - # Minimum required version for the PostgreSQL dependency. set(PHP_POSTGRESQL_MIN_VERSION 9.1) -# Minimum required version for the zlib dependency. -set(PHP_ZLIB_MIN_VERSION 1.2.0.4) - # Additional metadata for external packages to avoid duplication. set_package_properties( BZip2 @@ -244,20 +238,6 @@ set_package_properties( DESCRIPTION "PostgreSQL database library" ) -set_package_properties( - SQLite3 - PROPERTIES - URL "https://www.sqlite.org/" - DESCRIPTION "SQL database engine library" -) - -set_package_properties( - ZLIB - PROPERTIES - URL "https://zlib.net/" - DESCRIPTION "Compression library" -) - # Set base directory for ExternalProject CMake module. set_directory_properties( PROPERTIES EP_BASE ${PHP_BINARY_DIR}/CMakeFiles/PHP/ExternalProject diff --git a/cmake/cmake/modules/FindLibXslt.cmake b/cmake/cmake/modules/FindLibXslt.cmake deleted file mode 100644 index 84d31afe..00000000 --- a/cmake/cmake/modules/FindLibXslt.cmake +++ /dev/null @@ -1,20 +0,0 @@ -#[=============================================================================[ -# FindLibXslt - -This module overrides the upstream CMake `FindLibXslt` module. - -See: https://cmake.org/cmake/help/latest/module/FindLibXslt.html -#]=============================================================================] - -include(FeatureSummary) - -set_package_properties( - LibXslt - PROPERTIES - URL "https://gitlab.gnome.org/GNOME/libxslt" - DESCRIPTION "XSLT processor library" -) - -# Find package with upstream CMake find module. Absolute path prevents the -# maximum nesting/recursion depth error on some systems, like macOS. -include(${CMAKE_ROOT}/Modules/FindLibXslt.cmake) diff --git a/cmake/cmake/modules/PHP/Package/LibXml2.cmake b/cmake/cmake/modules/PHP/Package/LibXml2.cmake new file mode 100644 index 00000000..a320efcc --- /dev/null +++ b/cmake/cmake/modules/PHP/Package/LibXml2.cmake @@ -0,0 +1,141 @@ +#[=============================================================================[ +# PHP/Package/LibXml2 + +Finds or downloads the libxml2 library: + +```cmake +include(PHP/Package/LibXml2) +``` + +This module first tries to find the libxml2 library on the system. If not found +it tries to download it from the upstream source and builds it together +with the PHP build. + +See: https://cmake.org/cmake/help/latest/module/FindLibXml2.html + +## Examples + +Basic usage: + +```cmake +# CMakeLists.txt +include(PHP/Package/LibXml2) +php_package_libxml2() +target_link_libraries(example PRIVATE LibXml2::LibXml2) +``` +#]=============================================================================] + +include(ExternalProject) +include(FeatureSummary) +include(FetchContent) +include(PHP/Package/_Internal) + +set_package_properties( + LibXml2 + PROPERTIES + URL "https://gitlab.gnome.org/GNOME/libxml2" + DESCRIPTION "XML parser and toolkit" +) + +# Minimum required version for the libxml2 dependency. +set(PHP_LIBXML2_MIN_VERSION 2.9.0) + +# Download version when system dependency is not found. +set(PHP_LIBXML2_DOWNLOAD_VERSION 2.14.5) + +set(PHP_LIBXML2_URL https://github.com/GNOME/libxml2/archive/refs/tags/v${PHP_LIBXML2_DOWNLOAD_VERSION}.tar.gz) + +macro(php_package_libxml2) + # LibXml2 depends on ZLIB. + include(PHP/Package/ZLIB) + + FetchContent_Declare( + LibXml2 + URL ${PHP_LIBXML2_URL} + SOURCE_SUBDIR non-existing + FIND_PACKAGE_ARGS ${PHP_LIBXML2_MIN_VERSION} + ) + + find_package(LibXml2 ${PHP_LIBXML2_MIN_VERSION}) + + if(PHP_USE_FETCHCONTENT) + if(NOT LibXml2_FOUND) + message(STATUS "Downloading ${PHP_LIBXML2_URL}") + endif() + + FetchContent_MakeAvailable(LibXml2) + + if(NOT LibXml2_FOUND) + _php_package_libxml2_init() + endif() + endif() + + get_property(PHP_LIBXML2_DOWNLOADED GLOBAL PROPERTY _PHP_LIBXML2_DOWNLOADED) + + if(PHP_LIBXML2_DOWNLOADED) + set(LibXml2_VERSION ${PHP_LIBXML2_DOWNLOAD_VERSION}) + endif() +endmacro() + +macro(_php_package_libxml2_init) + set( + options + -DBUILD_SHARED_LIBS=OFF + -DCMAKE_INSTALL_PREFIX= + -DLIBXML2_WITH_LZMA=OFF + -DLIBXML2_WITH_PYTHON=OFF + ) + + if(PHP_ZLIB_DOWNLOADED) + ExternalProject_Get_Property(ZLIB INSTALL_DIR) + list(APPEND options "-DZLIB_ROOT=${INSTALL_DIR}") + endif() + + # LibXml2 had hardcoded dl library check in versions <= 2.14.5. + # https://gitlab.gnome.org/GNOME/libxml2/-/merge_requests/331 + if( + CMAKE_SYSTEM_NAME STREQUAL "Haiku" + AND PHP_LIBXML2_DOWNLOAD_VERSION VERSION_LESS_EQUAL 2.14.5 + ) + list(APPEND options "-DLIBXML2_WITH_MODULES=OFF") + endif() + + ExternalProject_Add( + LibXml2 + STEP_TARGETS configure build install + SOURCE_DIR ${libxml2_SOURCE_DIR} + BINARY_DIR ${libxml2_BINARY_DIR} + CMAKE_ARGS ${options} + INSTALL_DIR ${FETCHCONTENT_BASE_DIR}/libxml2-install + INSTALL_BYPRODUCTS /lib/libxml2${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + + add_dependencies(LibXml2-configure ZLIB::ZLIB) + + ExternalProject_Get_Property(LibXml2 INSTALL_DIR) + + # Bypass missing directory error for the imported target below. + file(MAKE_DIRECTORY ${INSTALL_DIR}/include/libxml2) + + add_library(LibXml2::LibXml2 STATIC IMPORTED GLOBAL) + add_dependencies(LibXml2::LibXml2 LibXml2-install) + + set_target_properties( + LibXml2::LibXml2 + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include/libxml2 + IMPORTED_LOCATION ${INSTALL_DIR}/lib/libxml2${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + + php_package_mark_as_found(LibXml2) + + define_property( + GLOBAL + PROPERTY _PHP_LIBXML2_DOWNLOADED + BRIEF_DOCS "Marker that LibXml2 library will be downloaded" + ) + + set_property(GLOBAL PROPERTY _PHP_LIBXML2_DOWNLOADED TRUE) +endmacro() + +php_package_libxml2() diff --git a/cmake/cmake/modules/PHP/Package/LibXslt.cmake b/cmake/cmake/modules/PHP/Package/LibXslt.cmake new file mode 100644 index 00000000..4d14a2e2 --- /dev/null +++ b/cmake/cmake/modules/PHP/Package/LibXslt.cmake @@ -0,0 +1,132 @@ +#[=============================================================================[ +# PHP/Package/LibXslt + +Finds or downloads the libxslt library: + +```cmake +include(PHP/Package/LibXslt) +``` + +This module first tries to find the libxslt library on the system. If not found +it tries to download it from the upstream source and builds it together +with the PHP build. + +See: https://cmake.org/cmake/help/latest/module/FindLibXslt.html + +## Examples + +Basic usage: + +```cmake +# CMakeLists.txt +include(PHP/Package/LibXslt) +php_package_libxslt() +target_link_libraries(example PRIVATE LibXslt::LibXslt) +``` +#]=============================================================================] + +include(ExternalProject) +include(FeatureSummary) +include(FetchContent) +include(PHP/Package/_Internal) + +set_package_properties( + LibXslt + PROPERTIES + URL "https://gitlab.gnome.org/GNOME/libxslt" + DESCRIPTION "XSLT processor library" +) + +# Minimum required version for the libxslt dependency. +set(PHP_LIBXSLT_MIN_VERSION 1.1.0) + +# Download version when system dependency is not found. +set(PHP_LIBXSLT_DOWNLOAD_VERSION 1.1.43) + +set(PHP_LIBXSLT_URL https://github.com/GNOME/libxslt/archive/refs/tags/v${PHP_LIBXSLT_DOWNLOAD_VERSION}.tar.gz) + +macro(php_package_libxslt) + # LibXslt depends on LibXml2. + include(PHP/Package/LibXml2) + + FetchContent_Declare( + LibXslt + URL ${PHP_LIBXSLT_URL} + SOURCE_SUBDIR non-existing + FIND_PACKAGE_ARGS ${PHP_LIBXSLT_MIN_VERSION} + ) + + find_package(LibXslt ${PHP_LIBXSLT_MIN_VERSION}) + + if(PHP_USE_FETCHCONTENT) + if(NOT LibXslt_FOUND) + message(STATUS "Downloading ${PHP_LIBXSLT_URL}") + endif() + + FetchContent_MakeAvailable(LibXslt) + + if(NOT LibXslt_FOUND) + _php_package_libxslt_init() + endif() + endif() + + get_property(PHP_LIBXSLT_DOWNLOADED GLOBAL PROPERTY _PHP_LIBXSLT_DOWNLOADED) + + if(PHP_LIBXSLT_DOWNLOADED) + set(LibXslt_VERSION ${PHP_LIBXSLT_DOWNLOAD_VERSION}) + endif() +endmacro() + +macro(_php_package_libxslt_init) + set( + options + -DBUILD_SHARED_LIBS=OFF + -DCMAKE_INSTALL_PREFIX= + -DLIBXSLT_WITH_PYTHON=OFF + -DLIBXSLT_WITH_TESTS=OFF + ) + + if(PHP_LIBXML2_DOWNLOADED) + ExternalProject_Get_Property(LibXml2 INSTALL_DIR) + list(APPEND options "-DLIBXML2_ROOT=${INSTALL_DIR}") + endif() + + ExternalProject_Add( + LibXslt + STEP_TARGETS configure build install + SOURCE_DIR ${libxslt_SOURCE_DIR} + BINARY_DIR ${libxslt_BINARY_DIR} + CMAKE_ARGS ${options} + INSTALL_DIR ${FETCHCONTENT_BASE_DIR}/libxslt-install + INSTALL_BYPRODUCTS /lib/libxslt${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + + add_dependencies(LibXslt-configure LibXml2::LibXml2) + + ExternalProject_Get_Property(LibXslt INSTALL_DIR) + + # Bypass missing directory error for the imported target below. + file(MAKE_DIRECTORY ${INSTALL_DIR}/include/libxslt) + + add_library(LibXslt::LibXslt STATIC IMPORTED GLOBAL) + add_dependencies(LibXslt::LibXslt LibXslt-install) + + set_target_properties( + LibXslt::LibXslt + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include/libxslt + IMPORTED_LOCATION ${INSTALL_DIR}/lib/libxslt${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + + php_package_mark_as_found(LibXslt) + + define_property( + GLOBAL + PROPERTY _PHP_LIBXSLT_DOWNLOADED + BRIEF_DOCS "Marker that LibXslt library will be downloaded" + ) + + set_property(GLOBAL PROPERTY _PHP_LIBXSLT_DOWNLOADED TRUE) +endmacro() + +php_package_libxslt() diff --git a/cmake/cmake/modules/PHP/Package/Oniguruma.cmake b/cmake/cmake/modules/PHP/Package/Oniguruma.cmake new file mode 100644 index 00000000..b4d55043 --- /dev/null +++ b/cmake/cmake/modules/PHP/Package/Oniguruma.cmake @@ -0,0 +1,128 @@ +#[=============================================================================[ +# PHP/Package/Oniguruma + +Finds or downloads the Oniguruma library: + +```cmake +include(PHP/Package/Oniguruma) +``` + +This module first tries to find the Oniguruma library on the system. If not +found it downloads it from the upstream source during the main project +configuration phase and then configures and builds it during the main project's +build phase. + +The `FetchContent` module is used, which provides integration with other +dependency providers, such as Conan. + +## Examples + +Basic usage: + +```cmake +include(PHP/Package/Oniguruma) +php_package_oniguruma() +target_link_libraries(php_ext_foo PRIVATE Oniguruma::Oniguruma) +``` +#]=============================================================================] + +include(ExternalProject) +include(FeatureSummary) +include(FetchContent) +include(PHP/Package/_Internal) + +# Minimum required version for the Oniguruma dependency. +set(PHP_ONIGURUMA_MIN_VERSION 5.9.6) # This is the 1st tag available on GitHub. + +# Download version when system dependency is not found. +set(PHP_ONIGURUMA_DOWNLOAD_VERSION 6.9.10) + +set( + PHP_ONIGURUMA_URL + https://github.com/petk/oniguruma/archive/refs/tags/v${PHP_ONIGURUMA_DOWNLOAD_VERSION}.tar.gz +) + +macro(php_package_oniguruma) + if(PHP_DOWNLOAD_FORCE) + set(args OVERRIDE_FIND_PACKAGE) + else() + set(args FIND_PACKAGE_ARGS ${PHP_ONIGURUMA_MIN_VERSION}) + endif() + + FetchContent_Declare( + Oniguruma + URL ${PHP_ONIGURUMA_URL} + SOURCE_SUBDIR non-existing + ${args} + ) + + find_package(Oniguruma ${PHP_ONIGURUMA_MIN_VERSION}) + + if(PHP_USE_FETCHCONTENT) + if(NOT Oniguruma_FOUND) + message(STATUS "Downloading ${PHP_ONIGURUMA_URL}") + endif() + + FetchContent_MakeAvailable(Oniguruma) + + if(NOT Oniguruma_FOUND) + _php_package_oniguruma_init() + endif() + endif() + + get_property(PHP_ONIGURUMA_DOWNLOADED GLOBAL PROPERTY _PHP_ONIGURUMA_DOWNLOADED) + + if(PHP_ONIGURUMA_DOWNLOADED) + set(PHP_ONIG_KOI8 FALSE) + set(Oniguruma_VERSION ${PHP_ONIGURUMA_DOWNLOAD_VERSION}) + endif() +endmacro() + +macro(_php_package_oniguruma_init) + set(options "-DCMAKE_INSTALL_PREFIX=") + + list( + APPEND + options + -DINSTALL_DOCUMENTATION=OFF + -DBUILD_TEST=OFF + -DBUILD_SHARED_LIBS=OFF + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + ) + + ExternalProject_Add( + Oniguruma + STEP_TARGETS build install + SOURCE_DIR ${oniguruma_SOURCE_DIR} + BINARY_DIR ${oniguruma_BINARY_DIR} + CMAKE_ARGS ${options} + INSTALL_DIR ${FETCHCONTENT_BASE_DIR}/oniguruma-install + INSTALL_BYPRODUCTS /lib/libonig${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + + ExternalProject_Get_Property(Oniguruma INSTALL_DIR) + + # Bypass missing directory error for the imported target below. + file(MAKE_DIRECTORY ${INSTALL_DIR}/include) + + add_library(Oniguruma::Oniguruma STATIC IMPORTED GLOBAL) + add_dependencies(Oniguruma::Oniguruma Oniguruma-install) + set_target_properties( + Oniguruma::Oniguruma + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include + IMPORTED_LOCATION ${INSTALL_DIR}/lib/libonig${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + + php_package_mark_as_found(Oniguruma) + + define_property( + GLOBAL + PROPERTY _PHP_ONIGURUMA_DOWNLOADED + BRIEF_DOCS "Marker that Oniguruma library will be downloaded" + ) + + set_property(GLOBAL PROPERTY _PHP_ONIGURUMA_DOWNLOADED TRUE) +endmacro() + +php_package_oniguruma() diff --git a/cmake/cmake/modules/PHP/Package/PNG.cmake b/cmake/cmake/modules/PHP/Package/PNG.cmake new file mode 100644 index 00000000..bce1d4f1 --- /dev/null +++ b/cmake/cmake/modules/PHP/Package/PNG.cmake @@ -0,0 +1,125 @@ +#[=============================================================================[ +# PHP/Package/PNG + +Finds or downloads the PNG library: + +```cmake +include(PHP/Package/PNG) +``` + +Module first tries to find the PNG library on the system. If not +successful it tries to download it from the upstream source and builds it +together with the PHP build. + +See: https://cmake.org/cmake/help/latest/module/FindPNG.html + +## Examples + +Basic usage: + +```cmake +include(PHP/Package/PNG) +php_package_png() +target_link_libraries(php_ext_foo PRIVATE PNG::PNG) +``` +#]=============================================================================] + +include(ExternalProject) +include(FeatureSummary) +include(FetchContent) +include(PHP/Package/_Internal) + +set_package_properties( + PNG + PROPERTIES + URL "http://libpng.org" + DESCRIPTION "Portable Network Graphics (PNG image format) library" +) + +# Minimum required version for the PNG dependency. +set(PHP_PNG_MIN_VERSION 0.96) # for png_get_IHDR + +# Download version when system dependency is not found. +set(PHP_PNG_DOWNLOAD_VERSION 1.6.50) + +set(PHP_PNG_URL https://download.sourceforge.net/libpng/libpng-${PHP_PNG_DOWNLOAD_VERSION}.tar.gz) + +macro(php_package_png) + # PNG depends on ZLIB. + include(PHP/Package/ZLIB) + + FetchContent_Declare( + PNG + URL ${PHP_PNG_URL} + SOURCE_SUBDIR non-existing + FIND_PACKAGE_ARGS ${PHP_PNG_MIN_VERSION} + ) + + find_package(PNG ${PHP_PNG_MIN_VERSION}) + + if(PHP_USE_FETCHCONTENT) + if(NOT PNG_FOUND) + message(STATUS "Downloading ${PHP_PNG_URL}") + endif() + + FetchContent_MakeAvailable(PNG) + + if(NOT PNG_FOUND) + _php_package_png_init() + endif() + endif() + + get_property(PHP_PNG_DOWNLOADED GLOBAL PROPERTY _PHP_PNG_DOWNLOADED) + + if(PHP_PNG_DOWNLOADED) + set(PNG_VERSION ${PHP_PNG_DOWNLOAD_VERSION}) + endif() +endmacro() + +macro(_php_package_png_init) + set(options -DCMAKE_INSTALL_PREFIX= -DPNG_TESTS=OFF) + + if(PHP_ZLIB_DOWNLOADED) + ExternalProject_Get_Property(ZLIB INSTALL_DIR) + list(APPEND options "-DZLIB_ROOT=${INSTALL_DIR}") + endif() + + ExternalProject_Add( + PNG + STEP_TARGETS configure build install + SOURCE_DIR ${png_SOURCE_DIR} + BINARY_DIR ${png_BINARY_DIR} + CMAKE_ARGS ${options} + INSTALL_DIR ${FETCHCONTENT_BASE_DIR}/png-install + INSTALL_BYPRODUCTS /lib/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + + add_dependencies(PNG-configure ZLIB::ZLIB) + + ExternalProject_Get_Property(PNG INSTALL_DIR) + + # Bypass missing directory error for the imported target below. + file(MAKE_DIRECTORY ${INSTALL_DIR}/include) + + add_library(PNG::PNG STATIC IMPORTED GLOBAL) + add_dependencies(PNG::PNG PNG-install) + + set_target_properties( + PNG::PNG + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include + IMPORTED_LOCATION ${INSTALL_DIR}/lib/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + + php_package_mark_as_found(PNG) + + define_property( + GLOBAL + PROPERTY _PHP_PNG_DOWNLOADED + BRIEF_DOCS "Marker that PNG library will be downloaded" + ) + + set_property(GLOBAL PROPERTY _PHP_PNG_DOWNLOADED TRUE) +endmacro() + +php_package_png() diff --git a/cmake/cmake/modules/PHP/Package/SQLite3.cmake b/cmake/cmake/modules/PHP/Package/SQLite3.cmake new file mode 100644 index 00000000..76ec9a62 --- /dev/null +++ b/cmake/cmake/modules/PHP/Package/SQLite3.cmake @@ -0,0 +1,114 @@ +#[=============================================================================[ +# PHP/Package/SQLite3 + +Finds or downloads the SQLite library: + +```cmake +include(PHP/Package/SQLite3) +``` + +This module is a wrapper for finding the SQLite library. It first tries to +find the SQLite library on the system. If not successful it tries to download +it from the upstream source and builds it together with the PHP build. + +See: https://cmake.org/cmake/help/latest/module/FindSQLite3.html + +## Examples + +Basic usage: + +```cmake +include(PHP/Package/SQLite3) +php_package_sqlite3() +target_link_libraries(php_ext_foo PRIVATE SQLite::SQLite3) +``` +#]=============================================================================] + +include(ExternalProject) +include(FeatureSummary) +include(FetchContent) +include(PHP/Package/_Internal) + +set_package_properties( + SQLite3 + PROPERTIES + URL "https://www.sqlite.org/" + DESCRIPTION "SQL database engine library" +) + +# Minimum required version for the SQLite dependency. +set(PHP_SQLITE3_MIN_VERSION 3.7.7) + +# Download version when system dependency is not found. +set(PHP_SQLITE3_DOWNLOAD_VERSION 3.50.2) + +set(PHP_SQLITE3_URL) + +macro(php_package_sqlite3) + FetchContent_Declare( + SQLite3 + URL ${PHP_SQLITE3_URL} + SOURCE_SUBDIR non-existing + FIND_PACKAGE_ARGS ${PHP_SQLITE3_MIN_VERSION} + ) + + find_package(SQLite3 ${PHP_SQLITE3_MIN_VERSION}) + + if(PHP_USE_FETCHCONTENT) + if(NOT SQLite3_FOUND) + message(STATUS "Downloading ${PHP_SQLITE3_URL}") + endif() + + FetchContent_MakeAvailable(SQLite3) + + if(NOT SQLite3_FOUND) + _php_package_sqlite3_init() + endif() + endif() + + get_property(PHP_SQLITE3_DOWNLOADED GLOBAL PROPERTY _PHP_SQLITE3_DOWNLOADED) + + if(PHP_SQLITE3_DOWNLOADED) + set(SQLite3_VERSION ${PHP_SQLite3_DOWNLOAD_VERSION}) + endif() +endmacro() + +macro(_php_package_sqlite3_init) + set(options "-DCMAKE_INSTALL_PREFIX=") + + ExternalProject_Add( + SQLite3 + STEP_TARGETS build install + SOURCE_DIR ${sqlite3_SOURCE_DIR} + BINARY_DIR ${sqlite3_BINARY_DIR} + CMAKE_ARGS ${options} + INSTALL_DIR ${FETCHCONTENT_BASE_DIR}/sqlite3-install + INSTALL_BYPRODUCTS /lib/libsqlite3${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + + ExternalProject_Get_Property(SQLite3 INSTALL_DIR) + + # Bypass missing directory error for the imported target below. + file(MAKE_DIRECTORY ${INSTALL_DIR}/include) + + add_library(SQLite::SQLite3 STATIC IMPORTED GLOBAL) + add_dependencies(SQLite::SQLite3 SQLite3-install) + set_target_properties( + SQLite::SQLite3 + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include + IMPORTED_LOCATION ${INSTALL_DIR}/lib/libsqlite3${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + + php_package_mark_as_found(SQLite3) + + define_property( + GLOBAL + PROPERTY _PHP_SQLITE3_DOWNLOADED + BRIEF_DOCS "Marker that SQLite3 library will be downloaded" + ) + + set_property(GLOBAL PROPERTY _PHP_SQLITE3_DOWNLOADED TRUE) +endmacro() + +php_package_sqlite3() diff --git a/cmake/cmake/modules/PHP/Package/ZLIB.cmake b/cmake/cmake/modules/PHP/Package/ZLIB.cmake new file mode 100644 index 00000000..61d4a711 --- /dev/null +++ b/cmake/cmake/modules/PHP/Package/ZLIB.cmake @@ -0,0 +1,125 @@ +#[=============================================================================[ +# PHP/Package/Zlib + +Finds or downloads the zlib library: + +```cmake +include(PHP/Package/Zlib) +``` + +This module is a wrapper for finding the ZLIB library. It first tries to find +the `ZLIB` library on the system. If not successful it tries to download it from +the upstream source and builds it together with the PHP build. + +See: https://cmake.org/cmake/help/latest/module/FindZLIB.html + +## Examples + +Basic usage: + +```cmake +include(PHP/Package/ZLIB) +php_package_zlib() +target_link_libraries(php_ext_foo PRIVATE ZLIB::ZLIB) +``` +#]=============================================================================] + +include(ExternalProject) +include(FeatureSummary) +include(FetchContent) +include(PHP/Package/_Internal) + +set_package_properties( + ZLIB + PROPERTIES + URL "https://zlib.net/" + DESCRIPTION "Compression library" +) + +# Minimum required version for the zlib dependency. +set(PHP_ZLIB_MIN_VERSION 1.2.0.4) + +# Download version when system dependency is not found. +set(PHP_ZLIB_DOWNLOAD_VERSION 1.3.1) + +set( + PHP_ZLIB_URL + https://github.com/madler/zlib/archive/refs/tags/v${PHP_ZLIB_DOWNLOAD_VERSION}.tar.gz +) + +macro(php_package_zlib) + FetchContent_Declare( + ZLIB + URL ${PHP_ZLIB_URL} + SOURCE_SUBDIR non-existing + FIND_PACKAGE_ARGS ${PHP_ZLIB_MIN_VERSION} + ) + + find_package(ZLIB ${PHP_ZLIB_MIN_VERSION}) + + if(PHP_USE_FETCHCONTENT) + if(NOT ZLIB_FOUND) + message(STATUS "Downloading ${PHP_ZLIB_URL}") + endif() + + FetchContent_MakeAvailable(ZLIB) + + if(NOT ZLIB_FOUND) + _php_package_zlib_init() + endif() + endif() + + get_property(PHP_ZLIB_DOWNLOADED GLOBAL PROPERTY _PHP_ZLIB_DOWNLOADED) + + if(PHP_ZLIB_DOWNLOADED) + set(ZLIB_VERSION ${PHP_ZLIB_DOWNLOAD_VERSION}) + endif() +endmacro() + +macro(_php_package_zlib_init) + set(options "-DCMAKE_INSTALL_PREFIX=") + + if(PHP_ZLIB_DOWNLOAD_VERSION VERSION_LESS_EQUAL 1.3.1) + list(APPEND options -DZLIB_BUILD_EXAMPLES=OFF) + endif() + + if(PHP_ZLIB_DOWNLOAD_VERSION VERSION_GREATER 1.3.1) + list(APPEND options -DZLIB_BUILD_TESTING=OFF) + endif() + + ExternalProject_Add( + ZLIB + STEP_TARGETS build install + SOURCE_DIR ${zlib_SOURCE_DIR} + BINARY_DIR ${zlib_BINARY_DIR} + CMAKE_ARGS ${options} + INSTALL_DIR ${FETCHCONTENT_BASE_DIR}/zlib-install + INSTALL_BYPRODUCTS /lib/libz${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + + ExternalProject_Get_Property(ZLIB INSTALL_DIR) + + # Bypass missing directory error for the imported target below. + file(MAKE_DIRECTORY ${INSTALL_DIR}/include) + + add_library(ZLIB::ZLIB STATIC IMPORTED GLOBAL) + add_dependencies(ZLIB::ZLIB ZLIB-install) + set_target_properties( + ZLIB::ZLIB + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include + IMPORTED_LOCATION ${INSTALL_DIR}/lib/libz${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + + php_package_mark_as_found(ZLIB) + + define_property( + GLOBAL + PROPERTY _PHP_ZLIB_DOWNLOADED + BRIEF_DOCS "Marker that zlib library will be downloaded" + ) + + set_property(GLOBAL PROPERTY _PHP_ZLIB_DOWNLOADED TRUE) +endmacro() + +php_package_zlib() diff --git a/cmake/cmake/modules/PHP/Package/_Internal.cmake b/cmake/cmake/modules/PHP/Package/_Internal.cmake new file mode 100644 index 00000000..52869506 --- /dev/null +++ b/cmake/cmake/modules/PHP/Package/_Internal.cmake @@ -0,0 +1,19 @@ +include_guard(GLOBAL) + +option(PHP_USE_FETCHCONTENT "Use FetchContent for build-time dependencies." ON) +mark_as_advanced(PHP_USE_FETCHCONTENT) + +option(PHP_DOWNLOAD_FORCE "Whether to download dependencies regardless if found on the system") + +# Move package to PACKAGES_FOUND. +function(php_package_mark_as_found) + set(package "${ARGV0}") + get_property(packagesNotFound GLOBAL PROPERTY PACKAGES_NOT_FOUND) + list(REMOVE_ITEM packagesNotFound ${package}) + set_property(GLOBAL PROPERTY PACKAGES_NOT_FOUND ${packagesNotFound}) + get_property(packagesFound GLOBAL PROPERTY PACKAGES_FOUND) + list(FIND packagesFound ${package} found) + if(found EQUAL -1) + set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND ${package}) + endif() +endfunction() diff --git a/cmake/cmake/modules/PHP/Package/libzip.cmake b/cmake/cmake/modules/PHP/Package/libzip.cmake new file mode 100644 index 00000000..986b365b --- /dev/null +++ b/cmake/cmake/modules/PHP/Package/libzip.cmake @@ -0,0 +1,146 @@ +#[=============================================================================[ +# PHP/Package/libzip + +Finds or downloads libzip library: + +```cmake +include(PHP/Package/libzip +``` + +This module first tries to find the libzip library on the system. If not found +it downloads it from the upstream source and builds it together with the build. + +## Examples + +Basic usage: + +```cmake +include(PHP/Package/libzip) +php_package_libzip() +target_link_libraries(php_ext_foo PRIVATE libzip::zip) +``` +#]=============================================================================] + +include(ExternalProject) +include(FeatureSummary) +include(FetchContent) +include(PHP/Package/_Internal) + +# Minimum required version for the libzip dependency. +# Also accepted libzip version ranges are from 0.11-1.7 with 1.3.1 and 1.7.0 +# excluded due to upstream bugs. +set(PHP_LIBZIP_MIN_VERSION 1.7.1) + +# Download version when system dependency is not found. +set(PHP_LIBZIP_DOWNLOAD_VERSION 1.11.4) + +set( + PHP_LIBZIP_URL + https://github.com/nih-at/libzip/archive/refs/tags/v${PHP_libzip_DOWNLOAD_VERSION}.tar.gz +) + +macro(php_package_libzip) + # libzip depends on ZLIB + include(PHP/Package/ZLIB) + + FetchContent_Declare( + libzip + URL ${PHP_LIBZIP_URL} + SOURCE_SUBDIR non-existing + FIND_PACKAGE_ARGS ${PHP_LIBZIP_MIN_VERSION} + ) + + find_package(libzip ${PHP_LIBZIP_MIN_VERSION}) + + if(NOT libzip_FOUND) + find_package(libzip 1.3.2...1.6.999) + endif() + + if(NOT libzip_FOUND) + find_package(libzip 0.11...1.3.0) + endif() + + if(PHP_USE_FETCHCONTENT) + if(NOT libzip_FOUND) + message(STATUS "Downloading ${PHP_LIBZIP_URL}") + endif() + + FetchContent_MakeAvailable(libzip) + + if(NOT libzip_FOUND) + _php_package_libzip_init() + endif() + endif() + + get_property(PHP_LIBZIP_DOWNLOADED GLOBAL PROPERTY _PHP_LIBZIP_DOWNLOADED) + + if(PHP_LIBZIP_DOWNLOADED) + set(libzip_VERSION ${PHP_libzip_DOWNLOAD_VERSION}) + endif() +endmacro() + +macro(_php_package_libzip_init) + set( + options + -DCMAKE_INSTALL_PREFIX= + -DBUILD_DOC=OFF + -DBUILD_EXAMPLES=OFF + -DBUILD_REGRESS=OFF + -DBUILD_SHARED_LIBS=OFF + -DBUILD_TOOLS=OFF + ) + + if( + PHP_LIBZIP_DOWNLOAD_VERSION VERSION_GREATER_EQUAL 1.10 + AND CMAKE_SYSTEM_NAME STREQUAL "Windows" + ) + list(APPEND options -DENABLE_FDOPEN=OFF) + endif() + + if(PHP_LIBZIP_DOWNLOAD_VERSION VERSION_GREATER_EQUAL 1.11) + list(APPEND options -DBUILD_OSSFUZZ=OFF) + endif() + + if(PHP_ZLIB_DOWNLOADED) + ExternalProject_Get_Property(ZLIB INSTALL_DIR) + list(APPEND options "-DZLIB_ROOT=${INSTALL_DIR}") + endif() + + ExternalProject_Add( + libzip + STEP_TARGETS build install + SOURCE_DIR ${libzip_SOURCE_DIR} + BINARY_DIR ${libzip_BINARY_DIR} + CMAKE_ARGS ${options} + INSTALL_DIR ${FETCHCONTENT_BASE_DIR}/libzip-install + INSTALL_BYPRODUCTS /lib/libzip${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + + add_dependencies(libzip ZLIB::ZLIB) + + ExternalProject_Get_Property(libzip INSTALL_DIR) + + # Bypass missing directory error for the imported target below. + file(MAKE_DIRECTORY ${INSTALL_DIR}/include) + + add_library(libzip::zip STATIC IMPORTED GLOBAL) + add_dependencies(libzip::zip libzip-install) + set_target_properties( + libzip::zip + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include + IMPORTED_LOCATION ${INSTALL_DIR}/lib/libzip${CMAKE_STATIC_LIBRARY_SUFFIX} + ) + + php_package_mark_as_found(libzip) + + define_property( + GLOBAL + PROPERTY _PHP_LIBZIP_DOWNLOADED + BRIEF_DOCS "Marker that libzip library will be downloaded" + ) + + set_property(GLOBAL PROPERTY _PHP_LIBZIP_DOWNLOADED TRUE) +endmacro() + +php_package_libzip() diff --git a/cmake/cmake/modules/Packages/LibXml2.cmake b/cmake/cmake/modules/Packages/LibXml2.cmake deleted file mode 100644 index a940fe55..00000000 --- a/cmake/cmake/modules/Packages/LibXml2.cmake +++ /dev/null @@ -1,79 +0,0 @@ -#[=============================================================================[ -# Packages/LibXml2 - -Wrapper for finding the `libxml2` library. - -Module first tries to find the `libxml2` library on the system. If not -successful it tries to download it from the upstream source with `FetchContent` -module and build it together with the PHP build. - -See: https://cmake.org/cmake/help/latest/module/FindLibXml2.html - -The `FetchContent` CMake module does things differently compared to the -`find_package()` flow: -* By default, it uses `QUIET` in its `find_package()` call when calling the - `FetchContent_MakeAvailable()`; -* When using `FeatureSummary`, dependencies must be moved manually to - `PACKAGES_FOUND` from the `PACKAGES_NOT_FOUND` global property; - -TODO: Improve this. This is for now only initial `FetchContent` integration for -testing purposes and will be changed in the future. - -## Usage - -```cmake -# CMakeLists.txt -include(Packages/LibXml2) -``` -#]=============================================================================] - -include(FeatureSummary) -include(FetchContent) - -set_package_properties( - LibXml2 - PROPERTIES - URL "https://gitlab.gnome.org/GNOME/libxml2" - DESCRIPTION "XML parser and toolkit" -) - -# Minimum required version for the libxml2 dependency. -set(PHP_LIBXML2_MIN_VERSION 2.9.0) - -# Download version when system dependency is not found. -set(PHP_LIBXML2_DOWNLOAD_VERSION 2.14.4) - -FetchContent_Declare( - LibXml2 - URL https://github.com/GNOME/libxml2/archive/refs/tags/v${PHP_LIBXML2_DOWNLOAD_VERSION}.tar.gz - EXCLUDE_FROM_ALL - SYSTEM - FIND_PACKAGE_ARGS -) - -find_package(LibXml2 ${PHP_LIBXML2_MIN_VERSION}) - -if(NOT LibXml2_FOUND) - set(FETCHCONTENT_QUIET NO) - set(LIBXML2_WITH_PYTHON OFF) - set(LIBXML2_WITH_LZMA OFF) - - FetchContent_MakeAvailable(LibXml2) - - # Move dependency to PACKAGES_FOUND. - block() - get_property(packagesNotFound GLOBAL PROPERTY PACKAGES_NOT_FOUND) - list(REMOVE_ITEM packagesNotFound LibXml2) - set_property(GLOBAL PROPERTY PACKAGES_NOT_FOUND ${packagesNotFound}) - get_property(packagesFound GLOBAL PROPERTY PACKAGES_FOUND) - set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND LibXml2) - endblock() - - # Mark package as found. - set(LibXml2_FOUND TRUE) - - # Clean used variables. - unset(FETCHCONTENT_QUIET) - unset(LIBXML2_WITH_PYTHON) - unset(LIBXML2_WITH_LZMA) -endif() diff --git a/cmake/cmake/presets/conan.json b/cmake/cmake/presets/conan.json new file mode 100644 index 00000000..2c0ff849 --- /dev/null +++ b/cmake/cmake/presets/conan.json @@ -0,0 +1,36 @@ +{ + "version": 4, + "include": [ + "all-enabled.json" + ], + "configurePresets": [ + { + "name": "conan", + "inherits": "all-enabled", + "displayName": "All extensions enabled", + "description": "PHP configuration with all PHP extensions and SAPIs enabled", + "binaryDir": "${sourceDir}/php-build", + "installDir": "/tmp", + "toolchainFile": "${sourceDir}/php-build/php/build/Release/generators/conan_toolchain.cmake" + } + ], + "buildPresets": [ + { + "name": "conan", + "configurePreset": "conan" + } + ], + "testPresets": [ + { + "name": "conan", + "configurePreset": "conan", + "environment": { + "SKIP_IO_CAPTURE_TESTS": "1" + }, + "output": { + "shortProgress": true, + "verbosity": "verbose" + } + } + ] +} diff --git a/cmake/conanfile.txt b/cmake/conanfile.txt new file mode 100644 index 00000000..4f3a282c --- /dev/null +++ b/cmake/conanfile.txt @@ -0,0 +1,55 @@ +[requires] +#acl/2.3.1 # Builds ok, but CMake imported target name needs to be adjusted. +argon2/20190702 +bzip2/1.0.8 +#c-client/2007f # Builds ok, but CMake imported target name needs to be adjusted. +capstone/5.0.1 +cyrus-sasl/2.1.28 +#editline/3.1 # Builds ok, but CMake imported target name needs to be adjusted. +enchant/2.3.2 +expat/2.7.1 +freetype/2.13.3 +gmp/6.3.0 +icu/77.1 +krb5/1.21.2 +libavif/1.1.1 +libcurl/8.12.1 +libdb/5.3.28 +libjpeg/9e # Conflict when using libjpeg/9f. +#libjpeg-turbo/3.1.1 +libpng/1.6.50 +#libpq/17.5 # Builds ok, but CMake imported target name needs to be adjusted. +libselinux/3.5 # Conflict when using libselinux/3.6 due to glib/2.78.1 somewhere. +libsodium/1.0.20 +#libsystemd/255.10 # Causes conflicts due to libmount/2.39.2 somewhere. +#libwebp/1.3.2 # Conflict when using libwebp/1.5.0. + # Builds ok, but CMake imported target name needs to be adjusted. +libxml2/2.13.8 +#libxpm/3.5.17 # Build error due to missing system packages. +libxslt/1.1.43 +libzip/1.11.3 +#lmdb/0.9.32 # Builds ok, but CMake imported target name needs to be adjusted. +#net-snmp/5.9.4 # Builds ok, but CMake imported target name needs to be adjusted. +odbc/2.3.11 +#oniguruma/6.9.9 # Build error. +#openldap/2.6.7 # Builds ok, but checks in ext/ldap need to be adjusted. +openssl/3.5.1 +pcre/8.45 +qdbm/1.8.78 +sqlite3/3.49.1 +#tidy-html5/5.8.0 # Build error due to CMake minimum policy version. +zlib/1.3.1 + +[tool_requires] +bison/3.8.2 +re2c/4.0.2 + +[generators] +CMakeDeps +CMakeToolchain + +[options] +# Optionally set library options here. + +[layout] +cmake_layout diff --git a/cmake/ext/dom/CMakeLists.txt b/cmake/ext/dom/CMakeLists.txt index a156fbf2..eb08a403 100644 --- a/cmake/ext/dom/CMakeLists.txt +++ b/cmake/ext/dom/CMakeLists.txt @@ -95,7 +95,7 @@ target_compile_definitions( $<$,$,MODULE_LIBRARY;SHARED_LIBRARY>>>:LIBXML_STATIC> ) -include(Packages/LibXml2) +include(PHP/Package/LibXml2) set_package_properties( LibXml2 diff --git a/cmake/ext/gd/CMakeLists.txt b/cmake/ext/gd/CMakeLists.txt index fa679d05..6a94f293 100644 --- a/cmake/ext/gd/CMakeLists.txt +++ b/cmake/ext/gd/CMakeLists.txt @@ -316,7 +316,7 @@ if(NOT PHP_EXT_GD_EXTERNAL) ) endif() - find_package(ZLIB ${PHP_ZLIB_MIN_VERSION}) + include(PHP/Package/ZLIB) set_package_properties( ZLIB PROPERTIES @@ -326,7 +326,7 @@ if(NOT PHP_EXT_GD_EXTERNAL) target_link_libraries(php_ext_gd PRIVATE ZLIB::ZLIB) - find_package(PNG) + include(PHP/Package/PNG) set_package_properties( PNG PROPERTIES diff --git a/cmake/ext/libxml/CMakeLists.txt b/cmake/ext/libxml/CMakeLists.txt index 5388f018..f3c43312 100644 --- a/cmake/ext/libxml/CMakeLists.txt +++ b/cmake/ext/libxml/CMakeLists.txt @@ -64,7 +64,7 @@ target_compile_definitions( $<$:LIBXML_STATIC;LIBXML_STATIC_FOR_DLL> ) -include(Packages/LibXml2) +include(PHP/Package/LibXml2) set_package_properties( LibXml2 diff --git a/cmake/ext/mbstring/CMakeLists.txt b/cmake/ext/mbstring/CMakeLists.txt index 9921fc42..65bb5a14 100644 --- a/cmake/ext/mbstring/CMakeLists.txt +++ b/cmake/ext/mbstring/CMakeLists.txt @@ -130,7 +130,7 @@ file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libmbfl/config.h "\n" [[ ################################################################################ if(PHP_EXT_MBSTRING_MBREGEX) - find_package(Oniguruma) + include(PHP/Package/Oniguruma) set_package_properties( Oniguruma PROPERTIES diff --git a/cmake/ext/mysqlnd/CMakeLists.txt b/cmake/ext/mysqlnd/CMakeLists.txt index 6edf8a18..7b80d15c 100644 --- a/cmake/ext/mysqlnd/CMakeLists.txt +++ b/cmake/ext/mysqlnd/CMakeLists.txt @@ -170,7 +170,7 @@ target_link_libraries( ) if(PHP_EXT_MYSQLND_COMPRESSION) - find_package(ZLIB ${PHP_ZLIB_MIN_VERSION}) + include(PHP/Package/ZLIB) set_package_properties( ZLIB PROPERTIES diff --git a/cmake/ext/pdo_sqlite/CMakeLists.txt b/cmake/ext/pdo_sqlite/CMakeLists.txt index 97288d64..653ba568 100644 --- a/cmake/ext/pdo_sqlite/CMakeLists.txt +++ b/cmake/ext/pdo_sqlite/CMakeLists.txt @@ -75,7 +75,7 @@ target_include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. ) -find_package(SQLite3 ${PHP_SQLITE_MIN_VERSION}) +include(PHP/Package/SQLite3) set_package_properties( SQLite3 PROPERTIES diff --git a/cmake/ext/simplexml/CMakeLists.txt b/cmake/ext/simplexml/CMakeLists.txt index 957dcbf9..37b24940 100644 --- a/cmake/ext/simplexml/CMakeLists.txt +++ b/cmake/ext/simplexml/CMakeLists.txt @@ -78,7 +78,7 @@ target_compile_definitions( add_dependencies(php_ext_simplexml php_ext_libxml php_ext_spl) -include(Packages/LibXml2) +include(PHP/Package/LibXml2) set_package_properties( LibXml2 diff --git a/cmake/ext/soap/CMakeLists.txt b/cmake/ext/soap/CMakeLists.txt index 6864b649..c86341b0 100644 --- a/cmake/ext/soap/CMakeLists.txt +++ b/cmake/ext/soap/CMakeLists.txt @@ -76,7 +76,7 @@ target_compile_definitions( $<$,$,MODULE_LIBRARY;SHARED_LIBRARY>>>:LIBXML_STATIC> ) -include(Packages/LibXml2) +include(PHP/Package/LibXml2) set_package_properties( LibXml2 diff --git a/cmake/ext/sqlite3/CMakeLists.txt b/cmake/ext/sqlite3/CMakeLists.txt index 62ced86c..c9a34165 100644 --- a/cmake/ext/sqlite3/CMakeLists.txt +++ b/cmake/ext/sqlite3/CMakeLists.txt @@ -67,7 +67,7 @@ target_sources( target_compile_definitions(php_ext_sqlite3 PRIVATE ZEND_ENABLE_STATIC_TSRMLS_CACHE) -find_package(SQLite3 ${PHP_SQLITE_MIN_VERSION}) +include(PHP/Package/SQLite3) set_package_properties( SQLite3 PROPERTIES diff --git a/cmake/ext/xml/CMakeLists.txt b/cmake/ext/xml/CMakeLists.txt index 76c61fb0..e90fbc5c 100644 --- a/cmake/ext/xml/CMakeLists.txt +++ b/cmake/ext/xml/CMakeLists.txt @@ -109,7 +109,7 @@ if(NOT PHP_EXT_XML_EXPAT) $<$,$,MODULE_LIBRARY;SHARED_LIBRARY>>>:LIBXML_STATIC> ) - include(Packages/LibXml2) + include(PHP/Package/LibXml2) set_package_properties( LibXml2 diff --git a/cmake/ext/xmlreader/CMakeLists.txt b/cmake/ext/xmlreader/CMakeLists.txt index a8cb78b4..6fbc622b 100644 --- a/cmake/ext/xmlreader/CMakeLists.txt +++ b/cmake/ext/xmlreader/CMakeLists.txt @@ -70,7 +70,7 @@ target_compile_definitions( $<$,$,MODULE_LIBRARY;SHARED_LIBRARY>>>:LIBXML_STATIC> ) -include(Packages/LibXml2) +include(PHP/Package/LibXml2) set_package_properties( LibXml2 diff --git a/cmake/ext/xmlwriter/CMakeLists.txt b/cmake/ext/xmlwriter/CMakeLists.txt index fae036c0..de51829c 100644 --- a/cmake/ext/xmlwriter/CMakeLists.txt +++ b/cmake/ext/xmlwriter/CMakeLists.txt @@ -70,7 +70,7 @@ target_compile_definitions( $<$,$,MODULE_LIBRARY;SHARED_LIBRARY>>>:LIBXML_STATIC> ) -include(Packages/LibXml2) +include(PHP/Package/LibXml2) set_package_properties( LibXml2 diff --git a/cmake/ext/xsl/CMakeLists.txt b/cmake/ext/xsl/CMakeLists.txt index f3ec6856..36e19820 100644 --- a/cmake/ext/xsl/CMakeLists.txt +++ b/cmake/ext/xsl/CMakeLists.txt @@ -82,7 +82,7 @@ if(MSVC) ) endif() -include(Packages/LibXml2) +include(PHP/Package/LibXml2) set_package_properties( LibXml2 @@ -95,7 +95,7 @@ target_link_libraries(php_ext_xsl PRIVATE LibXml2::LibXml2) add_dependencies(php_ext_xsl php_ext_libxml php_ext_dom) -find_package(LibXslt 1.1.0) +include(PHP/Package/LibXslt) set_package_properties( LibXslt PROPERTIES diff --git a/cmake/ext/zend_test/CMakeLists.txt b/cmake/ext/zend_test/CMakeLists.txt index 63e11688..9dcb1f6d 100644 --- a/cmake/ext/zend_test/CMakeLists.txt +++ b/cmake/ext/zend_test/CMakeLists.txt @@ -82,7 +82,7 @@ target_compile_definitions( # If libxml extension is enabled, link libxml library as headers are used. # TODO: Reconfigure this for static/shared LibXml library on Windows. if(PHP_EXT_LIBXML) - include(Packages/LibXml2) + include(PHP/Package/LibXml2) set_package_properties( LibXml2 diff --git a/cmake/ext/zip/CMakeLists.txt b/cmake/ext/zip/CMakeLists.txt index 5de44ad6..642739a4 100644 --- a/cmake/ext/zip/CMakeLists.txt +++ b/cmake/ext/zip/CMakeLists.txt @@ -68,7 +68,7 @@ target_sources( add_dependencies(php_ext_zip php_ext_pcre) -find_package(libzip 1.7.1) +include(PHP/Package/libzip) set_package_properties( libzip PROPERTIES @@ -76,21 +76,6 @@ set_package_properties( PURPOSE "Necessary to enable the zip extension." ) -if(NOT libzip_FOUND) - find_package(libzip 1.3.2...1.6.999) -endif() - -if(NOT libzip_FOUND) - find_package(libzip 0.11...1.3.0) -endif() - -if(libzip_VERSION VERSION_EQUAL 1.3.1 OR libzip_VERSION VERSION_EQUAL 1.7.0) - message( - FATAL_ERROR - "ext/zip: libzip ${libzip_VERSION} is not supported. Try upgrading libzip." - ) -endif() - # Link publicly for internal_functions files. target_link_libraries(php_ext_zip PUBLIC libzip::zip) diff --git a/cmake/ext/zlib/CMakeLists.txt b/cmake/ext/zlib/CMakeLists.txt index 71d45585..74b7ab4b 100644 --- a/cmake/ext/zlib/CMakeLists.txt +++ b/cmake/ext/zlib/CMakeLists.txt @@ -77,7 +77,7 @@ endif() target_compile_definitions(php_ext_zlib PRIVATE ZEND_ENABLE_STATIC_TSRMLS_CACHE) -find_package(ZLIB ${PHP_ZLIB_MIN_VERSION}) +include(PHP/Package/ZLIB) set_package_properties( ZLIB PROPERTIES diff --git a/cmake/vcpkg.json b/cmake/vcpkg.json new file mode 100644 index 00000000..7b7b6a79 --- /dev/null +++ b/cmake/vcpkg.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", + "name": "php", + "version": "8.3-dev", + "dependencies": [ + "libxml2", + "libxslt", + "oniguruma", + "zlib" + ] +}