From f7ae5bcde72c3330d337ef4c18275e3b943c50bf Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Tue, 19 Nov 2024 00:00:37 +0100 Subject: [PATCH 1/2] Download dependencies with FetchContent Added initial functionality for downloading dependencies or using dependency providers: - LibXml2 - libzip - Oniguruma - PNG - SQLite3 - ZLIB FetchContent module takes care of integrating with find_package() calls, downloads the sources at configure phase, or provides further integratation with dependency providers, while ExternalProject module takes care of isolation, when downloading sources without using dependency providers (such as Conan). Added initial Conan configuration. --- .github/workflows/ci.yaml | 131 ++++++++++++++++ cmake/CMakePresets.json | 1 + cmake/cmake/Configuration.cmake | 20 --- cmake/cmake/modules/PHP/Package/LibXml2.cmake | 148 ++++++++++++++++++ .../cmake/modules/PHP/Package/Oniguruma.cmake | 133 ++++++++++++++++ cmake/cmake/modules/PHP/Package/PNG.cmake | 133 ++++++++++++++++ cmake/cmake/modules/PHP/Package/SQLite3.cmake | 121 ++++++++++++++ cmake/cmake/modules/PHP/Package/ZLIB.cmake | 129 +++++++++++++++ cmake/cmake/modules/PHP/Package/libzip.cmake | 145 +++++++++++++++++ cmake/cmake/modules/Packages/LibXml2.cmake | 79 ---------- cmake/cmake/presets/conan.json | 36 +++++ cmake/conanfile.txt | 53 +++++++ cmake/ext/dom/CMakeLists.txt | 2 +- cmake/ext/gd/CMakeLists.txt | 4 +- cmake/ext/libxml/CMakeLists.txt | 2 +- cmake/ext/mbstring/CMakeLists.txt | 2 +- cmake/ext/mysqlnd/CMakeLists.txt | 2 +- cmake/ext/pdo_sqlite/CMakeLists.txt | 2 +- cmake/ext/simplexml/CMakeLists.txt | 2 +- cmake/ext/soap/CMakeLists.txt | 2 +- cmake/ext/sqlite3/CMakeLists.txt | 2 +- cmake/ext/xml/CMakeLists.txt | 2 +- cmake/ext/xmlreader/CMakeLists.txt | 2 +- cmake/ext/xmlwriter/CMakeLists.txt | 2 +- cmake/ext/xsl/CMakeLists.txt | 2 +- cmake/ext/zend_test/CMakeLists.txt | 2 +- cmake/ext/zip/CMakeLists.txt | 17 +- cmake/ext/zlib/CMakeLists.txt | 2 +- 28 files changed, 1047 insertions(+), 131 deletions(-) create mode 100644 cmake/cmake/modules/PHP/Package/LibXml2.cmake create mode 100644 cmake/cmake/modules/PHP/Package/Oniguruma.cmake create mode 100644 cmake/cmake/modules/PHP/Package/PNG.cmake create mode 100644 cmake/cmake/modules/PHP/Package/SQLite3.cmake create mode 100644 cmake/cmake/modules/PHP/Package/ZLIB.cmake create mode 100644 cmake/cmake/modules/PHP/Package/libzip.cmake delete mode 100644 cmake/cmake/modules/Packages/LibXml2.cmake create mode 100644 cmake/cmake/presets/conan.json create mode 100644 cmake/conanfile.txt diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2e15ede1..47511ee8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -137,6 +137,137 @@ 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 -y + 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 \ + libxslt1-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 -y + 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 + 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/PHP/Package/LibXml2.cmake b/cmake/cmake/modules/PHP/Package/LibXml2.cmake new file mode 100644 index 00000000..5ff8c78b --- /dev/null +++ b/cmake/cmake/modules/PHP/Package/LibXml2.cmake @@ -0,0 +1,148 @@ +#[=============================================================================[ +# 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) +target_link_libraries(example PRIVATE LibXml2::LibXml2) +``` +#]=============================================================================] + +include(ExternalProject) +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.5) + +macro(php_package_libxml2_find) + if(TARGET LibXml2::LibXml2) + set(LibXml2_FOUND TRUE) + get_property(LibXml2_DOWNLOADED GLOBAL PROPERTY _PHP_LibXml2_DOWNLOADED) + else() + # LibXml2 depends on ZLIB. + include(PHP/Package/ZLIB) + + find_package(LibXml2 ${PHP_LIBXML2_MIN_VERSION}) + + if(NOT LibXml2_FOUND) + _php_package_libxml2_download() + endif() + endif() +endmacro() + +macro(_php_package_libxml2_download) + message(STATUS "Downloading LibXml2 ${PHP_LIBXML2_DOWNLOAD_VERSION}") + + FetchContent_Declare( + LibXml2 + URL https://github.com/GNOME/libxml2/archive/refs/tags/v${PHP_LIBXML2_DOWNLOAD_VERSION}.tar.gz + SOURCE_SUBDIR non-existing + OVERRIDE_FIND_PACKAGE + ) + + FetchContent_MakeAvailable(LibXml2) + + set(options "-DCMAKE_INSTALL_PREFIX=") + list( + APPEND + options + -DLIBXML2_WITH_PYTHON=OFF + -DLIBXML2_WITH_LZMA=OFF + -DBUILD_SHARED_LIBS=OFF + ) + + if(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} + ) + + # Move dependency to PACKAGES_FOUND. + block() + set(package "LibXml2") + 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() + endblock() + + # Mark package as found. + set(LibXml2_FOUND TRUE) + + define_property( + GLOBAL + PROPERTY _PHP_LibXml2_DOWNLOADED + BRIEF_DOCS "Marker that LibXml2 library will be downloaded" + ) + + set_property(GLOBAL PROPERTY _PHP_LibXml2_DOWNLOADED TRUE) + set(Libxml2_DOWNLOADED TRUE) +endmacro() + +php_package_libxml2_find() diff --git a/cmake/cmake/modules/PHP/Package/Oniguruma.cmake b/cmake/cmake/modules/PHP/Package/Oniguruma.cmake new file mode 100644 index 00000000..3aa0c627 --- /dev/null +++ b/cmake/cmake/modules/PHP/Package/Oniguruma.cmake @@ -0,0 +1,133 @@ +#[=============================================================================[ +# 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) +target_link_libraries(php_ext_foo PRIVATE Oniguruma::Oniguruma) +``` +#]=============================================================================] + +include(ExternalProject) +include(FeatureSummary) +include(FetchContent) + +# 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) + +macro(php_package_oniguruma) + FetchContent_Declare( + Oniguruma + URL https://github.com/petk/oniguruma/archive/refs/tags/v${PHP_ONIGURUMA_DOWNLOAD_VERSION}.tar.gz + SOURCE_SUBDIR non-existing + FIND_PACKAGE_ARGS ${PHP_ONIGURUMA_MIN_VERSION} + ) + + #find_package(Oniguruma ${PHP_ONIGURUMA_MIN_VERSION}) + + FetchContent_MakeAvailable(Oniguruma) + + if(NOT Oniguruma_FOUND) + _php_package_oniguruma_init() + 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} + ) + + # Move dependency to PACKAGES_FOUND. + block() + set(package "Oniguruma") + 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() + endblock() + + define_property( + GLOBAL + PROPERTY _PHP_Oniguruma_DOWNLOADED + BRIEF_DOCS "Marker that Oniguruma library will be downloaded" + ) + + set_property(GLOBAL PROPERTY _PHP_Oniguruma_DOWNLOADED TRUE) + set(Oniguruma_DOWNLOADED TRUE) + + set(PHP_ONIG_KOI8 FALSE) +endmacro() + +php_package_oniguruma() + +macro(php_package_oniguruma_find) + if(TARGET Oniguruma::Oniguruma) + get_property(Oniguruma_DOWNLOADED GLOBAL PROPERTY _PHP_Oniguruma_DOWNLOADED) + set(PHP_ONIG_KOI8 FALSE) + else() + find_package(Oniguruma ${PHP_ONIGURUMA_MIN_VERSION}) + + if(NOT Oniguruma_FOUND) + _php_package_oniguruma_download() + endif() + endif() +endmacro() + +macro(_php_package_oniguruma_download) + message(STATUS "Downloading Oniguruma ${PHP_ONIGURUMA_DOWNLOAD_VERSION}") +endmacro() diff --git a/cmake/cmake/modules/PHP/Package/PNG.cmake b/cmake/cmake/modules/PHP/Package/PNG.cmake new file mode 100644 index 00000000..df5a9e28 --- /dev/null +++ b/cmake/cmake/modules/PHP/Package/PNG.cmake @@ -0,0 +1,133 @@ +#[=============================================================================[ +# 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) +target_link_libraries(php_ext_foo PRIVATE PNG::PNG) +``` +#]=============================================================================] + +include(ExternalProject) +include(FeatureSummary) +include(FetchContent) + +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) + +macro(php_package_png_find) + if(TARGET PNG::PNG) + set(PNG_FOUND TRUE) + get_property(PNG_DOWNLOADED GLOBAL PROPERTY _PHP_PNG_DOWNLOADED) + else() + # PNG depends on ZLIB. + include(PHP/Package/ZLIB) + + find_package(PNG ${PHP_PNG_MIN_VERSION}) + + if(NOT PNG_FOUND) + _php_package_png_download() + endif() + endif() +endmacro() + +macro(_php_package_png_download) + message(STATUS "Downloading PNG ${PHP_PNG_DOWNLOAD_VERSION}") + + FetchContent_Declare( + PNG + URL https://download.sourceforge.net/libpng/libpng-${PHP_PNG_DOWNLOAD_VERSION}.tar.gz + SOURCE_SUBDIR non-existing + OVERRIDE_FIND_PACKAGE + ) + + FetchContent_MakeAvailable(PNG) + + set(options "-DCMAKE_INSTALL_PREFIX=") + + if(ZLIB_DOWNLOADED) + ExternalProject_Get_Property(ZLIB INSTALL_DIR) + list(APPEND options "-DZLIB_ROOT=${INSTALL_DIR}") + endif() + + list(APPEND options -DPNG_TESTS=OFF) + + 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} + ) + + # Move dependency to PACKAGES_FOUND. + block() + set(package "PNG") + 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() + endblock() + + # Mark package as found. + set(PNG_FOUND TRUE) + + define_property( + GLOBAL + PROPERTY _PHP_PNG_DOWNLOADED + BRIEF_DOCS "Marker that PNG library will be downloaded" + ) + + set_property(GLOBAL PROPERTY _PHP_PNG_DOWNLOADED TRUE) + set(PNG_DOWNLOADED TRUE) +endmacro() + +php_package_png_find() diff --git a/cmake/cmake/modules/PHP/Package/SQLite3.cmake b/cmake/cmake/modules/PHP/Package/SQLite3.cmake new file mode 100644 index 00000000..af84d779 --- /dev/null +++ b/cmake/cmake/modules/PHP/Package/SQLite3.cmake @@ -0,0 +1,121 @@ +#[=============================================================================[ +# 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_find() +target_link_libraries(php_ext_foo PRIVATE SQLite::SQLite3) +``` +#]=============================================================================] + +include(ExternalProject) +include(FeatureSummary) +include(FetchContent) + +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) + +macro(php_package_sqlite3_find) + if(TARGET SQLite::SQLite3) + set(SQLite3_FOUND TRUE) + get_property(SQLite3_DOWNLOADED GLOBAL PROPERTY _PHP_SQLite3_DOWNLOADED) + else() + find_package(SQLite3 ${PHP_SQLITE3_MIN_VERSION}) + + if(NOT SQLite3_FOUND) + _php_package_sqlite3_download() + endif() + endif() +endmacro() + +macro(_php_package_sqlite3_download) + message(STATUS "Downloading SQLite ${PHP_SQLITE3_DOWNLOAD_VERSION}") + + FetchContent_Declare( + SQLite3 + URL https://github.com/sjinks/sqlite3-cmake/archive/refs/tags/v${PHP_SQLITE3_DOWNLOAD_VERSION}.tar.gz + SOURCE_SUBDIR non-existing + OVERRIDE_FIND_PACKAGE + ) + + FetchContent_MakeAvailable(SQLite3) + + 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} + ) + + # Move dependency to PACKAGES_FOUND. + block() + set(package "SQLite3") + 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() + endblock() + + # Mark package as found. + set(SQLite3_FOUND TRUE) + + define_property( + GLOBAL + PROPERTY _PHP_SQLite3_DOWNLOADED + BRIEF_DOCS "Marker that SQLite3 library will be downloaded" + ) + + set_property(GLOBAL PROPERTY _PHP_SQLite3_DOWNLOADED TRUE) + set(SQLite3_DOWNLOADED TRUE) +endmacro() + +php_package_sqlite3_find() diff --git a/cmake/cmake/modules/PHP/Package/ZLIB.cmake b/cmake/cmake/modules/PHP/Package/ZLIB.cmake new file mode 100644 index 00000000..a9ed5374 --- /dev/null +++ b/cmake/cmake/modules/PHP/Package/ZLIB.cmake @@ -0,0 +1,129 @@ +#[=============================================================================[ +# 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_find() +target_link_libraries(php_ext_foo PRIVATE ZLIB::ZLIB) +``` +#]=============================================================================] + +include(ExternalProject) +include(FeatureSummary) +include(FetchContent) + +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) + +macro(php_package_zlib_find) + if(TARGET ZLIB::ZLIB) + set(ZLIB_FOUND TRUE) + get_property(ZLIB_DOWNLOADED GLOBAL PROPERTY _PHP_ZLIB_DOWNLOADED) + else() + find_package(ZLIB ${PHP_ZLIB_MIN_VERSION}) + + if(NOT ZLIB_FOUND) + _php_package_zlib_download() + endif() + endif() +endmacro() + +macro(_php_package_zlib_download) + message(STATUS "Downloading ZLIB ${PHP_ZLIB_DOWNLOAD_VERSION}") + + FetchContent_Declare( + ZLIB + URL https://github.com/madler/zlib/archive/refs/tags/v${PHP_ZLIB_DOWNLOAD_VERSION}.tar.gz + SOURCE_SUBDIR non-existing + OVERRIDE_FIND_PACKAGE + ) + + FetchContent_MakeAvailable(ZLIB) + + 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} + ) + + # Move dependency to PACKAGES_FOUND. + block() + set(package "ZLIB") + 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() + endblock() + + # Mark package as found. + set(ZLIB_FOUND TRUE) + + define_property( + GLOBAL + PROPERTY _PHP_ZLIB_DOWNLOADED + BRIEF_DOCS "Marker that zlib library will be downloaded" + ) + + set_property(GLOBAL PROPERTY _PHP_ZLIB_DOWNLOADED TRUE) + set(ZLIB_DOWNLOADED TRUE) +endmacro() + +php_package_zlib_find() diff --git a/cmake/cmake/modules/PHP/Package/libzip.cmake b/cmake/cmake/modules/PHP/Package/libzip.cmake new file mode 100644 index 00000000..1b1b85d7 --- /dev/null +++ b/cmake/cmake/modules/PHP/Package/libzip.cmake @@ -0,0 +1,145 @@ +#[=============================================================================[ +# 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 +target_link_libraries(php_ext_foo PRIVATE libzip::zip) +``` +#]=============================================================================] + +include(ExternalProject) +include(FeatureSummary) +include(FetchContent) + +# 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) + +macro(php_package_libzip_find) + if(TARGET libzip::zip) + set(libzip_FOUND TRUE) + get_property(libzip_DOWNLOADED GLOBAL PROPERTY _PHP_libzip_DOWNLOADED) + get_property(libzip_VERSION GLOBAL PROPERTY _PHP_libzip_VERSION) + else() + # libzip depends on ZLIB + include(PHP/Package/ZLIB) + + 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(NOT libzip_FOUND) + _php_package_libzip_download() + else() + set_property( + GLOBAL PROPERTY _PHP_libzip_VERSION ${libzip_VERSION} + ) + endif() + endif() +endmacro() + +macro(_php_package_libzip_download) + message(STATUS "Downloading libzip ${PHP_libzip_DOWNLOAD_VERSION}") + + FetchContent_Declare( + libzip + URL https://github.com/nih-at/libzip/archive/refs/tags/v${PHP_libzip_DOWNLOAD_VERSION}.tar.gz + SOURCE_SUBDIR non-existing + OVERRIDE_FIND_PACKAGE + ) + + FetchContent_MakeAvailable(libzip) + + set(options "-DCMAKE_INSTALL_PREFIX=") + list(APPEND options -DBUILD_SHARED_LIBS=OFF) + + if(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} + ) + + # Move dependency to PACKAGES_FOUND. + block() + set(package "libzip") + 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() + endblock() + + # Mark package as found. + set(libzip_FOUND TRUE) + + define_property( + GLOBAL + PROPERTY _PHP_libzip_DOWNLOADED + BRIEF_DOCS "Marker that libzip library will be downloaded" + ) + + set_property(GLOBAL PROPERTY _PHP_libzip_DOWNLOADED TRUE) + set(libzip_DOWNLOADED TRUE) + + set_property( + GLOBAL PROPERTY _PHP_libzip_VERSION ${PHP_libzip_DOWNLOAD_VERSION} + ) + set(libzip_VERSION ${PHP_libzip_DOWNLOAD_VERSION}) +endmacro() + +macro(_php_package_libzip_set_vars) + +endmacro() + +php_package_libzip_find() 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..b74d68cc --- /dev/null +++ b/cmake/conanfile.txt @@ -0,0 +1,53 @@ +[requires] +#acl/2.3.1 # Builds ok, but CMake imported target name needs to be adjusted. +argon2/20190702 +bison/3.8.2 +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 +re2c/4.0.2 +sqlite3/3.49.1 +#tidy-html5/5.8.0 # Build error due to CMake minimum policy version. +zlib/1.3.1 + +[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..d49ca7f7 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 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 From 3766b2c91d5b3d241c527cb767d06ff98644f744 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Mon, 21 Jul 2025 23:39:04 +0200 Subject: [PATCH 2/2] Refactor package modules and download also LibXslt --- .github/workflows/ci.yaml | 95 ++++++++++++- cmake/cmake/modules/FindLibXslt.cmake | 20 --- cmake/cmake/modules/PHP/Package/LibXml2.cmake | 83 +++++------ cmake/cmake/modules/PHP/Package/LibXslt.cmake | 132 ++++++++++++++++++ .../cmake/modules/PHP/Package/Oniguruma.cmake | 75 +++++----- cmake/cmake/modules/PHP/Package/PNG.cmake | 76 +++++----- cmake/cmake/modules/PHP/Package/SQLite3.cmake | 73 +++++----- cmake/cmake/modules/PHP/Package/ZLIB.cmake | 70 +++++----- .../cmake/modules/PHP/Package/_Internal.cmake | 19 +++ cmake/cmake/modules/PHP/Package/libzip.cmake | 123 ++++++++-------- cmake/conanfile.txt | 6 +- cmake/ext/xsl/CMakeLists.txt | 2 +- cmake/vcpkg.json | 11 ++ 13 files changed, 494 insertions(+), 291 deletions(-) delete mode 100644 cmake/cmake/modules/FindLibXslt.cmake create mode 100644 cmake/cmake/modules/PHP/Package/LibXslt.cmake create mode 100644 cmake/cmake/modules/PHP/Package/_Internal.cmake create mode 100644 cmake/vcpkg.json diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 47511ee8..48a0410f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -143,7 +143,7 @@ jobs: steps: - name: Install base dependencies run: | - sudo apt-get update -y + sudo apt-get update sudo apt-get -y install \ build-essential \ libssl-dev \ @@ -170,7 +170,6 @@ jobs: libxpm-dev \ libtidy-dev \ libargon2-dev \ - libxslt1-dev \ libcapstone-dev \ libedit-dev \ libcdb-dev \ @@ -215,7 +214,7 @@ jobs: steps: - name: Install packages run: | - sudo apt-get update -y + sudo apt-get update sudo apt-get -y install \ build-essential \ freetds-dev \ @@ -268,6 +267,96 @@ jobs: 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/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 index 5ff8c78b..a320efcc 100644 --- a/cmake/cmake/modules/PHP/Package/LibXml2.cmake +++ b/cmake/cmake/modules/PHP/Package/LibXml2.cmake @@ -20,6 +20,7 @@ Basic usage: ```cmake # CMakeLists.txt include(PHP/Package/LibXml2) +php_package_libxml2() target_link_libraries(example PRIVATE LibXml2::LibXml2) ``` #]=============================================================================] @@ -27,6 +28,7 @@ target_link_libraries(example PRIVATE LibXml2::LibXml2) include(ExternalProject) include(FeatureSummary) include(FetchContent) +include(PHP/Package/_Internal) set_package_properties( LibXml2 @@ -41,44 +43,50 @@ set(PHP_LIBXML2_MIN_VERSION 2.9.0) # Download version when system dependency is not found. set(PHP_LIBXML2_DOWNLOAD_VERSION 2.14.5) -macro(php_package_libxml2_find) - if(TARGET LibXml2::LibXml2) - set(LibXml2_FOUND TRUE) - get_property(LibXml2_DOWNLOADED GLOBAL PROPERTY _PHP_LibXml2_DOWNLOADED) - else() - # LibXml2 depends on ZLIB. - include(PHP/Package/ZLIB) +set(PHP_LIBXML2_URL https://github.com/GNOME/libxml2/archive/refs/tags/v${PHP_LIBXML2_DOWNLOAD_VERSION}.tar.gz) - find_package(LibXml2 ${PHP_LIBXML2_MIN_VERSION}) - - if(NOT LibXml2_FOUND) - _php_package_libxml2_download() - endif() - endif() -endmacro() - -macro(_php_package_libxml2_download) - message(STATUS "Downloading LibXml2 ${PHP_LIBXML2_DOWNLOAD_VERSION}") +macro(php_package_libxml2) + # LibXml2 depends on ZLIB. + include(PHP/Package/ZLIB) FetchContent_Declare( LibXml2 - URL https://github.com/GNOME/libxml2/archive/refs/tags/v${PHP_LIBXML2_DOWNLOAD_VERSION}.tar.gz + URL ${PHP_LIBXML2_URL} SOURCE_SUBDIR non-existing - OVERRIDE_FIND_PACKAGE + FIND_PACKAGE_ARGS ${PHP_LIBXML2_MIN_VERSION} ) - FetchContent_MakeAvailable(LibXml2) + 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() - set(options "-DCMAKE_INSTALL_PREFIX=") - list( - APPEND +macro(_php_package_libxml2_init) + set( options - -DLIBXML2_WITH_PYTHON=OFF - -DLIBXML2_WITH_LZMA=OFF -DBUILD_SHARED_LIBS=OFF + -DCMAKE_INSTALL_PREFIX= + -DLIBXML2_WITH_LZMA=OFF + -DLIBXML2_WITH_PYTHON=OFF ) - if(ZLIB_DOWNLOADED) + if(PHP_ZLIB_DOWNLOADED) ExternalProject_Get_Property(ZLIB INSTALL_DIR) list(APPEND options "-DZLIB_ROOT=${INSTALL_DIR}") endif() @@ -119,30 +127,15 @@ macro(_php_package_libxml2_download) IMPORTED_LOCATION ${INSTALL_DIR}/lib/libxml2${CMAKE_STATIC_LIBRARY_SUFFIX} ) - # Move dependency to PACKAGES_FOUND. - block() - set(package "LibXml2") - 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() - endblock() - - # Mark package as found. - set(LibXml2_FOUND TRUE) + php_package_mark_as_found(LibXml2) define_property( GLOBAL - PROPERTY _PHP_LibXml2_DOWNLOADED + PROPERTY _PHP_LIBXML2_DOWNLOADED BRIEF_DOCS "Marker that LibXml2 library will be downloaded" ) - set_property(GLOBAL PROPERTY _PHP_LibXml2_DOWNLOADED TRUE) - set(Libxml2_DOWNLOADED TRUE) + set_property(GLOBAL PROPERTY _PHP_LIBXML2_DOWNLOADED TRUE) endmacro() -php_package_libxml2_find() +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 index 3aa0c627..b4d55043 100644 --- a/cmake/cmake/modules/PHP/Package/Oniguruma.cmake +++ b/cmake/cmake/modules/PHP/Package/Oniguruma.cmake @@ -21,6 +21,7 @@ Basic usage: ```cmake include(PHP/Package/Oniguruma) +php_package_oniguruma() target_link_libraries(php_ext_foo PRIVATE Oniguruma::Oniguruma) ``` #]=============================================================================] @@ -28,6 +29,7 @@ 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. @@ -35,20 +37,44 @@ 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 https://github.com/petk/oniguruma/archive/refs/tags/v${PHP_ONIGURUMA_DOWNLOAD_VERSION}.tar.gz + URL ${PHP_ONIGURUMA_URL} SOURCE_SUBDIR non-existing - FIND_PACKAGE_ARGS ${PHP_ONIGURUMA_MIN_VERSION} + ${args} ) - #find_package(Oniguruma ${PHP_ONIGURUMA_MIN_VERSION}) + 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() - FetchContent_MakeAvailable(Oniguruma) + get_property(PHP_ONIGURUMA_DOWNLOADED GLOBAL PROPERTY _PHP_ONIGURUMA_DOWNLOADED) - if(NOT Oniguruma_FOUND) - _php_package_oniguruma_init() + if(PHP_ONIGURUMA_DOWNLOADED) + set(PHP_ONIG_KOI8 FALSE) + set(Oniguruma_VERSION ${PHP_ONIGURUMA_DOWNLOAD_VERSION}) endif() endmacro() @@ -88,46 +114,15 @@ macro(_php_package_oniguruma_init) IMPORTED_LOCATION ${INSTALL_DIR}/lib/libonig${CMAKE_STATIC_LIBRARY_SUFFIX} ) - # Move dependency to PACKAGES_FOUND. - block() - set(package "Oniguruma") - 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() - endblock() + php_package_mark_as_found(Oniguruma) define_property( GLOBAL - PROPERTY _PHP_Oniguruma_DOWNLOADED + PROPERTY _PHP_ONIGURUMA_DOWNLOADED BRIEF_DOCS "Marker that Oniguruma library will be downloaded" ) - set_property(GLOBAL PROPERTY _PHP_Oniguruma_DOWNLOADED TRUE) - set(Oniguruma_DOWNLOADED TRUE) - - set(PHP_ONIG_KOI8 FALSE) + set_property(GLOBAL PROPERTY _PHP_ONIGURUMA_DOWNLOADED TRUE) endmacro() php_package_oniguruma() - -macro(php_package_oniguruma_find) - if(TARGET Oniguruma::Oniguruma) - get_property(Oniguruma_DOWNLOADED GLOBAL PROPERTY _PHP_Oniguruma_DOWNLOADED) - set(PHP_ONIG_KOI8 FALSE) - else() - find_package(Oniguruma ${PHP_ONIGURUMA_MIN_VERSION}) - - if(NOT Oniguruma_FOUND) - _php_package_oniguruma_download() - endif() - endif() -endmacro() - -macro(_php_package_oniguruma_download) - message(STATUS "Downloading Oniguruma ${PHP_ONIGURUMA_DOWNLOAD_VERSION}") -endmacro() diff --git a/cmake/cmake/modules/PHP/Package/PNG.cmake b/cmake/cmake/modules/PHP/Package/PNG.cmake index df5a9e28..bce1d4f1 100644 --- a/cmake/cmake/modules/PHP/Package/PNG.cmake +++ b/cmake/cmake/modules/PHP/Package/PNG.cmake @@ -7,7 +7,7 @@ Finds or downloads the PNG library: include(PHP/Package/PNG) ``` -Module first tries to find the `PNG` library on the system. If not +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. @@ -19,6 +19,7 @@ Basic usage: ```cmake include(PHP/Package/PNG) +php_package_png() target_link_libraries(php_ext_foo PRIVATE PNG::PNG) ``` #]=============================================================================] @@ -26,6 +27,7 @@ target_link_libraries(php_ext_foo PRIVATE PNG::PNG) include(ExternalProject) include(FeatureSummary) include(FetchContent) +include(PHP/Package/_Internal) set_package_properties( PNG @@ -40,43 +42,48 @@ 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) -macro(php_package_png_find) - if(TARGET PNG::PNG) - set(PNG_FOUND TRUE) - get_property(PNG_DOWNLOADED GLOBAL PROPERTY _PHP_PNG_DOWNLOADED) - else() - # PNG depends on ZLIB. - include(PHP/Package/ZLIB) +set(PHP_PNG_URL https://download.sourceforge.net/libpng/libpng-${PHP_PNG_DOWNLOAD_VERSION}.tar.gz) - find_package(PNG ${PHP_PNG_MIN_VERSION}) - - if(NOT PNG_FOUND) - _php_package_png_download() - endif() - endif() -endmacro() - -macro(_php_package_png_download) - message(STATUS "Downloading PNG ${PHP_PNG_DOWNLOAD_VERSION}") +macro(php_package_png) + # PNG depends on ZLIB. + include(PHP/Package/ZLIB) FetchContent_Declare( PNG - URL https://download.sourceforge.net/libpng/libpng-${PHP_PNG_DOWNLOAD_VERSION}.tar.gz + URL ${PHP_PNG_URL} SOURCE_SUBDIR non-existing - OVERRIDE_FIND_PACKAGE + FIND_PACKAGE_ARGS ${PHP_PNG_MIN_VERSION} ) - FetchContent_MakeAvailable(PNG) + find_package(PNG ${PHP_PNG_MIN_VERSION}) - set(options "-DCMAKE_INSTALL_PREFIX=") + if(PHP_USE_FETCHCONTENT) + if(NOT PNG_FOUND) + message(STATUS "Downloading ${PHP_PNG_URL}") + endif() + + FetchContent_MakeAvailable(PNG) - if(ZLIB_DOWNLOADED) + 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() - list(APPEND options -DPNG_TESTS=OFF) - ExternalProject_Add( PNG STEP_TARGETS configure build install @@ -104,21 +111,7 @@ macro(_php_package_png_download) IMPORTED_LOCATION ${INSTALL_DIR}/lib/libpng${CMAKE_STATIC_LIBRARY_SUFFIX} ) - # Move dependency to PACKAGES_FOUND. - block() - set(package "PNG") - 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() - endblock() - - # Mark package as found. - set(PNG_FOUND TRUE) + php_package_mark_as_found(PNG) define_property( GLOBAL @@ -127,7 +120,6 @@ macro(_php_package_png_download) ) set_property(GLOBAL PROPERTY _PHP_PNG_DOWNLOADED TRUE) - set(PNG_DOWNLOADED TRUE) endmacro() -php_package_png_find() +php_package_png() diff --git a/cmake/cmake/modules/PHP/Package/SQLite3.cmake b/cmake/cmake/modules/PHP/Package/SQLite3.cmake index af84d779..76ec9a62 100644 --- a/cmake/cmake/modules/PHP/Package/SQLite3.cmake +++ b/cmake/cmake/modules/PHP/Package/SQLite3.cmake @@ -7,8 +7,8 @@ Finds or downloads the SQLite library: 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 +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 @@ -19,7 +19,7 @@ Basic usage: ```cmake include(PHP/Package/SQLite3) -php_package_sqlite3_find() +php_package_sqlite3() target_link_libraries(php_ext_foo PRIVATE SQLite::SQLite3) ``` #]=============================================================================] @@ -27,6 +27,7 @@ target_link_libraries(php_ext_foo PRIVATE SQLite::SQLite3) include(ExternalProject) include(FeatureSummary) include(FetchContent) +include(PHP/Package/_Internal) set_package_properties( SQLite3 @@ -41,31 +42,38 @@ set(PHP_SQLITE3_MIN_VERSION 3.7.7) # Download version when system dependency is not found. set(PHP_SQLITE3_DOWNLOAD_VERSION 3.50.2) -macro(php_package_sqlite3_find) - if(TARGET SQLite::SQLite3) - set(SQLite3_FOUND TRUE) - get_property(SQLite3_DOWNLOADED GLOBAL PROPERTY _PHP_SQLite3_DOWNLOADED) - else() - find_package(SQLite3 ${PHP_SQLITE3_MIN_VERSION}) - - if(NOT SQLite3_FOUND) - _php_package_sqlite3_download() - endif() - endif() -endmacro() - -macro(_php_package_sqlite3_download) - message(STATUS "Downloading SQLite ${PHP_SQLITE3_DOWNLOAD_VERSION}") +set(PHP_SQLITE3_URL) +macro(php_package_sqlite3) FetchContent_Declare( SQLite3 - URL https://github.com/sjinks/sqlite3-cmake/archive/refs/tags/v${PHP_SQLITE3_DOWNLOAD_VERSION}.tar.gz + URL ${PHP_SQLITE3_URL} SOURCE_SUBDIR non-existing - OVERRIDE_FIND_PACKAGE + FIND_PACKAGE_ARGS ${PHP_SQLITE3_MIN_VERSION} ) - FetchContent_MakeAvailable(SQLite3) + 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( @@ -92,30 +100,15 @@ macro(_php_package_sqlite3_download) IMPORTED_LOCATION ${INSTALL_DIR}/lib/libsqlite3${CMAKE_STATIC_LIBRARY_SUFFIX} ) - # Move dependency to PACKAGES_FOUND. - block() - set(package "SQLite3") - 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() - endblock() - - # Mark package as found. - set(SQLite3_FOUND TRUE) + php_package_mark_as_found(SQLite3) define_property( GLOBAL - PROPERTY _PHP_SQLite3_DOWNLOADED + PROPERTY _PHP_SQLITE3_DOWNLOADED BRIEF_DOCS "Marker that SQLite3 library will be downloaded" ) - set_property(GLOBAL PROPERTY _PHP_SQLite3_DOWNLOADED TRUE) - set(SQLite3_DOWNLOADED TRUE) + set_property(GLOBAL PROPERTY _PHP_SQLITE3_DOWNLOADED TRUE) endmacro() -php_package_sqlite3_find() +php_package_sqlite3() diff --git a/cmake/cmake/modules/PHP/Package/ZLIB.cmake b/cmake/cmake/modules/PHP/Package/ZLIB.cmake index a9ed5374..61d4a711 100644 --- a/cmake/cmake/modules/PHP/Package/ZLIB.cmake +++ b/cmake/cmake/modules/PHP/Package/ZLIB.cmake @@ -7,7 +7,7 @@ Finds or downloads the zlib library: include(PHP/Package/Zlib) ``` -This module is a wrapper for finding the `ZLIB` library. It first tries to find +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. @@ -19,7 +19,7 @@ Basic usage: ```cmake include(PHP/Package/ZLIB) -php_package_zlib_find() +php_package_zlib() target_link_libraries(php_ext_foo PRIVATE ZLIB::ZLIB) ``` #]=============================================================================] @@ -27,6 +27,7 @@ target_link_libraries(php_ext_foo PRIVATE ZLIB::ZLIB) include(ExternalProject) include(FeatureSummary) include(FetchContent) +include(PHP/Package/_Internal) set_package_properties( ZLIB @@ -41,31 +42,41 @@ 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) -macro(php_package_zlib_find) - if(TARGET ZLIB::ZLIB) - set(ZLIB_FOUND TRUE) - get_property(ZLIB_DOWNLOADED GLOBAL PROPERTY _PHP_ZLIB_DOWNLOADED) - else() - find_package(ZLIB ${PHP_ZLIB_MIN_VERSION}) - - if(NOT ZLIB_FOUND) - _php_package_zlib_download() - endif() - endif() -endmacro() - -macro(_php_package_zlib_download) - message(STATUS "Downloading ZLIB ${PHP_ZLIB_DOWNLOAD_VERSION}") +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 https://github.com/madler/zlib/archive/refs/tags/v${PHP_ZLIB_DOWNLOAD_VERSION}.tar.gz + URL ${PHP_ZLIB_URL} SOURCE_SUBDIR non-existing - OVERRIDE_FIND_PACKAGE + FIND_PACKAGE_ARGS ${PHP_ZLIB_MIN_VERSION} ) - FetchContent_MakeAvailable(ZLIB) + 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) @@ -100,21 +111,7 @@ macro(_php_package_zlib_download) IMPORTED_LOCATION ${INSTALL_DIR}/lib/libz${CMAKE_STATIC_LIBRARY_SUFFIX} ) - # Move dependency to PACKAGES_FOUND. - block() - set(package "ZLIB") - 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() - endblock() - - # Mark package as found. - set(ZLIB_FOUND TRUE) + php_package_mark_as_found(ZLIB) define_property( GLOBAL @@ -123,7 +120,6 @@ macro(_php_package_zlib_download) ) set_property(GLOBAL PROPERTY _PHP_ZLIB_DOWNLOADED TRUE) - set(ZLIB_DOWNLOADED TRUE) endmacro() -php_package_zlib_find() +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 index 1b1b85d7..986b365b 100644 --- a/cmake/cmake/modules/PHP/Package/libzip.cmake +++ b/cmake/cmake/modules/PHP/Package/libzip.cmake @@ -15,7 +15,8 @@ it downloads it from the upstream source and builds it together with the build. Basic usage: ```cmake -include(PHP/Package/libzip +include(PHP/Package/libzip) +php_package_libzip() target_link_libraries(php_ext_foo PRIVATE libzip::zip) ``` #]=============================================================================] @@ -23,60 +24,84 @@ 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) +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_DOWNLOAD_VERSION 1.11.4) -macro(php_package_libzip_find) - if(TARGET libzip::zip) - set(libzip_FOUND TRUE) - get_property(libzip_DOWNLOADED GLOBAL PROPERTY _PHP_libzip_DOWNLOADED) - get_property(libzip_VERSION GLOBAL PROPERTY _PHP_libzip_VERSION) - else() - # libzip depends on ZLIB - include(PHP/Package/ZLIB) +set( + PHP_LIBZIP_URL + https://github.com/nih-at/libzip/archive/refs/tags/v${PHP_libzip_DOWNLOAD_VERSION}.tar.gz +) - find_package(libzip ${PHP_libzip_MIN_VERSION}) +macro(php_package_libzip) + # libzip depends on ZLIB + include(PHP/Package/ZLIB) - if(NOT libzip_FOUND) - find_package(libzip 1.3.2...1.6.999) - endif() + 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) - find_package(libzip 0.11...1.3.0) + message(STATUS "Downloading ${PHP_LIBZIP_URL}") endif() + FetchContent_MakeAvailable(libzip) + if(NOT libzip_FOUND) - _php_package_libzip_download() - else() - set_property( - GLOBAL PROPERTY _PHP_libzip_VERSION ${libzip_VERSION} - ) + _php_package_libzip_init() endif() endif() -endmacro() -macro(_php_package_libzip_download) - message(STATUS "Downloading libzip ${PHP_libzip_DOWNLOAD_VERSION}") + get_property(PHP_LIBZIP_DOWNLOADED GLOBAL PROPERTY _PHP_LIBZIP_DOWNLOADED) - FetchContent_Declare( - libzip - URL https://github.com/nih-at/libzip/archive/refs/tags/v${PHP_libzip_DOWNLOAD_VERSION}.tar.gz - SOURCE_SUBDIR non-existing - OVERRIDE_FIND_PACKAGE + 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 ) - FetchContent_MakeAvailable(libzip) + if( + PHP_LIBZIP_DOWNLOAD_VERSION VERSION_GREATER_EQUAL 1.10 + AND CMAKE_SYSTEM_NAME STREQUAL "Windows" + ) + list(APPEND options -DENABLE_FDOPEN=OFF) + endif() - set(options "-DCMAKE_INSTALL_PREFIX=") - list(APPEND options -DBUILD_SHARED_LIBS=OFF) + if(PHP_LIBZIP_DOWNLOAD_VERSION VERSION_GREATER_EQUAL 1.11) + list(APPEND options -DBUILD_OSSFUZZ=OFF) + endif() - if(ZLIB_DOWNLOADED) + if(PHP_ZLIB_DOWNLOADED) ExternalProject_Get_Property(ZLIB INSTALL_DIR) list(APPEND options "-DZLIB_ROOT=${INSTALL_DIR}") endif() @@ -107,39 +132,15 @@ macro(_php_package_libzip_download) IMPORTED_LOCATION ${INSTALL_DIR}/lib/libzip${CMAKE_STATIC_LIBRARY_SUFFIX} ) - # Move dependency to PACKAGES_FOUND. - block() - set(package "libzip") - 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() - endblock() - - # Mark package as found. - set(libzip_FOUND TRUE) + php_package_mark_as_found(libzip) define_property( GLOBAL - PROPERTY _PHP_libzip_DOWNLOADED + PROPERTY _PHP_LIBZIP_DOWNLOADED BRIEF_DOCS "Marker that libzip library will be downloaded" ) - set_property(GLOBAL PROPERTY _PHP_libzip_DOWNLOADED TRUE) - set(libzip_DOWNLOADED TRUE) - - set_property( - GLOBAL PROPERTY _PHP_libzip_VERSION ${PHP_libzip_DOWNLOAD_VERSION} - ) - set(libzip_VERSION ${PHP_libzip_DOWNLOAD_VERSION}) -endmacro() - -macro(_php_package_libzip_set_vars) - + set_property(GLOBAL PROPERTY _PHP_LIBZIP_DOWNLOADED TRUE) endmacro() -php_package_libzip_find() +php_package_libzip() diff --git a/cmake/conanfile.txt b/cmake/conanfile.txt index b74d68cc..4f3a282c 100644 --- a/cmake/conanfile.txt +++ b/cmake/conanfile.txt @@ -1,7 +1,6 @@ [requires] #acl/2.3.1 # Builds ok, but CMake imported target name needs to be adjusted. argon2/20190702 -bison/3.8.2 bzip2/1.0.8 #c-client/2007f # Builds ok, but CMake imported target name needs to be adjusted. capstone/5.0.1 @@ -37,11 +36,14 @@ odbc/2.3.11 openssl/3.5.1 pcre/8.45 qdbm/1.8.78 -re2c/4.0.2 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 diff --git a/cmake/ext/xsl/CMakeLists.txt b/cmake/ext/xsl/CMakeLists.txt index d49ca7f7..36e19820 100644 --- a/cmake/ext/xsl/CMakeLists.txt +++ b/cmake/ext/xsl/CMakeLists.txt @@ -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/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" + ] +}