From d0695f6709dd0b3fedf17e3f24e046b167918030 Mon Sep 17 00:00:00 2001 From: Phoebe <20694052+PhoebeHui@users.noreply.github.com> Date: Tue, 27 Oct 2020 08:44:56 +0800 Subject: [PATCH] [pcre] Export cmake targets (#13539) --- ports/pcre/CONTROL | 2 +- ports/pcre/export-cmake-targets.patch | 25 +++++++++++++++++++++++++ ports/pcre/portfile.cmake | 9 +++++++-- ports/pcre/unofficial-pcre-config.cmake | 1 + 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 ports/pcre/export-cmake-targets.patch create mode 100644 ports/pcre/unofficial-pcre-config.cmake diff --git a/ports/pcre/CONTROL b/ports/pcre/CONTROL index cbd70b8692..5f42aa89dc 100644 --- a/ports/pcre/CONTROL +++ b/ports/pcre/CONTROL @@ -1,5 +1,5 @@ Source: pcre Version: 8.44 -Port-Version: 7 +Port-Version: 8 Homepage: https://www.pcre.org/ Description: Perl Compatible Regular Expressions diff --git a/ports/pcre/export-cmake-targets.patch b/ports/pcre/export-cmake-targets.patch new file mode 100644 index 0000000000..ef89070ddf --- /dev/null +++ b/ports/pcre/export-cmake-targets.patch @@ -0,0 +1,25 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 252de6e..bcef3ae 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -885,10 +885,19 @@ ENDIF(PCRE_BUILD_TESTS) + # Installation + SET(CMAKE_INSTALL_ALWAYS 1) + +-INSTALL(TARGETS ${targets} ++foreach(target ${targets}) ++ INSTALL(TARGETS ${target} ++ EXPORT pcre-targets + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) ++ target_include_directories(${target} PUBLIC $) ++endforeach() ++ ++INSTALL(EXPORT pcre-targets ++ NAMESPACE unofficial::pcre:: ++ FILE unofficial-pcre-targets.cmake ++ DESTINATION "share/unofficial-pcre") + + INSTALL(FILES ${PCRE_HEADERS} ${PCREPOSIX_HEADERS} DESTINATION include) + diff --git a/ports/pcre/portfile.cmake b/ports/pcre/portfile.cmake index 6175b0bbb1..2cb9fce348 100644 --- a/ports/pcre/portfile.cmake +++ b/ports/pcre/portfile.cmake @@ -4,7 +4,8 @@ set(PATCHES # Fix CMake Deprecation Warning concerning OLD behavior for policy CMP0026 # Suppress MSVC compiler warnings C4703, C4146, C4308, which fixes errors # under x64-uwp and arm-uwp - pcre-8.44_suppress_cmake_and_compiler_warnings-errors.patch) + pcre-8.44_suppress_cmake_and_compiler_warnings-errors.patch + export-cmake-targets.patch) vcpkg_download_distfile(ARCHIVE URLS "https://ftp.pcre.org/pub/pcre/pcre-${PCRE_VERSION}.zip" @@ -53,6 +54,8 @@ vcpkg_configure_cmake( vcpkg_install_cmake() +vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-${PORT} TARGET_PATH share/unofficial-${PORT}) + foreach(FILE ${CURRENT_PACKAGES_DIR}/include/pcre.h ${CURRENT_PACKAGES_DIR}/include/pcreposix.h) file(READ ${FILE} PCRE_H) if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") @@ -121,6 +124,8 @@ file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/man) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/man) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/share/doc) +vcpkg_copy_pdbs() +configure_file(${CMAKE_CURRENT_LIST_DIR}/unofficial-pcre-config.cmake ${CURRENT_PACKAGES_DIR}/share/unofficial-pcre/unofficial-pcre-config.cmake @ONLY) + file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) -vcpkg_copy_pdbs() diff --git a/ports/pcre/unofficial-pcre-config.cmake b/ports/pcre/unofficial-pcre-config.cmake new file mode 100644 index 0000000000..edf30b9778 --- /dev/null +++ b/ports/pcre/unofficial-pcre-config.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcre-targets.cmake")