[libtorrent] add iconv feature on windows and clean up portfile (#11257)

This commit is contained in:
Francisco Pombal 2020-05-12 04:12:34 +01:00 committed by GitHub
parent 4acff16593
commit 3834f96170
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 85 additions and 16 deletions

View File

@ -1,5 +1,5 @@
Source: libtorrent
Version: 1.2.6
Version: 1.2.6-1
Homepage: https://github.com/arvidn/libtorrent
Description: An efficient feature complete C++ BitTorrent implementation
Build-Depends: openssl, boost-system, boost-date-time, boost-chrono, boost-random, boost-asio, boost-crc, boost-config, boost-iterator, boost-scope-exit, boost-multiprecision
@ -11,6 +11,10 @@ Description: build with deprecated functions enabled
Feature: examples
Description: build the examples in the examples directory
Feature: iconv
Build-Depends: libiconv (windows)
Description: build with libiconv on Windows
Feature: python
Build-Depends: boost-python, libtorrent[deprfun]
Description: build the python bindings in bindings/python directory

View File

@ -0,0 +1,35 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 303f905e4..6bdbc5ac4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -603,24 +603,19 @@ target_optional_compile_definitions(torrent-rasterbar PUBLIC FEATURE NAME mutabl
target_optional_compile_definitions(torrent-rasterbar PUBLIC FEATURE NAME streaming DEFAULT ON
DESCRIPTION "Enables support for piece deadline" DISABLED TORRENT_DISABLE_STREAMING)
-find_public_dependency(Iconv)
-if(MSVC)
- set(iconv_package_type OPTIONAL)
-else()
- set(iconv_package_type RECOMMENDED)
-endif()
+find_public_dependency(unofficial-iconv REQUIRED)
-set_package_properties(Iconv
+set_package_properties(unofficial-iconv
PROPERTIES
URL "https://www.gnu.org/software/libiconv/"
- DESCRIPTION "GNU encoding conversion library"
- TYPE ${iconv_package_type}
+ DESCRIPTION "GNU encoding conversion library (unofficial vcpkg CMake port)"
+ TYPE REQUIRED
PURPOSE "Convert strings between various encodings"
)
-if(Iconv_FOUND)
+if(unofficial-iconv_FOUND)
target_compile_definitions(torrent-rasterbar PUBLIC TORRENT_USE_ICONV)
- target_link_libraries(torrent-rasterbar PRIVATE Iconv::Iconv)
+ target_link_libraries(torrent-rasterbar PRIVATE unofficial::iconv::libiconv unofficial::iconv::libcharset)
endif()
find_public_dependency(OpenSSL)

View File

@ -0,0 +1,31 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 303f905e4..1810c23c6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -603,26 +603,6 @@ target_optional_compile_definitions(torrent-rasterbar PUBLIC FEATURE NAME mutabl
target_optional_compile_definitions(torrent-rasterbar PUBLIC FEATURE NAME streaming DEFAULT ON
DESCRIPTION "Enables support for piece deadline" DISABLED TORRENT_DISABLE_STREAMING)
-find_public_dependency(Iconv)
-if(MSVC)
- set(iconv_package_type OPTIONAL)
-else()
- set(iconv_package_type RECOMMENDED)
-endif()
-
-set_package_properties(Iconv
- PROPERTIES
- URL "https://www.gnu.org/software/libiconv/"
- DESCRIPTION "GNU encoding conversion library"
- TYPE ${iconv_package_type}
- PURPOSE "Convert strings between various encodings"
-)
-
-if(Iconv_FOUND)
- target_compile_definitions(torrent-rasterbar PUBLIC TORRENT_USE_ICONV)
- target_link_libraries(torrent-rasterbar PRIVATE Iconv::Iconv)
-endif()
-
find_public_dependency(OpenSSL)
set_package_properties(OpenSSL
PROPERTIES

View File

@ -6,12 +6,19 @@ if(VCPKG_TARGET_IS_WINDOWS)
message(FATAL_ERROR "The python feature is currently broken on Windows")
endif()
# Ensure OPENSSL_USE_STATIC_LIBS is set to ON
if("iconv" IN_LIST FEATURES)
set(ICONV_PATCH "fix_find_iconv.patch")
else()
# prevent picking up libiconv if it happens to already be installed
set(ICONV_PATCH "no_use_iconv.patch")
endif()
# Ensure "OPENSSL_USE_STATIC_LIBS" is set to ON
# when statically linking against OpenSSL on Windows.
# Also ensure "static_runtime" will be used when statically linking against the runtime.
# Prevents OpenSSL crypt32.lib linking errors.
if(VCPKG_CRT_LINKAGE STREQUAL "static")
set(LIBTORRENT_STATIC_RUNTIME ON)
set(_static_runtime ON)
elseif(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
set(_OPENSSL_USE_STATIC_LIBS ON)
endif()
@ -32,7 +39,7 @@ if("python" IN_LIST FEATURES)
vcpkg_add_to_path(${PYTHON3_PATH})
file(GLOB BOOST_PYTHON_LIB "${CURRENT_INSTALLED_DIR}/lib/*boost_python*")
string(REGEX REPLACE ".*(python)([0-9])([0-9]+).*" "\\1\\2\\3" BOOST_PYTHON_MODULE "${BOOST_PYTHON_LIB}")
string(REGEX REPLACE ".*(python)([0-9])([0-9]+).*" "\\1\\2\\3" _boost-python-module-name "${BOOST_PYTHON_LIB}")
endif()
vcpkg_from_github(
@ -44,6 +51,7 @@ vcpkg_from_github(
PATCHES
add-datetime-to-boost-libs.patch
fix_python_cmake.patch
${ICONV_PATCH}
)
vcpkg_configure_cmake(
@ -51,24 +59,15 @@ vcpkg_configure_cmake(
PREFER_NINJA # Disable this option if project cannot be built with Ninja
OPTIONS
${FEATURE_OPTIONS}
-Dboost-python-module-name=${BOOST_PYTHON_MODULE}
-Dstatic_runtime=${LIBTORRENT_STATIC_RUNTIME}
-Dboost-python-module-name=${_boost-python-module-name}
-Dstatic_runtime=${_static_runtime}
-DOPENSSL_USE_STATIC_LIBS=${_OPENSSL_USE_STATIC_LIBS}
-DPython3_USE_STATIC_LIBS=ON
)
vcpkg_install_cmake()
file(READ ${CURRENT_PACKAGES_DIR}/include/libtorrent/aux_/export.hpp EXPORT_H)
string(REPLACE "defined TORRENT_BUILDING_SHARED" "0" EXPORT_H "${EXPORT_H}")
if (VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
string(REPLACE "defined TORRENT_LINKING_SHARED" "1" EXPORT_H "${EXPORT_H}")
else()
string(REPLACE "defined TORRENT_LINKING_SHARED" "0" EXPORT_H "${EXPORT_H}")
endif()
file(WRITE ${CURRENT_PACKAGES_DIR}/include/libtorrent/aux_/export.hpp "${EXPORT_H}")
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/LibtorrentRasterbar TARGET_PATH share/libtorrentrasterbar)
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/LibtorrentRasterbar TARGET_PATH share/LibtorrentRasterbar)
# Handle copyright
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)