vcpkg/ports/zstd/portfile.cmake

68 lines
2.2 KiB
CMake
Raw Normal View History

2017-05-05 18:10:49 +08:00
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO facebook/zstd
REF "v${VERSION}"
2023-05-02 06:15:58 +08:00
SHA512 356994e0d8188ce97590bf86b602eb50cbcb2f951594afb9c2d6e03cc68f966862505afc4a50e76efd55e4cfb11dbc9b15c7837b7827a961a1311ef72cd23505
HEAD_REF dev
2020-04-14 03:39:29 +08:00
PATCHES
no-static-suffix.patch
2023-04-14 03:23:49 +08:00
fix-emscripten-and-clang-cl.patch
)
2017-05-05 18:10:49 +08:00
2021-08-26 12:08:51 +08:00
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" ZSTD_BUILD_STATIC)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" ZSTD_BUILD_SHARED)
2016-11-23 08:00:31 +08:00
2023-09-14 06:00:09 +08:00
if("tools" IN_LIST FEATURES)
set(ZSTD_BUILD_PROGRAMS 1)
else()
set(ZSTD_BUILD_PROGRAMS 0)
endif()
2021-08-26 12:08:51 +08:00
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}/build/cmake"
2017-05-05 18:10:49 +08:00
OPTIONS
2021-08-26 12:08:51 +08:00
-DZSTD_BUILD_SHARED=${ZSTD_BUILD_SHARED}
-DZSTD_BUILD_STATIC=${ZSTD_BUILD_STATIC}
2017-05-05 18:10:49 +08:00
-DZSTD_LEGACY_SUPPORT=1
-DZSTD_BUILD_TESTS=0
-DZSTD_BUILD_CONTRIB=0
-DZSTD_MULTITHREAD_SUPPORT=1
2023-10-31 05:58:07 +08:00
OPTIONS_RELEASE
-DZSTD_BUILD_PROGRAMS=${ZSTD_BUILD_PROGRAMS}
OPTIONS_DEBUG
-DZSTD_BUILD_PROGRAMS=OFF
)
2017-05-05 18:10:49 +08:00
2021-08-26 12:08:51 +08:00
vcpkg_cmake_install()
2017-05-05 18:10:49 +08:00
vcpkg_copy_pdbs()
2021-08-26 12:08:51 +08:00
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()
2020-04-14 03:39:29 +08:00
2021-08-26 12:08:51 +08:00
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")
2017-05-05 18:10:49 +08:00
if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
foreach(HEADER IN ITEMS zdict.h zstd.h zstd_errors.h)
2021-08-26 12:08:51 +08:00
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/${HEADER}" "defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1)" "1" )
2017-05-05 18:10:49 +08:00
endforeach()
2016-11-23 08:00:31 +08:00
endif()
2023-10-31 05:58:07 +08:00
if(VCPKG_TARGET_IS_WINDOWS AND ZSTD_BUILD_PROGRAMS)
vcpkg_copy_tools(TOOL_NAMES zstd AUTO_CLEAN)
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"
)