vcpkg/ports/folly/portfile.cmake
Jia Yue Hua a5e5f4de45
[folly]: fix lib dependency (#25335)
* [folly]: fix lib dependency

* [folly]: fix dependency

* use file op delete cmake files

* fix cmake config package

* fix folly-config, minmax

* delete fix-cmake-module.patch

* revert LZ4 snappy

* fix lz4

* fix libevent targert

* fix bzip2

* remove sodium

* add version

* fix windows build

* fix deps

* fix deps

* fix deps

* fix deps

* fix deps

* fix deps

* fix Required find_dependenct

* fix feature
2022-10-08 21:09:22 -07:00

93 lines
3.5 KiB
CMake

vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
# Required to run build/generate_escape_tables.py et al.
vcpkg_find_acquire_program(PYTHON3)
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY)
vcpkg_add_to_path("${PYTHON3_DIR}")
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO facebook/folly
REF 46c03de426e26f4c5a92df37ab233c586fbe369a #v2022.08.15.00
SHA512 6798878d6892ed79d954fb5754ee102ea04868bce4be9be5dc7c6d6c7ddcbc5573719fe09470d89c385d9e487a75d1a9abc70c29c67698b957fc68b97a8bea32
HEAD_REF main
PATCHES
reorder-glog-gflags.patch
disable-non-underscore-posix-names.patch
boost-1.70.patch
fix-windows-minmax.patch
fix-deps.patch
)
file(REMOVE "${SOURCE_PATH}/CMake/FindFmt.cmake")
file(REMOVE "${SOURCE_PATH}/CMake/FindLibsodium.cmake")
file(REMOVE "${SOURCE_PATH}/CMake/FindZstd.cmake")
file(REMOVE "${SOURCE_PATH}/build/fbcode_builder/CMake/FindDoubleConversion.cmake")
file(REMOVE "${SOURCE_PATH}/build/fbcode_builder/CMake/FindGMock.cmake")
file(REMOVE "${SOURCE_PATH}/build/fbcode_builder/CMake/FindGflags.cmake")
file(REMOVE "${SOURCE_PATH}/build/fbcode_builder/CMake/FindGlog.cmake")
file(REMOVE "${SOURCE_PATH}/build/fbcode_builder/CMake/FindLibEvent.cmake")
file(REMOVE "${SOURCE_PATH}/build/fbcode_builder/CMake/FindSodium.cmake")
file(REMOVE "${SOURCE_PATH}/build/fbcode_builder/CMake/FindZstd.cmake")
if(VCPKG_CRT_LINKAGE STREQUAL static)
set(MSVC_USE_STATIC_RUNTIME ON)
else()
set(MSVC_USE_STATIC_RUNTIME OFF)
endif()
set(FEATURE_OPTIONS)
macro(feature FEATURENAME PACKAGENAME)
if("${FEATURENAME}" IN_LIST FEATURES)
list(APPEND FEATURE_OPTIONS -DCMAKE_DISABLE_FIND_PACKAGE_${PACKAGENAME}=OFF)
else()
list(APPEND FEATURE_OPTIONS -DCMAKE_DISABLE_FIND_PACKAGE_${PACKAGENAME}=ON)
endif()
endmacro()
feature(zlib ZLIB)
feature(bzip2 BZip2)
feature(lzma LibLZMA)
feature(lz4 LZ4)
feature(zstd Zstd)
feature(snappy Snappy)
feature(libsodium unofficial-sodium)
vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
OPTIONS
-DMSVC_USE_STATIC_RUNTIME=${MSVC_USE_STATIC_RUNTIME}
-DCMAKE_DISABLE_FIND_PACKAGE_LibDwarf=ON
-DCMAKE_DISABLE_FIND_PACKAGE_Libiberty=ON
-DCMAKE_DISABLE_FIND_PACKAGE_LibAIO=ON
-DLIBAIO_FOUND=OFF
-DCMAKE_INSTALL_DIR=share/folly
${FEATURE_OPTIONS}
)
vcpkg_cmake_install(ADD_BIN_TO_PATH)
vcpkg_copy_pdbs()
configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY)
vcpkg_cmake_config_fixup()
# Release folly-targets.cmake does not link to the right libraries in debug mode.
# We substitute with generator expressions so that the right libraries are linked for debug and release.
set(FOLLY_TARGETS_CMAKE "${CURRENT_PACKAGES_DIR}/share/folly/folly-targets.cmake")
FILE(READ ${FOLLY_TARGETS_CMAKE} _contents)
string(REPLACE "\${VCPKG_IMPORT_PREFIX}/lib/zlib.lib" "ZLIB::ZLIB" _contents "${_contents}")
STRING(REPLACE "\${VCPKG_IMPORT_PREFIX}/lib/" "\${VCPKG_IMPORT_PREFIX}/\$<\$<CONFIG:DEBUG>:debug/>lib/" _contents "${_contents}")
STRING(REPLACE "\${VCPKG_IMPORT_PREFIX}/debug/lib/" "\${VCPKG_IMPORT_PREFIX}/\$<\$<CONFIG:DEBUG>:debug/>lib/" _contents "${_contents}")
string(REPLACE "-vc140-mt.lib" "-vc140-mt\$<\$<CONFIG:DEBUG>:-gd>.lib" _contents "${_contents}")
FILE(WRITE ${FOLLY_TARGETS_CMAKE} "${_contents}")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
# Handle copyright
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
vcpkg_fixup_pkgconfig()