CMake: Provide files for config-mode find_package

This commit is contained in:
Sebastian Pipping 2019-08-29 23:47:01 +02:00
parent 442cb95d29
commit 716c53052b
6 changed files with 107 additions and 1 deletions

View File

@ -16,6 +16,7 @@ set(PACKAGE_VERSION "${PROJECT_VERSION}")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_TARNAME "${PACKAGE_NAME}") set(PACKAGE_TARNAME "${PACKAGE_NAME}")
include(CMakePackageConfigHelpers)
include(GNUInstallDirs) include(GNUInstallDirs)
# #
@ -251,7 +252,8 @@ if(NOT WIN32)
set_property(TARGET expat PROPERTY NO_SONAME ${NO_SONAME}) set_property(TARGET expat PROPERTY NO_SONAME ${NO_SONAME})
endif(NOT WIN32) 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} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
@ -376,6 +378,41 @@ expat_install(
DESTINATION DESTINATION
${CMAKE_INSTALL_DOCDIR}) ${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 # Summary
# #

View File

@ -29,6 +29,8 @@ Release x.x.x xxx xxx xx xxxx
-DUSE_SYS_GETRANDOM=(ON|OFF|AUTO) -DUSE_SYS_GETRANDOM=(ON|OFF|AUTO)
CMake: Add argument -DXML_LARGE_SIZE=ON CMake: Add argument -DXML_LARGE_SIZE=ON
CMake: Install expat_config.h to include directory 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: Now produces a summary of applied configuration
CMake: Require C++ compiler only when tests are enabled CMake: Require C++ compiler only when tests are enabled
#265 CMake: Fix linking with MinGW #265 CMake: Fix linking with MinGW

View File

@ -54,6 +54,8 @@ pkgconfigdir = $(libdir)/pkgconfig
_EXTRA_DIST_CMAKE = \ _EXTRA_DIST_CMAKE = \
cmake/expat-config.cmake.in \
\
CMakeLists.txt \ CMakeLists.txt \
CMake.README \ CMake.README \
ConfigureChecks.cmake \ ConfigureChecks.cmake \

3
expat/cmake/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/expat-config.cmake
/expat-config-version.cmake
/expat-targets.cmake

View File

@ -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)

View File

@ -49,6 +49,7 @@ Flags: ignoreversion; Source: CMake.README; DestDir: "{app}\Sour
Flags: ignoreversion; Source: CMakeLists.txt; DestDir: "{app}\Source" Flags: ignoreversion; Source: CMakeLists.txt; DestDir: "{app}\Source"
Flags: ignoreversion; Source: ConfigureChecks.cmake; DestDir: "{app}\Source" Flags: ignoreversion; Source: ConfigureChecks.cmake; DestDir: "{app}\Source"
Flags: ignoreversion; Source: expat_config.h.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\*.c; DestDir: "{app}\Source\lib"
Flags: ignoreversion; Source: lib\*.h; DestDir: "{app}\Source\lib" Flags: ignoreversion; Source: lib\*.h; DestDir: "{app}\Source\lib"
Flags: ignoreversion; Source: lib\*.def; DestDir: "{app}\Source\lib" Flags: ignoreversion; Source: lib\*.def; DestDir: "{app}\Source\lib"