From 20944ef885c1b300974e0b4893e003d342330f06 Mon Sep 17 00:00:00 2001 From: Viktor Elofsson Date: Sun, 9 Jul 2017 22:34:33 +0200 Subject: [PATCH] Fix vcpkg Boost naming for static libs and also fix the include file for shared libs. --- ports/libtorrent/portfile.cmake | 13 ++++++++++--- ports/libtorrent/vcpkg-boost-madness.patch | 13 +++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 ports/libtorrent/vcpkg-boost-madness.patch diff --git a/ports/libtorrent/portfile.cmake b/ports/libtorrent/portfile.cmake index 476d84221d..6eb49c0b45 100644 --- a/ports/libtorrent/portfile.cmake +++ b/ports/libtorrent/portfile.cmake @@ -24,16 +24,20 @@ vcpkg_apply_patches( SOURCE_PATH ${SOURCE_PATH} PATCHES ${CMAKE_CURRENT_LIST_DIR}/add-datetime-to-boost-libs.patch PATCHES ${CMAKE_CURRENT_LIST_DIR}/add-dbghelp-to-win32-libs.patch + PATCHES ${CMAKE_CURRENT_LIST_DIR}/vcpkg-boost-madness.patch ) -if (NOT VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - message(FATAL_ERROR "Only dynamic linking supported.") +if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) + set(LIBTORRENT_SHARED ON) +else() + set(LIBTORRENT_SHARED OFF) endif() vcpkg_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA # Disable this option if project cannot be built with Ninja OPTIONS + -Dshared=${LIBTORRENT_SHARED} -Ddeprecated-functions=off ) @@ -46,8 +50,11 @@ if (VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) file(RENAME ${CURRENT_PACKAGES_DIR}/lib/torrent-rasterbar.dll ${CURRENT_PACKAGES_DIR}/bin/torrent-rasterbar.dll) file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/torrent-rasterbar.dll ${CURRENT_PACKAGES_DIR}/debug/bin/torrent-rasterbar.dll) -else() + # Defines for shared lib + file(READ ${CURRENT_PACKAGES_DIR}/include/libtorrent/export.hpp EXPORT_H) + string(REPLACE "defined TORRENT_BUILDING_SHARED" "1" EXPORT_H "${EXPORT_H}") + file(WRITE ${CURRENT_PACKAGES_DIR}/include/libtorrent/export.hpp "${EXPORT_H}") endif() # Handle copyright diff --git a/ports/libtorrent/vcpkg-boost-madness.patch b/ports/libtorrent/vcpkg-boost-madness.patch new file mode 100644 index 0000000000..e9e498ee4d --- /dev/null +++ b/ports/libtorrent/vcpkg-boost-madness.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 99698a2..454bae6 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -252,7 +252,7 @@ else() + + set(Boost_USE_STATIC_RUNTIME ON) + endif() +- set(Boost_USE_STATIC_LIBS ON) ++ set(Boost_USE_STATIC_LIBS OFF) + add_library(torrent-rasterbar STATIC ${sources2}) + endif() +