From b429525a0b3965b3680af430cb0b03246313ec6b Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 29 Aug 2019 23:08:35 +0200 Subject: [PATCH 1/9] CMake: Move expat_install up for upcoming use --- expat/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index 14d5dfb8..5d395bdc 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -138,6 +138,12 @@ if(NOT WIN32) evaluate_detection_results(USE_SYS_GETRANDOM HAVE_SYSCALL_GETRANDOM "syscall SYS_getrandom" "Syscall SYS_getrandom") endif() +macro(expat_install) + if(INSTALL) + install(${ARGN}) + endif() +endmacro() + configure_file(expat_config.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/expat_config.h") add_definitions(-DHAVE_EXPAT_CONFIG_H) @@ -250,12 +256,6 @@ if(NOT WIN32) set_property(TARGET expat PROPERTY NO_SONAME ${NO_SONAME}) endif(NOT WIN32) -macro(expat_install) - if(INSTALL) - install(${ARGN}) - endif() -endmacro() - expat_install(TARGETS expat RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) From 65ad42cb6f3bd3f64259eff6bec94c5eeaa09f0e Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 29 Aug 2019 23:09:26 +0200 Subject: [PATCH 2/9] CMake: Install expat_config.h to include directory --- expat/CMakeLists.txt | 1 + expat/Changes | 1 + 2 files changed, 2 insertions(+) diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index 5d395bdc..374f6255 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -146,6 +146,7 @@ endmacro() configure_file(expat_config.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/expat_config.h") add_definitions(-DHAVE_EXPAT_CONFIG_H) +expat_install(FILES "${CMAKE_CURRENT_BINARY_DIR}/expat_config.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) set(EXTRA_COMPILE_FLAGS) diff --git a/expat/Changes b/expat/Changes index 36c96158..47c5da15 100644 --- a/expat/Changes +++ b/expat/Changes @@ -27,6 +27,7 @@ Release x.x.x xxx xxx xx xxxx #239 #277 CMake: Add arguments -DUSE_GETRANDOM=(ON|OFF|AUTO) -DUSE_SYS_GETRANDOM=(ON|OFF|AUTO) + CMake: Install expat_config.h to include directory CMake: Now produces a summary of applied configuration CMake: Require C++ compiler only when tests are enabled #265 CMake: Fix linking with MinGW From cc5772f7dd02f277557b0de07a264c49be11ec7e Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 29 Aug 2019 23:19:44 +0200 Subject: [PATCH 3/9] CMake: Mimic lib/Makefile.am with regard to doc installation --- expat/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index 374f6255..7bb4eea4 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -371,6 +371,17 @@ if(BUILD_fuzzers) endforeach() endif(BUILD_fuzzers) +# +# Documentation +# +configure_file(Changes changelog COPYONLY) +expat_install( + FILES + AUTHORS + ${CMAKE_CURRENT_BINARY_DIR}/changelog + DESTINATION + ${CMAKE_INSTALL_DOCDIR}) + # # Summary # From d31810306a1ca37e4337b483afa400adc760dcf1 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Fri, 30 Aug 2019 00:13:30 +0200 Subject: [PATCH 4/9] CMake: Make expat_config.h.cmake match expat_config.h.in variable order --- expat/expat_config.h.cmake | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/expat/expat_config.h.cmake b/expat/expat_config.h.cmake index f92d4c94..87c54afb 100644 --- a/expat/expat_config.h.cmake +++ b/expat/expat_config.h.cmake @@ -78,31 +78,31 @@ /* whether byteorder is bigendian */ #cmakedefine WORDS_BIGENDIAN +/* Define to allow retrieving the byte offsets for attribute names and values. + */ +#cmakedefine XML_ATTR_INFO + /* Define to specify how much context to retain around the current parse point. */ #cmakedefine XML_CONTEXT_BYTES @XML_CONTEXT_BYTES@ +#if ! defined(_WIN32) +/* Define to include code reading entropy from `/dev/urandom'. */ + #cmakedefine XML_DEV_URANDOM +#endif + /* Define to make parameter entity parsing functionality available. */ #cmakedefine XML_DTD /* Define to make XML Namespaces functionality available. */ #cmakedefine XML_NS -#if ! defined(_WIN32) -/* Define to extract entropy from /dev/urandom. */ - #cmakedefine XML_DEV_URANDOM -#endif - /* Define to use UTF-16 chars (two bytes). */ #cmakedefine XML_UNICODE /* Define to use wchar_t as UTF-16 char type instead of unsigned short. */ #cmakedefine XML_UNICODE_WCHAR_T -/* Define to allow retrieving the byte offsets for attribute names and values. - */ -#cmakedefine XML_ATTR_INFO - /* Define to __FUNCTION__ or "" if `__func__' does not conform to ANSI C. */ #ifdef _MSC_VER # define __func__ __FUNCTION__ From 8666a6dfe8ea464fef6371ce3938dd0a38f1e047 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Fri, 30 Aug 2019 01:12:41 +0200 Subject: [PATCH 5/9] CMake: Fix PACKAGE_* variables in expat_config.h.cmake --- expat/expat_config.h.cmake | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/expat/expat_config.h.cmake b/expat/expat_config.h.cmake index 87c54afb..bb8c86cd 100644 --- a/expat/expat_config.h.cmake +++ b/expat/expat_config.h.cmake @@ -57,20 +57,26 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_UNISTD_H +/* Name of package */ +#define PACKAGE "@PACKAGE_NAME@" + /* Define to the address where bug reports for this package should be sent. */ -#cmakedefine PACKAGE_BUGREPORT +#cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@" /* Define to the full name of this package. */ -#cmakedefine PACKAGE_NAME +#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@" /* Define to the full name and version of this package. */ -#cmakedefine PACKAGE_STRING +#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@" /* Define to the one symbol short name of this package. */ -#cmakedefine PACKAGE_TARNAME +#cmakedefine PACKAGE_TARNAME "@PACKAGE_TARNAME@" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" /* Define to the version of this package. */ -#cmakedefine PACKAGE_VERSION +#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" /* Define to 1 if you have the ANSI C header files. */ #cmakedefine STDC_HEADERS From f9be0365a7ec86960ffa3aaa82508ff6f0b19ac0 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Fri, 30 Aug 2019 00:23:39 +0200 Subject: [PATCH 6/9] CMake: Extract macro expat_bool_to_int to reduce code duplication --- expat/CMakeLists.txt | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index 7bb4eea4..b004cdbc 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -86,31 +86,19 @@ if(NOT WIN32) endif(XML_DEV_URANDOM) endif() -if(XML_DTD) - set(XML_DTD 1) -else(XML_DTD) - set(XML_DTD 0) -endif(XML_DTD) -if(XML_NS) - set(XML_NS 1) -else(XML_NS) - set(XML_NS 0) -endif(XML_NS) -if(XML_UNICODE) - set(XML_UNICODE 1) -else(XML_UNICODE) - set(XML_UNICODE 0) -endif(XML_UNICODE) -if(XML_UNICODE_WCHAR_T) - set(XML_UNICODE_WCHAR_T 1) -else(XML_UNICODE_WCHAR_T) - set(XML_UNICODE_WCHAR_T 0) -endif(XML_UNICODE_WCHAR_T) -if(XML_ATTR_INFO) - set(XML_ATTR_INFO 1) -else(XML_ATTR_INFO) - set(XML_ATTR_INFO 0) -endif(XML_ATTR_INFO) +macro(expat_bool_to_int var_ref) + if(${var_ref}) + set(${var_ref} 1) + else() + set(${var_ref} 0) + endif() +endmacro() + +expat_bool_to_int(XML_ATTR_INFO) +expat_bool_to_int(XML_DTD) +expat_bool_to_int(XML_NS) +expat_bool_to_int(XML_UNICODE) +expat_bool_to_int(XML_UNICODE_WCHAR_T) if(XML_UNICODE_WCHAR_T AND NOT XML_UNICODE) message(SEND_ERROR "Option XML_UNICODE_WCHAR_T=ON may not be used without XML_UNICODE=ON.") From 442cb95d29a487df09e264b99218cd1519f51500 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Fri, 30 Aug 2019 00:47:54 +0200 Subject: [PATCH 7/9] CMake: Add argument -DXML_LARGE_SIZE=ON --- expat/CMakeLists.txt | 7 +++++++ expat/Changes | 1 + 2 files changed, 8 insertions(+) diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index b004cdbc..9730bf00 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -62,6 +62,7 @@ endif() option(XML_UNICODE "Use UTF-16 encoded chars (two bytes) instead of UTF-8" OFF) option(XML_UNICODE_WCHAR_T "Use wchar_t to represent UTF-16 instead of unsigned short" OFF) option(XML_ATTR_INFO "Define to allow retrieving the byte offsets for attribute names and values" OFF) +option(XML_LARGE_SIZE "Make XML_GetCurrent* functions return <(unsigned) long long> rather than <(unsigned) long>" OFF) if(MSVC) set(MSVC_USE_STATIC_CRT OFF CACHE BOOL "Use /MT flag (static CRT) when compiling in MSVC") endif() @@ -96,10 +97,15 @@ endmacro() expat_bool_to_int(XML_ATTR_INFO) expat_bool_to_int(XML_DTD) +expat_bool_to_int(XML_LARGE_SIZE) expat_bool_to_int(XML_NS) expat_bool_to_int(XML_UNICODE) expat_bool_to_int(XML_UNICODE_WCHAR_T) +if(XML_LARGE_SIZE) + add_definitions(-DXML_LARGE_SIZE) +endif() + if(XML_UNICODE_WCHAR_T AND NOT XML_UNICODE) message(SEND_ERROR "Option XML_UNICODE_WCHAR_T=ON may not be used without XML_UNICODE=ON.") set(XML_UNICODE 1) @@ -409,6 +415,7 @@ message(STATUS " Features") message(STATUS " Attributes info .......... ${XML_ATTR_INFO}") message(STATUS " Context bytes ............ ${XML_CONTEXT_BYTES}") message(STATUS " DTD support .............. ${XML_DTD}") +message(STATUS " Large size ............... ${XML_LARGE_SIZE}") message(STATUS " Namespace support ........ ${XML_NS}") message(STATUS "") message(STATUS " Entropy sources") diff --git a/expat/Changes b/expat/Changes index 47c5da15..d50ec869 100644 --- a/expat/Changes +++ b/expat/Changes @@ -27,6 +27,7 @@ Release x.x.x xxx xxx xx xxxx #239 #277 CMake: Add arguments -DUSE_GETRANDOM=(ON|OFF|AUTO) -DUSE_SYS_GETRANDOM=(ON|OFF|AUTO) + CMake: Add argument -DXML_LARGE_SIZE=ON CMake: Install expat_config.h to include directory CMake: Now produces a summary of applied configuration CMake: Require C++ compiler only when tests are enabled From 716c53052b77b4656b28b4bc16399313e07286c2 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Thu, 29 Aug 2019 23:47:01 +0200 Subject: [PATCH 8/9] CMake: Provide files for config-mode find_package --- expat/CMakeLists.txt | 39 +++++++++++++++++++- expat/Changes | 2 + expat/Makefile.am | 2 + expat/cmake/.gitignore | 3 ++ expat/cmake/expat-config.cmake.in | 61 +++++++++++++++++++++++++++++++ expat/win32/expat.iss | 1 + 6 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 expat/cmake/.gitignore create mode 100644 expat/cmake/expat-config.cmake.in 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" From f4accb1032c927ca48a1e8d889dec5a102bd6ae9 Mon Sep 17 00:00:00 2001 From: Sebastian Pipping Date: Fri, 30 Aug 2019 01:44:29 +0200 Subject: [PATCH 9/9] Changes: Enrich CMake related entries --- expat/Changes | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/expat/Changes b/expat/Changes index 5886b54e..de4a6764 100644 --- a/expat/Changes +++ b/expat/Changes @@ -23,13 +23,13 @@ Release x.x.x xxx xxx xx xxxx --with-sys-getrandom --without-sys-getrandom Autotools: Fix "make run-xmltest" for out-of-source builds - #244 #264 CMake: Add argument -DXML_ATTR_INFO=ON + #244 #264 CMake: Add argument -DXML_ATTR_INFO=(ON|OFF), default OFF #239 #277 CMake: Add arguments - -DUSE_GETRANDOM=(ON|OFF|AUTO) - -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 + -DUSE_GETRANDOM=(ON|OFF|AUTO), default AUTO + -DUSE_SYS_GETRANDOM=(ON|OFF|AUTO), default AUTO + #326 CMake: Add argument -DXML_LARGE_SIZE=(ON|OFF), default OFF + #326 CMake: Install expat_config.h to include directory + #326 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