From e1435a662086efeaf009904277fc702f7143e2f2 Mon Sep 17 00:00:00 2001 From: Joerg-Christian Boehme Date: Mon, 22 Apr 2019 23:47:11 +0200 Subject: [PATCH] Fix cross-compilation against Poco pre-built (#2599) (#2679) * Use ZLIB and PCRE imported target to improve portability * Set EXPAT and SQLite3 library for XML and SQL if POCO_UNBUNDLED is true in cmake build --- CMakeLists.txt | 17 ++- Data/SQLite/CMakeLists.txt | 4 +- Data/SQLite/cmake/PocoDataSQLiteConfig.cmake | 7 ++ Foundation/CMakeLists.txt | 11 +- Foundation/cmake/PocoFoundationConfig.cmake | 9 +- PDF/CMakeLists.txt | 9 +- PDF/cmake/PocoPDFConfig.cmake | 4 + XML/CMakeLists.txt | 4 +- XML/cmake/PocoXMLConfig.cmake | 7 ++ cmake/FindPCRE.cmake | 126 +++++++++++++++---- cmake/FindSQLite3.cmake | 87 ------------- cmake/V313/FindSQLite3.cmake | 66 ++++++++++ cmake/V39/FindEXPAT.cmake | 79 ++++++++++++ 13 files changed, 301 insertions(+), 129 deletions(-) delete mode 100644 cmake/FindSQLite3.cmake create mode 100644 cmake/V313/FindSQLite3.cmake create mode 100644 cmake/V39/FindEXPAT.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 372f7393f..412b8f0c3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,9 +24,15 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) # Append our module directory to CMake list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -if(${CMAKE_VERSION} VERSION_LESS "3.4") +if(CMAKE_VERSION VERSION_LESS "3.4") list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/V33) endif() +if(CMAKE_VERSION VERSION_LESS "3.10") + list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/V39) +endif() +if(CMAKE_VERSION VERSION_LESS "3.14") + list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/V313) +endif() ################################################################################# # Setup C/C++ compiler options ################################################################################# @@ -436,6 +442,15 @@ install( Devel ) +if(POCO_UNBUNDLED) + install(FILES cmake/FindPCRE.cmake + DESTINATION "${PocoConfigPackageLocation}") + install(FILES cmake/V39/FindEXPAT.cmake + DESTINATION "${PocoConfigPackageLocation}/V39") + install(FILES cmake/V313/FindSQLite3.cmake + DESTINATION "${PocoConfigPackageLocation}/V313") +endif() + message(STATUS "CMake ${CMAKE_VERSION} successfully configured ${PROJECT_NAME} using ${CMAKE_GENERATOR} generator") message(STATUS "${PROJECT_NAME} package version: ${PROJECT_VERSION}") if(BUILD_SHARED_LIBS) diff --git a/Data/SQLite/CMakeLists.txt b/Data/SQLite/CMakeLists.txt index a9d6e06aa..5e22ee631 100644 --- a/Data/SQLite/CMakeLists.txt +++ b/Data/SQLite/CMakeLists.txt @@ -28,7 +28,7 @@ set_target_properties(DataSQLite OUTPUT_NAME PocoDataSQLite DEFINE_SYMBOL SQLite_EXPORTS ) -target_link_libraries(DataSQLite PUBLIC Poco::Data ${SQLITE3_LIBRARIES}) +target_link_libraries(DataSQLite PUBLIC Poco::Data) target_include_directories(DataSQLite PUBLIC $ @@ -37,7 +37,7 @@ target_include_directories(DataSQLite ) if(POCO_UNBUNDLED) - target_include_directories(DataSQLite PUBLIC "${SQLITE3_INCLUDE_DIRS}") + target_link_libraries(DataSQLite PUBLIC SQLite::SQLite3) target_compile_definitions(DataSQLite PUBLIC POCO_UNBUNDLED) else() if(WINCE) diff --git a/Data/SQLite/cmake/PocoDataSQLiteConfig.cmake b/Data/SQLite/cmake/PocoDataSQLiteConfig.cmake index 8d8198c4f..690507393 100644 --- a/Data/SQLite/cmake/PocoDataSQLiteConfig.cmake +++ b/Data/SQLite/cmake/PocoDataSQLiteConfig.cmake @@ -1,4 +1,11 @@ include(CMakeFindDependencyMacro) find_dependency(PocoFoundation) find_dependency(PocoData) +if(@POCO_UNBUNDLED@) + if(CMAKE_VERSION VERSION_LESS "3.14") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/V313") + endif() + find_dependency(SQLite3 REQUIRED) +endif() + include("${CMAKE_CURRENT_LIST_DIR}/PocoDataSQLiteTargets.cmake") diff --git a/Foundation/CMakeLists.txt b/Foundation/CMakeLists.txt index 71d706690..2e4cf6948 100644 --- a/Foundation/CMakeLists.txt +++ b/Foundation/CMakeLists.txt @@ -94,7 +94,11 @@ set_target_properties(Foundation DEFINE_SYMBOL Foundation_EXPORTS ) -target_link_libraries(Foundation PUBLIC ${PCRE_LIBRARIES} ${ZLIB_LIBRARIES}) +if (POCO_UNBUNDLED) + target_link_libraries(Foundation PUBLIC Pcre::Pcre ZLIB::ZLIB) + target_compile_definitions(Foundation PUBLIC POCO_UNBUNDLED) +endif (POCO_UNBUNDLED) + target_include_directories(Foundation PUBLIC $ @@ -209,11 +213,6 @@ if (ANDROID) target_link_libraries(Foundation PUBLIC log) endif() -if(POCO_UNBUNDLED) - target_include_directories(Foundation PUBLIC "${PCRE_INCLUDE_DIRS}" "${ZLIB_INCLUDE_DIRS}") - target_compile_definitions(Foundation PUBLIC POCO_UNBUNDLED) -endif() - POCO_INSTALL(Foundation) POCO_GENERATE_PACKAGE(Foundation) diff --git a/Foundation/cmake/PocoFoundationConfig.cmake b/Foundation/cmake/PocoFoundationConfig.cmake index ebf740bc1..fac887655 100644 --- a/Foundation/cmake/PocoFoundationConfig.cmake +++ b/Foundation/cmake/PocoFoundationConfig.cmake @@ -1 +1,8 @@ -include("${CMAKE_CURRENT_LIST_DIR}/PocoFoundationTargets.cmake") \ No newline at end of file +if(@POCO_UNBUNDLED@) + include(CMakeFindDependencyMacro) + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") + find_dependency(ZLIB REQUIRED) + find_dependency(PCRE REQUIRED) +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/PocoFoundationTargets.cmake") diff --git a/PDF/CMakeLists.txt b/PDF/CMakeLists.txt index 904ea824f..37e197be1 100644 --- a/PDF/CMakeLists.txt +++ b/PDF/CMakeLists.txt @@ -125,7 +125,11 @@ set_target_properties(PDF DEFINE_SYMBOL PDF_EXPORTS ) -target_link_libraries(PDF PUBLIC ${ZLIB_LIBRARIES} Poco::XML Poco::Util) +if (POCO_UNBUNDLED) + target_link_libraries(PDF PUBLIC ZLIB::ZLIB) + target_compile_definitions(PDF PUBLIC POCO_UNBUNDLED) +endif (POCO_UNBUNDLED) +target_link_libraries(PDF PUBLIC Poco::XML Poco::Util) target_include_directories(PDF PUBLIC $ @@ -133,9 +137,6 @@ target_include_directories(PDF PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src ) -if (POCO_UNBUNDLED) - target_include_directories(PDF PUBLIC "${ZLIB_INCLUDE_DIRS}") - target_compile_definitions(PDF PUBLIC POCO_UNBUNDLED) endif() POCO_INSTALL(PDF) diff --git a/PDF/cmake/PocoPDFConfig.cmake b/PDF/cmake/PocoPDFConfig.cmake index 36a69b09d..a5c94ec3e 100644 --- a/PDF/cmake/PocoPDFConfig.cmake +++ b/PDF/cmake/PocoPDFConfig.cmake @@ -1,3 +1,7 @@ include(CMakeFindDependencyMacro) find_dependency(PocoFoundation) +if(@POCO_UNBUNDLED@) + find_dependency(ZLIB REQUIRED) +endif() + include("${CMAKE_CURRENT_LIST_DIR}/PocoPDFTargets.cmake") diff --git a/XML/CMakeLists.txt b/XML/CMakeLists.txt index 4db9de276..a34c4fc63 100644 --- a/XML/CMakeLists.txt +++ b/XML/CMakeLists.txt @@ -35,7 +35,7 @@ set_target_properties( XML DEFINE_SYMBOL XML_EXPORTS ) -target_link_libraries(XML PUBLIC ${EXPAT_LIBRARIES} Poco::Foundation) +target_link_libraries(XML PUBLIC Poco::Foundation) target_include_directories(XML PUBLIC $ @@ -44,7 +44,7 @@ target_include_directories(XML ) if (POCO_UNBUNDLED) - target_include_directories(XML PUBLIC "${EXPAT_INCLUDE_DIRS}") + target_link_libraries(XML PUBLIC EXPAT::EXPAT) target_compile_definitions(XML PUBLIC POCO_UNBUNDLED) else() if(WIN32) diff --git a/XML/cmake/PocoXMLConfig.cmake b/XML/cmake/PocoXMLConfig.cmake index fd050cf51..237c9c9f1 100644 --- a/XML/cmake/PocoXMLConfig.cmake +++ b/XML/cmake/PocoXMLConfig.cmake @@ -1,3 +1,10 @@ include(CMakeFindDependencyMacro) find_dependency(PocoFoundation) +if(@POCO_UNBUNDLED@) + if(CMAKE_VERSION VERSION_LESS "3.10") + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/V39") + endif() + find_dependency(EXPAT REQUIRED) +endif() + include("${CMAKE_CURRENT_LIST_DIR}/PocoXMLTargets.cmake") diff --git a/cmake/FindPCRE.cmake b/cmake/FindPCRE.cmake index 41a99cb57..c5bb73c5a 100644 --- a/cmake/FindPCRE.cmake +++ b/cmake/FindPCRE.cmake @@ -1,33 +1,107 @@ -# -# - Find pcre -# Find the native PCRE includes and library -# -# PCRE_INCLUDE_DIRS - where to find pcre.h, etc. -# PCRE_LIBRARIES - List of libraries when using pcre. -# PCRE_FOUND - True if pcre found. +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. +#[=======================================================================[.rst: +FindPCRE +------- -IF (PCRE_INCLUDE_DIRS) - # Already in cache, be silent - SET(PCRE_FIND_QUIETLY TRUE) -ENDIF (PCRE_INCLUDE_DIRS) +Finds the PCRE library. -FIND_PATH(PCRE_INCLUDE_DIR pcre.h) +Imported Targets +^^^^^^^^^^^^^^^^ -SET(PCRE_NAMES pcre) -FIND_LIBRARY(PCRE_LIBRARY NAMES ${PCRE_NAMES} ) +This module provides the following imported targets, if found: -# handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if -# all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_INCLUDE_DIR) +``Pcre::Pcre`` + The PCRE library -IF(PCRE_FOUND) - SET( PCRE_LIBRARIES ${PCRE_LIBRARY} ) - SET( PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR} ) -ELSE(PCRE_FOUND) - SET( PCRE_LIBRARIES ) - SET( PCRE_INCLUDE_DIRS ) -ENDIF(PCRE_FOUND) +Result Variables +^^^^^^^^^^^^^^^^ -MARK_AS_ADVANCED( PCRE_LIBRARIES PCRE_INCLUDE_DIRS ) +This will define the following variables: + +``PCRE_FOUND`` + True if the system has the PCRE library. +``PCRE_VERSION`` + The version of the PCRE library which was found. +``PCRE_INCLUDE_DIRS`` + Include directories needed to use PCRE. +``PCRE_LIBRARIES`` + Libraries needed to link to PCRE. + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``PCRE_INCLUDE_DIR`` + The directory containing ``foo.h``. +``PCRE_LIBRARY`` + The path to the PCRE library. + +Hints +^^^^^ + +``PCRE_ROOT_DIR`` + The path to the root directory of a PCRE installation. +``PCRE_ROOT_INCLUDE_DIRS`` + The path to the include directory of a PCRE installation. +``PCRE_ROOT_LIBRARY_DIRS`` + The path to the library directory of a PCRE installation. + +#]=======================================================================]# + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +pkg_check_modules(PC_PCRE QUIET pcre) + +find_path(PCRE_INCLUDE_DIR + NAMES pcre.h + HINTS + ${PCRE_ROOT_DIR}/include + ${PCRE_ROOT_INCLUDE_DIRS} + PATHS + ${PC_PCRE_INCLUDE_DIRS} + DOC "Specify the include directory containing pcre.h" +) + +find_library(PCRE_LIBRARY + NAMES pcre + HINTS + ${PCRE_ROOT_DIR}/lib + ${PCRE_ROOT_LIBRARY_DIRS} + PATHS + ${PC_PCRE_LIBRARY_DIRS} + DOC "Specify the lib directory containing pcre" +) + +set(PCRE_VERSION ${PC_PCRE_VERSION}) + +find_package_handle_standard_args(PCRE + FOUND_VAR PCRE_FOUND + REQUIRED_VARS + PCRE_LIBRARY + PCRE_INCLUDE_DIR + VERSION_VAR PCRE_VERSION +) + +if(PCRE_FOUND) + set(PCRE_LIBRARIES ${PCRE_LIBRARY}) + set(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR}) + set(PCRE_DEFINITIONS ${PC_PCRE_CFLAGS_OTHER}) +endif() + +if(PCRE_FOUND AND NOT TARGET Pcre::Pcre) + add_library(Pcre::Pcre UNKNOWN IMPORTED) + set_target_properties(Pcre::Pcre PROPERTIES + IMPORTED_LOCATION "${PCRE_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PC_PCRE_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${PCRE_INCLUDE_DIR}" + ) +endif() + +mark_as_advanced( + PCRE_INCLUDE_DIR + PCRE_LIBRARY +) diff --git a/cmake/FindSQLite3.cmake b/cmake/FindSQLite3.cmake deleted file mode 100644 index aa650e38a..000000000 --- a/cmake/FindSQLite3.cmake +++ /dev/null @@ -1,87 +0,0 @@ -# - Try to find Sqlite3 -# Once done this will define -# -# SQLITE3_FOUND - system has Sqlite3 -# SQLITE3_INCLUDE_DIRS - the Sqlite3 include directory -# SQLITE3_LIBRARIES - Link these to use Sqlite3 -# SQLITE3_DEFINITIONS - Compiler switches required for using Sqlite3 -# -# Copyright (c) 2008 Andreas Schneider -# -# Redistribution and use is allowed according to the terms of the New -# BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# - - -if (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS) - # in cache already - set(SQLITE3_FOUND TRUE) -else (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS) - # use pkg-config to get the directories and then use these values - # in the FIND_PATH() and FIND_LIBRARY() calls - if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) - include(UsePkgConfig) - pkgconfig(sqlite3 _SQLITE3_INCLUDEDIR _SQLITE3_LIBDIR _SQLITE3_LDFLAGS _SQLITE3_CFLAGS) - else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) - find_package(PkgConfig) - if (PKG_CONFIG_FOUND) - pkg_check_modules(_SQLITE3 sqlite3) - endif (PKG_CONFIG_FOUND) - endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) - find_path(SQLITE3_INCLUDE_DIR - NAMES - sqlite3.h - PATHS - ${_SQLITE3_INCLUDEDIR} - /usr/include - /usr/local/include - /opt/local/include - /sw/include - ) - - find_library(SQLITE3_LIBRARY - NAMES - sqlite3 - PATHS - ${_SQLITE3_LIBDIR} - /usr/lib - /usr/local/lib - /opt/local/lib - /sw/lib - ) - - if (SQLITE3_LIBRARY) - set(SQLITE3_FOUND TRUE) - endif (SQLITE3_LIBRARY) - - set(SQLITE3_INCLUDE_DIRS - ${SQLITE3_INCLUDE_DIR} - ) - - if (SQLITE3_FOUND) - set(SQLITE3_LIBRARIES - ${SQLITE3_LIBRARIES} - ${SQLITE3_LIBRARY} - ) - endif (SQLITE3_FOUND) - - if (SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES) - set(SQLITE3_FOUND TRUE) - endif (SQLITE3_INCLUDE_DIRS AND SQLITE3_LIBRARIES) - - if (SQLITE3_FOUND) - if (NOT Sqlite3_FIND_QUIETLY) - message(STATUS "Found Sqlite3: ${SQLITE3_LIBRARIES}") - endif (NOT Sqlite3_FIND_QUIETLY) - else (SQLITE3_FOUND) - if (Sqlite3_FIND_REQUIRED) - message(FATAL_ERROR "Could not find Sqlite3") - endif (Sqlite3_FIND_REQUIRED) - endif (SQLITE3_FOUND) - - # show the SQLITE3_INCLUDE_DIRS and SQLITE3_LIBRARIES variables only in the advanced view - mark_as_advanced(SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES) - -endif (SQLITE3_LIBRARIES AND SQLITE3_INCLUDE_DIRS) - diff --git a/cmake/V313/FindSQLite3.cmake b/cmake/V313/FindSQLite3.cmake new file mode 100644 index 000000000..c144ca1d8 --- /dev/null +++ b/cmake/V313/FindSQLite3.cmake @@ -0,0 +1,66 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +FindSQLite3 +----------- + +Find the SQLite libraries, v3 + +IMPORTED targets +^^^^^^^^^^^^^^^^ + +This module defines the following :prop_tgt:`IMPORTED` target: + +``SQLite::SQLite3`` + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables if found: + +``SQLite3_INCLUDE_DIRS`` + where to find sqlite3.h, etc. +``SQLite3_LIBRARIES`` + the libraries to link against to use SQLite3. +``SQLite3_VERSION`` + version of the SQLite3 library found +``SQLite3_FOUND`` + TRUE if found + +#]=======================================================================] + +# Look for the necessary header +find_path(SQLite3_INCLUDE_DIR NAMES sqlite3.h) +mark_as_advanced(SQLite3_INCLUDE_DIR) + +# Look for the necessary library +find_library(SQLite3_LIBRARY NAMES sqlite3 sqlite) +mark_as_advanced(SQLite3_LIBRARY) + +# Extract version information from the header file +if(SQLite3_INCLUDE_DIR) + file(STRINGS ${SQLite3_INCLUDE_DIR}/sqlite3.h _ver_line + REGEX "^#define SQLITE_VERSION *\"[0-9]+\\.[0-9]+\\.[0-9]+\"" + LIMIT_COUNT 1) + string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" + SQLite3_VERSION "${_ver_line}") + unset(_ver_line) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(SQLite3 + REQUIRED_VARS SQLite3_INCLUDE_DIR SQLite3_LIBRARY + VERSION_VAR SQLite3_VERSION) + +# Create the imported target +if(SQLite3_FOUND) + set(SQLite3_INCLUDE_DIRS ${SQLite3_INCLUDE_DIR}) + set(SQLite3_LIBRARIES ${SQLite3_LIBRARY}) + if(NOT TARGET SQLite::SQLite3) + add_library(SQLite::SQLite3 UNKNOWN IMPORTED) + set_target_properties(SQLite::SQLite3 PROPERTIES + IMPORTED_LOCATION "${SQLite3_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIR}") + endif() +endif() diff --git a/cmake/V39/FindEXPAT.cmake b/cmake/V39/FindEXPAT.cmake new file mode 100644 index 000000000..1412fafc4 --- /dev/null +++ b/cmake/V39/FindEXPAT.cmake @@ -0,0 +1,79 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#.rst: +# FindEXPAT +# --------- +# +# Find the native Expat headers and library. +# +# Imported Targets +# ^^^^^^^^^^^^^^^^ +# +# This module defines the following :prop_tgt:`IMPORTED` targets: +# +# ``EXPAT::EXPAT`` +# The Expat ``expat`` library, if found. +# +# Result Variables +# ^^^^^^^^^^^^^^^^ +# +# This module will set the following variables in your project: +# +# ``EXPAT_INCLUDE_DIRS`` +# where to find expat.h, etc. +# ``EXPAT_LIBRARIES`` +# the libraries to link against to use Expat. +# ``EXPAT_FOUND`` +# true if the Expat headers and libraries were found. +# + +find_package(PkgConfig QUIET) + +pkg_check_modules(PC_EXPAT QUIET expat) + +# Look for the header file. +find_path(EXPAT_INCLUDE_DIR NAMES expat.h HINTS ${PC_EXPAT_INCLUDE_DIRS}) + +# Look for the library. +find_library(EXPAT_LIBRARY NAMES expat libexpat HINTS ${PC_EXPAT_LIBRARY_DIRS}) + +if (EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h") + file(STRINGS "${EXPAT_INCLUDE_DIR}/expat.h" expat_version_str + REGEX "^#[\t ]*define[\t ]+XML_(MAJOR|MINOR|MICRO)_VERSION[\t ]+[0-9]+$") + + unset(EXPAT_VERSION_STRING) + foreach(VPART MAJOR MINOR MICRO) + foreach(VLINE ${expat_version_str}) + if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$") + set(EXPAT_VERSION_PART "${CMAKE_MATCH_1}") + if(EXPAT_VERSION_STRING) + string(APPEND EXPAT_VERSION_STRING ".${EXPAT_VERSION_PART}") + else() + set(EXPAT_VERSION_STRING "${EXPAT_VERSION_PART}") + endif() + endif() + endforeach() + endforeach() +endif () + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(EXPAT + REQUIRED_VARS EXPAT_LIBRARY EXPAT_INCLUDE_DIR + VERSION_VAR EXPAT_VERSION_STRING) + +# Copy the results to the output variables and target. +if(EXPAT_FOUND) + set(EXPAT_LIBRARIES ${EXPAT_LIBRARY}) + set(EXPAT_INCLUDE_DIRS ${EXPAT_INCLUDE_DIR}) + + if(NOT TARGET EXPAT::EXPAT) + add_library(EXPAT::EXPAT UNKNOWN IMPORTED) + set_target_properties(EXPAT::EXPAT PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + IMPORTED_LOCATION "${EXPAT_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${EXPAT_INCLUDE_DIRS}") + endif() +endif() + +mark_as_advanced(EXPAT_INCLUDE_DIR EXPAT_LIBRARY)