diff --git a/ports/hnswlib/cmake.patch b/ports/hnswlib/cmake.patch new file mode 100644 index 00000000000..7e5be49eec0 --- /dev/null +++ b/ports/hnswlib/cmake.patch @@ -0,0 +1,44 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 7cebe60..b2aecc8 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1,11 +1,36 @@ +-cmake_minimum_required (VERSION 2.6) +-project(hnsw_lib ++cmake_minimum_required(VERSION 3.0...3.26) ++ ++project(hnswlib + LANGUAGES CXX) + ++include(GNUInstallDirs) ++ + add_library(hnswlib INTERFACE) +-target_include_directories(hnswlib INTERFACE .) ++add_library(hnswlib::hnswlib ALIAS hnswlib) ++ ++target_include_directories(hnswlib INTERFACE ++ $ ++ $) ++ ++# Install ++install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/hnswlib ++ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + ++install(TARGETS hnswlib ++ EXPORT hnswlibTargets) ++ ++install(EXPORT hnswlibTargets ++ FILE hnswlibConfig.cmake ++ NAMESPACE hnswlib:: ++ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hnswlib) ++ ++# Examples and tests + if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) ++ option(HNSWLIB_EXAMPLES "Build examples and tests." ON) ++else() ++ option(HNSWLIB_EXAMPLES "Build examples and tests." OFF) ++endif() ++if(HNSWLIB_EXAMPLES) + set(CMAKE_CXX_STANDARD 11) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") diff --git a/ports/hnswlib/portfile.cmake b/ports/hnswlib/portfile.cmake index cf150d766bc..4d1379ef4fe 100644 --- a/ports/hnswlib/portfile.cmake +++ b/ports/hnswlib/portfile.cmake @@ -1,12 +1,24 @@ vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO nmslib/hnswlib - REF 359b2ba87358224963986f709e593d799064ace6 # v0.7.0 - SHA512 59a0c02bbe8f7389a2ecad9188a76eb3847b719a213d306093753c04e4eeb11d95e8e310aa03888364be475a2f2e6e7976bd81117517eef81eff2983379ac743 + REF "v${VERSION}" + SHA512 fd74c23040598973d7e0b5a6af73eb884ee2d30703187d1702fdd48eaf8f7f96d8fbb125d3763f90111d9fb7c5ab3434ebdb818da8717d35c5571e99083c812b HEAD_REF master + PATCHES + cmake.patch # Backport CMake targets from nmslib/hnswlib #446 to 0.7.0 release. ) -file(COPY "${SOURCE_PATH}/hnswlib" DESTINATION "${CURRENT_PACKAGES_DIR}/include") +set(VCPKG_BUILD_TYPE "release") # header-only port + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DHNSWLIB_EXAMPLES=OFF +) + +vcpkg_cmake_install() +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/hnswlib) + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib") -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/ports/hnswlib/usage b/ports/hnswlib/usage deleted file mode 100644 index 3ef3d72f9ba..00000000000 --- a/ports/hnswlib/usage +++ /dev/null @@ -1,4 +0,0 @@ -hnswlib is header-only and can be used from CMake via: - - find_path(HNSWLIB_INCLUDE_DIRS "hnswlib/hnswlib.h") - target_include_directories(main PRIVATE ${HNSWLIB_INCLUDE_DIRS}) diff --git a/ports/hnswlib/vcpkg.json b/ports/hnswlib/vcpkg.json index 94e35819276..72b6c82932a 100644 --- a/ports/hnswlib/vcpkg.json +++ b/ports/hnswlib/vcpkg.json @@ -1,7 +1,18 @@ { "name": "hnswlib", "version": "0.7.0", + "port-version": 1, "description": "Header-only library for fast approximate nearest neighbors", "homepage": "https://github.com/nmslib/hnswlib", - "license": "Apache-2.0" + "license": "Apache-2.0", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] } diff --git a/versions/baseline.json b/versions/baseline.json index 5785f60378c..e5d7fd9cb9e 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -3130,7 +3130,7 @@ }, "hnswlib": { "baseline": "0.7.0", - "port-version": 0 + "port-version": 1 }, "hps": { "baseline": "2022-01-18", diff --git a/versions/h-/hnswlib.json b/versions/h-/hnswlib.json index 1ed277d6806..7bc1c41cc35 100644 --- a/versions/h-/hnswlib.json +++ b/versions/h-/hnswlib.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "497030f03d37d63ff86c9e99d24d9e8f048ea067", + "version": "0.7.0", + "port-version": 1 + }, { "git-tree": "7053d263445d46410589894d921fa6c85fbf107c", "version": "0.7.0",