vcpkg/ports/c-ares/portfile.cmake
Johannes Schönberger 9db6c29de7
Fix c-ares compilation under Linux with dynamic linkage (#19126)
* Fix c-ares compilation under Linux with shared linkage

* Update version

* Update version file

Co-authored-by: Victor Romero <romerosanchezv@gmail.com>
2021-08-02 16:55:47 -07:00

44 lines
1.4 KiB
CMake

vcpkg_fail_port_install(ON_TARGET "uwp")
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO c-ares/c-ares
REF cares-1_17_1
SHA512 e2a2a40118b128755571274d0cfe7cc822bc18392616378c6dd5f73f210571d7e5005a40ba0763658bdae7f2c7aadb324b2888ad8b4dcb54ad47dfaf97c2ebfc
HEAD_REF master
)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_STATIC)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_SHARED)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DCARES_STATIC=${BUILD_STATIC}
-DCARES_SHARED=${BUILD_SHARED}
-DCARES_BUILD_TOOLS=OFF
-DCARES_BUILD_TESTS=OFF
-DCARES_BUILD_CONTAINER_TESTS=OFF
)
vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/c-ares)
vcpkg_copy_pdbs()
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/ares.h
"#ifdef CARES_STATICLIB" "#if 1"
)
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL static OR NOT VCPKG_TARGET_IS_WINDOWS)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin") # Empty folders
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")
# Handle copyright
file(INSTALL "${SOURCE_PATH}/LICENSE.md" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)