vcpkg/ports/zstd/portfile.cmake
Kai Pastor 51e10eb7fe
[tiff,zstd,gdal,libkml] Fix find_package interactions, enable gdal libkml driver (#28929)
* [gdal] Fix find_package2

* [cmake-user] Test gdal

* [cmake-user] gdal needs CMake 3.9

* Fix tiff & zstd

* Update versions

* [libkml] Export modern INTERFACE_LINK_LIBRARIES

* [gdal] Enable libkml driver

Co-authored-by: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com>
2023-01-16 12:45:42 -08:00

56 lines
2.0 KiB
CMake

vcpkg_minimum_required(VERSION 2022-10-12) # for ${VERSION}
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO facebook/zstd
REF "v${VERSION}"
SHA512 e107508a41fca50845cc2494e64adaba93efb95a2fa486fc962510a8ba4b2180d93067cae9870f119e88e5e8b28a046bc2240b0b23cdd8933d1fb1a6a9668c1e
HEAD_REF dev
PATCHES
install_pkgpc.patch
no-static-suffix.patch
)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" ZSTD_BUILD_STATIC)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" ZSTD_BUILD_SHARED)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}/build/cmake"
OPTIONS
-DZSTD_BUILD_SHARED=${ZSTD_BUILD_SHARED}
-DZSTD_BUILD_STATIC=${ZSTD_BUILD_STATIC}
-DZSTD_LEGACY_SUPPORT=1
-DZSTD_BUILD_PROGRAMS=0
-DZSTD_BUILD_TESTS=0
-DZSTD_BUILD_CONTRIB=0
-DZSTD_MULTITHREAD_SUPPORT=1
)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/zstd)
vcpkg_fixup_pkgconfig()
file(READ "${CURRENT_PACKAGES_DIR}/share/zstd/zstdTargets.cmake" targets)
if(targets MATCHES "-pthread")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/lib/pkgconfig/libzstd.pc" " -lzstd" " -lzstd -pthread")
if(NOT VCPKG_BUILD_TYPE)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/libzstd.pc" " -lzstd" " -lzstd -pthread")
endif()
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
foreach(HEADER IN ITEMS zdict.h zstd.h zstd_errors.h)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/${HEADER}" "defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)" "1" )
endforeach()
endif()
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(
COMMENT "ZSTD is dual licensed under BSD and GPLv2."
FILE_LIST
"${SOURCE_PATH}/LICENSE"
"${SOURCE_PATH}/COPYING"
)