From cdb6757b0f2562de7a47b075064c7f5c71d2bb52 Mon Sep 17 00:00:00 2001 From: PhoebeHui <20694052+PhoebeHui@users.noreply.github.com> Date: Tue, 15 Sep 2020 01:13:02 -0700 Subject: [PATCH 1/3] [pcre] export cmake targets --- ports/pcre/CONTROL | 2 +- ports/pcre/export-cmake-targets.patch | 25 +++++++++++++++++++++++++ ports/pcre/portfile.cmake | 10 ++++++++-- ports/pcre/unofficial-pcre-config.cmake | 23 +++++++++++++++++++++++ ports/pcre/usage | 16 ++++++++++++++++ 5 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 ports/pcre/export-cmake-targets.patch create mode 100644 ports/pcre/unofficial-pcre-config.cmake create mode 100644 ports/pcre/usage diff --git a/ports/pcre/CONTROL b/ports/pcre/CONTROL index cbd70b86927bb0..5f42aa89dc6df5 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 00000000000000..8001808c044f25 --- /dev/null +++ b/ports/pcre/export-cmake-targets.patch @@ -0,0 +1,25 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 252de6e..2fea7ca 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -885,11 +885,19 @@ ENDIF(PCRE_BUILD_TESTS) + # Installation + SET(CMAKE_INSTALL_ALWAYS 1) + +-INSTALL(TARGETS ${targets} ++foreach(target ${targets}) ++ INSTALL(TARGETS ${target} ++ EXPORT ${target}-targets + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) + ++ INSTALL(EXPORT ${target}-targets ++ NAMESPACE unofficial::pcre:: ++ FILE unofficial-${target}-targets.cmake ++ DESTINATION "share/unofficial-pcre") ++endforeach() ++ + INSTALL(FILES ${PCRE_HEADERS} ${PCREPOSIX_HEADERS} DESTINATION include) + + FILE(GLOB html ${PROJECT_SOURCE_DIR}/doc/html/*.html) diff --git a/ports/pcre/portfile.cmake b/ports/pcre/portfile.cmake index 6175b0bbb1f43c..c974cbe1dc838c 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,9 @@ 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 ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}) 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 00000000000000..2ff186c03e75a0 --- /dev/null +++ b/ports/pcre/unofficial-pcre-config.cmake @@ -0,0 +1,23 @@ + +include("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcre-targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcre16-targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcre32-targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcrecpp-targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcreposix-targets.cmake") + +set(PCRE_INCLUDE_DIR ${CMAKE_CURRENT_LIST_FILE}/../../include) +set(PCRE_LIBRARY unofficial::pcre::pcre) +set(PCRE16_LIBRARY unofficial::pcre::pcre16) +set(PCRE32_LIBRARY unofficial::pcre::pcre32) +set(PCRECPP_LIBRARY unofficial::pcre::pcre unofficial::pcre::pcrecpp) +set(PCREPOSIX_LIBRARY unofficial::pcre::pcreposix unofficial::pcre::pcre) + +set(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR}) +set(PCRE_LIBRARIES ${PCRE_LIBRARY}) +set(PCRE16_LIBRARIES ${PCRE16_LIBRARY}) +set(PCRE32_LIBRARIES ${PCRE32_LIBRARY}) +set(PCRECPP_LIBRARIES ${PCRECPP_LIBRARY}) +set(PCREPOSIX_LIBRARIES ${PCREPOSIX_LIBRARY}) + + + diff --git a/ports/pcre/usage b/ports/pcre/usage new file mode 100644 index 00000000000000..7cc4876cd3a3dc --- /dev/null +++ b/ports/pcre/usage @@ -0,0 +1,16 @@ +The package pcre provides CMake targets: + + find_package(unofficial-pcre CONFIG REQUIRED) + target_include_directories(main PRIVATE ${PCRE_INCLUDE_DIR}) + target_link_libraries(main PRIVATE ${PCRE_LIBRARY}) + + +Using pcre16: + target_link_libraries(main PRIVATE ${PCRE16_LIBRARY}) +Using pcre32: + target_link_libraries(main PRIVATE ${PCRE32_LIBRARY}) +Using pcrecpp + target_link_libraries(main PRIVATE ${PCRECPP_LIBRARY}) +Using pcreposix + target_link_libraries(main PRIVATE ${PCREPOSIX_LIBRARY}) + From eeb43dd5dad2399c6833835bfef4c2d5f7a4c40e Mon Sep 17 00:00:00 2001 From: PhoebeHui <20694052+PhoebeHui@users.noreply.github.com> Date: Tue, 15 Sep 2020 01:20:08 -0700 Subject: [PATCH 2/3] Update usage --- ports/pcre/unofficial-pcre-config.cmake | 4 ---- ports/pcre/usage | 10 ++++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/ports/pcre/unofficial-pcre-config.cmake b/ports/pcre/unofficial-pcre-config.cmake index 2ff186c03e75a0..004b20ee8c0928 100644 --- a/ports/pcre/unofficial-pcre-config.cmake +++ b/ports/pcre/unofficial-pcre-config.cmake @@ -1,4 +1,3 @@ - include("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcre-targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcre16-targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcre32-targets.cmake") @@ -18,6 +17,3 @@ set(PCRE16_LIBRARIES ${PCRE16_LIBRARY}) set(PCRE32_LIBRARIES ${PCRE32_LIBRARY}) set(PCRECPP_LIBRARIES ${PCRECPP_LIBRARY}) set(PCREPOSIX_LIBRARIES ${PCREPOSIX_LIBRARY}) - - - diff --git a/ports/pcre/usage b/ports/pcre/usage index 7cc4876cd3a3dc..140e809fdfcf80 100644 --- a/ports/pcre/usage +++ b/ports/pcre/usage @@ -4,13 +4,11 @@ The package pcre provides CMake targets: target_include_directories(main PRIVATE ${PCRE_INCLUDE_DIR}) target_link_libraries(main PRIVATE ${PCRE_LIBRARY}) - -Using pcre16: + pcre16 linkage: target_link_libraries(main PRIVATE ${PCRE16_LIBRARY}) -Using pcre32: + pcre32 linkage: target_link_libraries(main PRIVATE ${PCRE32_LIBRARY}) -Using pcrecpp + pcrecpp linkage: target_link_libraries(main PRIVATE ${PCRECPP_LIBRARY}) -Using pcreposix + pcreposix linkage: target_link_libraries(main PRIVATE ${PCREPOSIX_LIBRARY}) - From 4e8f6772c8137215f5e0056ed39c92ace0d6620c Mon Sep 17 00:00:00 2001 From: PhoebeHui <20694052+PhoebeHui@users.noreply.github.com> Date: Wed, 21 Oct 2020 00:49:19 -0700 Subject: [PATCH 3/3] Address review suggestions --- ports/pcre/export-cmake-targets.patch | 18 +++++++++--------- ports/pcre/portfile.cmake | 1 - ports/pcre/unofficial-pcre-config.cmake | 18 ------------------ ports/pcre/usage | 14 -------------- 4 files changed, 9 insertions(+), 42 deletions(-) delete mode 100644 ports/pcre/usage diff --git a/ports/pcre/export-cmake-targets.patch b/ports/pcre/export-cmake-targets.patch index 8001808c044f25..ef89070ddf1483 100644 --- a/ports/pcre/export-cmake-targets.patch +++ b/ports/pcre/export-cmake-targets.patch @@ -1,25 +1,25 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 252de6e..2fea7ca 100644 +index 252de6e..bcef3ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -885,11 +885,19 @@ ENDIF(PCRE_BUILD_TESTS) +@@ -885,10 +885,19 @@ ENDIF(PCRE_BUILD_TESTS) # Installation SET(CMAKE_INSTALL_ALWAYS 1) -INSTALL(TARGETS ${targets} +foreach(target ${targets}) + INSTALL(TARGETS ${target} -+ EXPORT ${target}-targets ++ EXPORT pcre-targets RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) - -+ INSTALL(EXPORT ${target}-targets -+ NAMESPACE unofficial::pcre:: -+ FILE unofficial-${target}-targets.cmake -+ DESTINATION "share/unofficial-pcre") ++ 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) - FILE(GLOB html ${PROJECT_SOURCE_DIR}/doc/html/*.html) diff --git a/ports/pcre/portfile.cmake b/ports/pcre/portfile.cmake index c974cbe1dc838c..2cb9fce3488580 100644 --- a/ports/pcre/portfile.cmake +++ b/ports/pcre/portfile.cmake @@ -127,6 +127,5 @@ 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 ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}) file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) diff --git a/ports/pcre/unofficial-pcre-config.cmake b/ports/pcre/unofficial-pcre-config.cmake index 004b20ee8c0928..edf30b9778d038 100644 --- a/ports/pcre/unofficial-pcre-config.cmake +++ b/ports/pcre/unofficial-pcre-config.cmake @@ -1,19 +1 @@ include("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcre-targets.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcre16-targets.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcre32-targets.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcrecpp-targets.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcreposix-targets.cmake") - -set(PCRE_INCLUDE_DIR ${CMAKE_CURRENT_LIST_FILE}/../../include) -set(PCRE_LIBRARY unofficial::pcre::pcre) -set(PCRE16_LIBRARY unofficial::pcre::pcre16) -set(PCRE32_LIBRARY unofficial::pcre::pcre32) -set(PCRECPP_LIBRARY unofficial::pcre::pcre unofficial::pcre::pcrecpp) -set(PCREPOSIX_LIBRARY unofficial::pcre::pcreposix unofficial::pcre::pcre) - -set(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR}) -set(PCRE_LIBRARIES ${PCRE_LIBRARY}) -set(PCRE16_LIBRARIES ${PCRE16_LIBRARY}) -set(PCRE32_LIBRARIES ${PCRE32_LIBRARY}) -set(PCRECPP_LIBRARIES ${PCRECPP_LIBRARY}) -set(PCREPOSIX_LIBRARIES ${PCREPOSIX_LIBRARY}) diff --git a/ports/pcre/usage b/ports/pcre/usage deleted file mode 100644 index 140e809fdfcf80..00000000000000 --- a/ports/pcre/usage +++ /dev/null @@ -1,14 +0,0 @@ -The package pcre provides CMake targets: - - find_package(unofficial-pcre CONFIG REQUIRED) - target_include_directories(main PRIVATE ${PCRE_INCLUDE_DIR}) - target_link_libraries(main PRIVATE ${PCRE_LIBRARY}) - - pcre16 linkage: - target_link_libraries(main PRIVATE ${PCRE16_LIBRARY}) - pcre32 linkage: - target_link_libraries(main PRIVATE ${PCRE32_LIBRARY}) - pcrecpp linkage: - target_link_libraries(main PRIVATE ${PCRECPP_LIBRARY}) - pcreposix linkage: - target_link_libraries(main PRIVATE ${PCREPOSIX_LIBRARY})