diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index 9730bf00..ed9e8171 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -16,6 +16,7 @@ set(PACKAGE_VERSION "${PROJECT_VERSION}") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}") +include(CMakePackageConfigHelpers) include(GNUInstallDirs) # @@ -251,7 +252,8 @@ if(NOT WIN32) set_property(TARGET expat PROPERTY NO_SONAME ${NO_SONAME}) endif(NOT WIN32) -expat_install(TARGETS expat RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} +expat_install(TARGETS expat EXPORT expat + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) @@ -376,6 +378,41 @@ expat_install( DESTINATION ${CMAKE_INSTALL_DOCDIR}) +# +# CMake files for find_package(expat [..] CONFIG [..]) +# +configure_package_config_file( + cmake/expat-config.cmake.in + cmake/expat-config.cmake + INSTALL_DESTINATION + ${CMAKE_INSTALL_LIBDIR}/cmake/expat-${PROJECT_VERSION}/ +) +write_basic_package_version_file( + cmake/expat-config-version.cmake + COMPATIBILITY SameMajorVersion # i.e. semver +) +export( + TARGETS + expat + FILE + cmake/expat-targets.cmake # not going to be installed +) +expat_install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/cmake/expat-config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/cmake/expat-config-version.cmake + DESTINATION + ${CMAKE_INSTALL_LIBDIR}/cmake/expat-${PROJECT_VERSION}/ +) +expat_install( + EXPORT + expat + DESTINATION + ${CMAKE_INSTALL_LIBDIR}/cmake/expat-${PROJECT_VERSION}/ + NAMESPACE + expat:: +) + # # Summary # diff --git a/expat/Changes b/expat/Changes index d50ec869..5886b54e 100644 --- a/expat/Changes +++ b/expat/Changes @@ -29,6 +29,8 @@ Release x.x.x xxx xxx xx xxxx -DUSE_SYS_GETRANDOM=(ON|OFF|AUTO) CMake: Add argument -DXML_LARGE_SIZE=ON CMake: Install expat_config.h to include directory + CMake: Generate and install configuration files for + future find_package(expat [..] CONFIG [..]) CMake: Now produces a summary of applied configuration CMake: Require C++ compiler only when tests are enabled #265 CMake: Fix linking with MinGW diff --git a/expat/Makefile.am b/expat/Makefile.am index 561e2f1f..c3825e84 100644 --- a/expat/Makefile.am +++ b/expat/Makefile.am @@ -54,6 +54,8 @@ pkgconfigdir = $(libdir)/pkgconfig _EXTRA_DIST_CMAKE = \ + cmake/expat-config.cmake.in \ + \ CMakeLists.txt \ CMake.README \ ConfigureChecks.cmake \ diff --git a/expat/cmake/.gitignore b/expat/cmake/.gitignore new file mode 100644 index 00000000..89c8a280 --- /dev/null +++ b/expat/cmake/.gitignore @@ -0,0 +1,3 @@ +/expat-config.cmake +/expat-config-version.cmake +/expat-targets.cmake diff --git a/expat/cmake/expat-config.cmake.in b/expat/cmake/expat-config.cmake.in new file mode 100644 index 00000000..79af6aa3 --- /dev/null +++ b/expat/cmake/expat-config.cmake.in @@ -0,0 +1,61 @@ +# __ __ _ +# ___\ \/ /_ __ __ _| |_ +# / _ \\ /| '_ \ / _` | __| +# | __// \| |_) | (_| | |_ +# \___/_/\_\ .__/ \__,_|\__| +# |_| XML parser +# +# Copyright (c) 2019 Expat development team +# Licensed under the MIT license: +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to permit +# persons to whom the Software is furnished to do so, subject to the +# following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +# USE OR OTHER DEALINGS IN THE SOFTWARE. +# +if(NOT _expat_config_included) + # Protect against multiple inclusion + set(_expat_config_included TRUE) + + +include("${CMAKE_CURRENT_LIST_DIR}/expat.cmake") + +@PACKAGE_INIT@ + +# +# Supported components +# +macro(_register_component _NAME _AVAILABE) + set(expat_${_NAME}_FOUND ${_AVAILABE}) +endmacro() + +_register_component(attr_info @XML_ATTR_INFO@) +if(@XML_CONTEXT_BYTES@) + _register_component(context_bytes 1) +else() + _register_component(context_bytes 0) +endif() +_register_component(dtd @XML_DTD@) +_register_component(large_size @XML_LARGE_SIZE@) +_register_component(ns @XML_NS@) +_register_component(unicode @XML_UNICODE@) +_register_component(unicode_wchar_t @XML_UNICODE_WCHAR_T@) + +check_required_components(expat) + + +endif(NOT _expat_config_included) diff --git a/expat/win32/expat.iss b/expat/win32/expat.iss index 8150166d..4863a7d8 100644 --- a/expat/win32/expat.iss +++ b/expat/win32/expat.iss @@ -49,6 +49,7 @@ Flags: ignoreversion; Source: CMake.README; DestDir: "{app}\Sour Flags: ignoreversion; Source: CMakeLists.txt; DestDir: "{app}\Source" Flags: ignoreversion; Source: ConfigureChecks.cmake; DestDir: "{app}\Source" Flags: ignoreversion; Source: expat_config.h.cmake; DestDir: "{app}\Source" +Flags: ignoreversion; Source: cmake/expat-config.cmake.in; DestDir: "{app}\Source\cmake" Flags: ignoreversion; Source: lib\*.c; DestDir: "{app}\Source\lib" Flags: ignoreversion; Source: lib\*.h; DestDir: "{app}\Source\lib" Flags: ignoreversion; Source: lib\*.def; DestDir: "{app}\Source\lib"