mirror of
https://github.com/libexpat/libexpat.git
synced 2025-04-13 00:02:54 +00:00
Merge pull request #326 from libexpat/cmake-improvements
CMake improvements
This commit is contained in:
commit
feebc5c330
7 changed files with 170 additions and 49 deletions
|
@ -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)
|
||||
|
||||
#
|
||||
|
@ -62,6 +63,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()
|
||||
|
@ -86,31 +88,24 @@ 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_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.")
|
||||
|
@ -138,8 +133,15 @@ 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)
|
||||
expat_install(FILES "${CMAKE_CURRENT_BINARY_DIR}/expat_config.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
|
||||
set(EXTRA_COMPILE_FLAGS)
|
||||
|
@ -250,13 +252,8 @@ 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}
|
||||
expat_install(TARGETS expat EXPORT expat
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
|
@ -370,6 +367,52 @@ 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})
|
||||
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
@ -409,6 +452,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")
|
||||
|
|
|
@ -23,10 +23,14 @@ 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)
|
||||
-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
|
||||
#265 CMake: Fix linking with MinGW
|
||||
|
|
|
@ -54,6 +54,8 @@ pkgconfigdir = $(libdir)/pkgconfig
|
|||
|
||||
|
||||
_EXTRA_DIST_CMAKE = \
|
||||
cmake/expat-config.cmake.in \
|
||||
\
|
||||
CMakeLists.txt \
|
||||
CMake.README \
|
||||
ConfigureChecks.cmake \
|
||||
|
|
3
expat/cmake/.gitignore
vendored
Normal file
3
expat/cmake/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
/expat-config.cmake
|
||||
/expat-config-version.cmake
|
||||
/expat-targets.cmake
|
61
expat/cmake/expat-config.cmake.in
Normal file
61
expat/cmake/expat-config.cmake.in
Normal 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)
|
|
@ -57,20 +57,26 @@
|
|||
/* Define to 1 if you have the <unistd.h> 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
|
||||
|
@ -78,31 +84,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__
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Add table
Reference in a new issue