From 009ae574103620156c30e02b0ef45c7281d203d4 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Mon, 25 May 2020 23:38:07 -0700 Subject: [PATCH 1/4] [zxing-cpp] Fix build failure --- .../0002-fix-dependency-libiconv.patch | 18 ++++++++++++++++++ ports/zxing-cpp/CONTROL | 4 ++-- ports/zxing-cpp/portfile.cmake | 15 ++++++--------- 3 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 ports/zxing-cpp/0002-fix-dependency-libiconv.patch diff --git a/ports/zxing-cpp/0002-fix-dependency-libiconv.patch b/ports/zxing-cpp/0002-fix-dependency-libiconv.patch new file mode 100644 index 00000000000000..3dfc8c2c6d5f61 --- /dev/null +++ b/ports/zxing-cpp/0002-fix-dependency-libiconv.patch @@ -0,0 +1,18 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 5ade734..6e6ce85 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -58,10 +58,9 @@ include_directories(core/src) + add_library(libzxing ${LIBZXING_FILES}) + set_target_properties(libzxing PROPERTIES PREFIX "") + +-find_package(Iconv) +-if(ICONV_FOUND) +- include_directories(${ICONV_INCLUDE_DIR}) +- target_link_libraries(libzxing ${ICONV_LIBRARIES}) ++find_package(unofficial-iconv CONFIG) ++if(unofficial-iconv_FOUND) ++ target_link_libraries(libzxing unofficial::iconv::libiconv unofficial::iconv::libcharset) + else() + add_definitions(-DNO_ICONV=1) + endif() diff --git a/ports/zxing-cpp/CONTROL b/ports/zxing-cpp/CONTROL index fdf89409776fc6..833ecfc1482d80 100644 --- a/ports/zxing-cpp/CONTROL +++ b/ports/zxing-cpp/CONTROL @@ -1,5 +1,5 @@ Source: zxing-cpp -Version: 3.3.3-6 +Version: 3.3.3-7 Homepage: https://github.com/glassechidna/zxing-cpp -Build-Depends: opencv +Build-Depends: opencv, libiconv Description: Barcode detection and decoding library. diff --git a/ports/zxing-cpp/portfile.cmake b/ports/zxing-cpp/portfile.cmake index 044342ed660ff5..9aa4efa7f34c4b 100644 --- a/ports/zxing-cpp/portfile.cmake +++ b/ports/zxing-cpp/portfile.cmake @@ -1,5 +1,3 @@ -include(vcpkg_common_functions) - vcpkg_check_linkage(ONLY_STATIC_LIBRARY) vcpkg_from_github( @@ -10,6 +8,7 @@ vcpkg_from_github( HEAD_REF master PATCHES 0001-opencv4-compat.patch + 0002-fix-dependency-libiconv.patch ) vcpkg_configure_cmake( @@ -20,6 +19,10 @@ vcpkg_configure_cmake( vcpkg_install_cmake() +vcpkg_copy_pdbs() + +vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/${PORT}) + vcpkg_fixup_cmake_targets(CONFIG_PATH lib/zxing/cmake TARGET_PATH share/zxing) file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/tools/${PORT}) @@ -28,18 +31,12 @@ if (NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStor else() file(COPY ${CURRENT_PACKAGES_DIR}/bin/zxing DESTINATION ${CURRENT_PACKAGES_DIR}/tools/${PORT}) endif() -vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/${PORT}) -vcpkg_copy_pdbs() file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib/zxing) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib/pkgconfig) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) -file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/lib/zxing) # Handle copyright -file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share/zxing-cpp) -file(COPY ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/zxing-cpp) -file(RENAME ${CURRENT_PACKAGES_DIR}/share/zxing-cpp/COPYING ${CURRENT_PACKAGES_DIR}/share/zxing-cpp/copyright) +file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) From c0cd46752e76c7af3499e676a8094c2fd92495d3 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 26 May 2020 02:49:04 -0700 Subject: [PATCH 2/4] [libiconv] Add vcpkg-cmake-wrapper to find libcharset --- ports/libiconv/CONTROL | 2 +- ports/libiconv/portfile.cmake | 2 ++ ports/libiconv/vcpkg-cmake-wrapper.cmake | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 ports/libiconv/vcpkg-cmake-wrapper.cmake diff --git a/ports/libiconv/CONTROL b/ports/libiconv/CONTROL index 098a30bcc0ad7d..acff1a893840f3 100644 --- a/ports/libiconv/CONTROL +++ b/ports/libiconv/CONTROL @@ -1,4 +1,4 @@ Source: libiconv -Version: 1.16-2 +Version: 1.16-3 Homepage: https://www.gnu.org/software/libiconv/ Description: GNU Unicode text conversion diff --git a/ports/libiconv/portfile.cmake b/ports/libiconv/portfile.cmake index 5f184079f36f14..b36c995b6df6ac 100644 --- a/ports/libiconv/portfile.cmake +++ b/ports/libiconv/portfile.cmake @@ -37,6 +37,8 @@ vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-iconv TARGET_PATH share/u vcpkg_copy_pdbs() +file(COPY ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/Iconv) + file(INSTALL ${SOURCE_PATH}/COPYING.LIB DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) vcpkg_test_cmake(PACKAGE_NAME unofficial-iconv) diff --git a/ports/libiconv/vcpkg-cmake-wrapper.cmake b/ports/libiconv/vcpkg-cmake-wrapper.cmake new file mode 100644 index 00000000000000..f3b0477ca2a514 --- /dev/null +++ b/ports/libiconv/vcpkg-cmake-wrapper.cmake @@ -0,0 +1,8 @@ +_find_package(${ARGS}) +if(Iconv_FOUND) + find_library(CHARSET_LIBRARY_DEBUG NAMES charsetd libcharsetd charset libcharset NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" NO_DEFAULT_PATH) + find_library(CHARSET_LIBRARY_RELEASE NAMES charset libcharset NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" NO_DEFAULT_PATH) + find_library(CHARSET_LIBRARY_RELEASE NAMES charset libcharset NAMES_PER_DIR PATH_SUFFIXES lib) + select_library_configurations(CHARSET) + list(APPEND Iconv_LIBRARIES ${CHARSET_LIBRARIES}) +endif() From 97790895a804ec72e25fe28fc5463be27eb23446 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 26 May 2020 02:52:22 -0700 Subject: [PATCH 3/4] [zxing-cpp] Use FindIconv and wrapper to find libiconv, add features --- .../0002-fix-dependency-libiconv.patch | 18 --------- ports/zxing-cpp/0002-improve-features.patch | 39 +++++++++++++++++++ ports/zxing-cpp/CONTROL | 10 ++++- ports/zxing-cpp/portfile.cmake | 12 +++++- 4 files changed, 58 insertions(+), 21 deletions(-) delete mode 100644 ports/zxing-cpp/0002-fix-dependency-libiconv.patch create mode 100644 ports/zxing-cpp/0002-improve-features.patch diff --git a/ports/zxing-cpp/0002-fix-dependency-libiconv.patch b/ports/zxing-cpp/0002-fix-dependency-libiconv.patch deleted file mode 100644 index 3dfc8c2c6d5f61..00000000000000 --- a/ports/zxing-cpp/0002-fix-dependency-libiconv.patch +++ /dev/null @@ -1,18 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 5ade734..6e6ce85 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -58,10 +58,9 @@ include_directories(core/src) - add_library(libzxing ${LIBZXING_FILES}) - set_target_properties(libzxing PROPERTIES PREFIX "") - --find_package(Iconv) --if(ICONV_FOUND) -- include_directories(${ICONV_INCLUDE_DIR}) -- target_link_libraries(libzxing ${ICONV_LIBRARIES}) -+find_package(unofficial-iconv CONFIG) -+if(unofficial-iconv_FOUND) -+ target_link_libraries(libzxing unofficial::iconv::libiconv unofficial::iconv::libcharset) - else() - add_definitions(-DNO_ICONV=1) - endif() diff --git a/ports/zxing-cpp/0002-improve-features.patch b/ports/zxing-cpp/0002-improve-features.patch new file mode 100644 index 00000000000000..5776c36eac36b4 --- /dev/null +++ b/ports/zxing-cpp/0002-improve-features.patch @@ -0,0 +1,39 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 5ade734..54071bd 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) + project(zxing) + set(CMAKE_CXX_STANDARD 11) + option(BUILD_TESTING "Enable generation of test targets" OFF) ++option(WITH_OPENCV "Build with opencv" OFF) ++option(WITH_ICONV "Build with iconv" OFF) + + set(CMAKE_LIBRARY_PATH /opt/local/lib ${CMAKE_LIBRARY_PATH}) + +@@ -43,8 +45,8 @@ if(WIN32) + endif() + + # OpenCV classes +-find_package(OpenCV) +-if(OpenCV_FOUND) ++if(WITH_OPENCV) ++ find_package(OpenCV REQUIRED) + list(APPEND LIBZXING_FILES + opencv/src/zxing/MatSource.cpp + opencv/src/zxing/MatSource.h +@@ -58,10 +60,10 @@ include_directories(core/src) + add_library(libzxing ${LIBZXING_FILES}) + set_target_properties(libzxing PROPERTIES PREFIX "") + +-find_package(Iconv) +-if(ICONV_FOUND) +- include_directories(${ICONV_INCLUDE_DIR}) +- target_link_libraries(libzxing ${ICONV_LIBRARIES}) ++if(WITH_ICONV) ++ find_package(Iconv REQUIRED) ++ include_directories(${Iconv_INCLUDE_DIRS}) ++ target_link_libraries(libzxing ${Iconv_LIBRARIES}) + else() + add_definitions(-DNO_ICONV=1) + endif() diff --git a/ports/zxing-cpp/CONTROL b/ports/zxing-cpp/CONTROL index 833ecfc1482d80..89a07a22273ae0 100644 --- a/ports/zxing-cpp/CONTROL +++ b/ports/zxing-cpp/CONTROL @@ -1,5 +1,13 @@ Source: zxing-cpp Version: 3.3.3-7 Homepage: https://github.com/glassechidna/zxing-cpp -Build-Depends: opencv, libiconv Description: Barcode detection and decoding library. +Default-Features: opencv, iconv + +Feature: opencv +Build-Depends: opencv +Description: Build with opencv + +Feature: iconv +Build-Depends: libiconv +Description: Build with libiconv \ No newline at end of file diff --git a/ports/zxing-cpp/portfile.cmake b/ports/zxing-cpp/portfile.cmake index 9aa4efa7f34c4b..3e966639076629 100644 --- a/ports/zxing-cpp/portfile.cmake +++ b/ports/zxing-cpp/portfile.cmake @@ -8,13 +8,21 @@ vcpkg_from_github( HEAD_REF master PATCHES 0001-opencv4-compat.patch - 0002-fix-dependency-libiconv.patch + 0002-improve-features.patch +) + +file(REMOVE ${SOURCE_PATH}/cmake/FindModules/FindIconv.cmake) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + opencv WITH_OPENCV + iconv WITH_ICONV ) vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA - OPTIONS -DCMAKE_DISABLE_FIND_PACKAGE_Iconv=ON + OPTIONS ${FEATURE_OPTIONS} ) vcpkg_install_cmake() From b2b4aa30a198f8ffbded38b329b986f2744caca4 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Wed, 27 May 2020 02:15:02 -0700 Subject: [PATCH 4/4] [libiconv] Add include code to wrapper --- ports/libiconv/vcpkg-cmake-wrapper.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ports/libiconv/vcpkg-cmake-wrapper.cmake b/ports/libiconv/vcpkg-cmake-wrapper.cmake index f3b0477ca2a514..472dd8082db8af 100644 --- a/ports/libiconv/vcpkg-cmake-wrapper.cmake +++ b/ports/libiconv/vcpkg-cmake-wrapper.cmake @@ -1,3 +1,5 @@ +include(SelectLibraryConfigurations) + _find_package(${ARGS}) if(Iconv_FOUND) find_library(CHARSET_LIBRARY_DEBUG NAMES charsetd libcharsetd charset libcharset NAMES_PER_DIR PATH_SUFFIXES lib PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug" NO_DEFAULT_PATH)