Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vcpkg-baseline][zxing-cpp] Fix build failure #11586

Merged
merged 4 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ports/libiconv/CONTROL
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions ports/libiconv/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions ports/libiconv/vcpkg-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
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)
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()
39 changes: 39 additions & 0 deletions ports/zxing-cpp/0002-improve-features.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You dont need this patch. Use -DCMAKE_DISABLE_FIND_PACKAGE_<package>=ON in the vcpkg_configure_cmake call instead (https://cmake.org/cmake/help/v3.0/variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName.html)

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()
12 changes: 10 additions & 2 deletions ports/zxing-cpp/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
Source: zxing-cpp
Version: 3.3.3-6
Version: 3.3.3-7
Homepage: https://github.com/glassechidna/zxing-cpp
Build-Depends: opencv
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
25 changes: 15 additions & 10 deletions ports/zxing-cpp/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
include(vcpkg_common_functions)

vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_from_github(
Expand All @@ -10,16 +8,29 @@ vcpkg_from_github(
HEAD_REF master
PATCHES
0001-opencv4-compat.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()

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})
Expand All @@ -28,18 +39,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)