From c0faac17a6d8a97923d434dfd0fe44935a337774 Mon Sep 17 00:00:00 2001 From: LTLA Date: Fri, 9 Jul 2021 23:20:11 -0700 Subject: [PATCH 1/4] Updated the CMakeLists to simply use as a fetch'd library. --- CMakeLists.txt | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 31935e0e..ec91f568 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,28 +1,27 @@ -cmake_minimum_required (VERSION 2.6) -project (hnsw_lib) +cmake_minimum_required (VERSION 3.14) +project(hnsw_lib + LANGUAGES CXX) -include_directories("${PROJECT_BINARY_DIR}") +add_library(hnswlib INTERFACE) +target_include_directories(hnswlib INTERFACE .) +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + set(CMAKE_CXX_STANDARD 11) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + SET( CMAKE_CXX_FLAGS "-Ofast -DNDEBUG -std=c++11 -DHAVE_CXX0X -openmp -march=native -fpic -ftree-vectorize") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + SET( CMAKE_CXX_FLAGS "-Ofast -lrt -DNDEBUG -std=c++11 -DHAVE_CXX0X -march=native -fpic -w -fopenmp -ftree-vectorize -ftree-vectorizer-verbose=0" ) + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + SET( CMAKE_CXX_FLAGS "-Ofast -lrt -DNDEBUG -std=c++11 -DHAVE_CXX0X -openmp -march=native -fpic -w -fopenmp -ftree-vectorize" ) + endif() -set(SOURCE_EXE main.cpp) + add_executable(test_updates examples/updates_test.cpp) + target_link_libraries(test_updates hnswlib) -set(SOURCE_LIB sift_1b.cpp) + add_executable(searchKnnCloserFirst_test examples/searchKnnCloserFirst_test.cpp) + target_link_libraries(searchKnnCloserFirst_test hnswlib) -add_library(sift_test STATIC ${SOURCE_LIB}) - - -add_executable(main ${SOURCE_EXE}) -if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - SET( CMAKE_CXX_FLAGS "-Ofast -DNDEBUG -std=c++11 -DHAVE_CXX0X -openmp -march=native -fpic -ftree-vectorize") -elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -SET( CMAKE_CXX_FLAGS "-Ofast -lrt -DNDEBUG -std=c++11 -DHAVE_CXX0X -openmp -march=native -fpic -w -fopenmp -ftree-vectorize -ftree-vectorizer-verbose=0" ) -elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - SET( CMAKE_CXX_FLAGS "-Ofast -lrt -DNDEBUG -std=c++11 -DHAVE_CXX0X -openmp -march=native -fpic -w -fopenmp -ftree-vectorize" ) + add_executable(main main.cpp sift_1b.cpp) + target_link_libraries(main hnswlib) endif() - -add_executable(test_updates examples/updates_test.cpp) - -add_executable(searchKnnCloserFirst_test examples/searchKnnCloserFirst_test.cpp) - -target_link_libraries(main sift_test) From 085b16503161d8c204f753240f96629ca6184054 Mon Sep 17 00:00:00 2001 From: LTLA Date: Sat, 10 Jul 2021 00:26:36 -0700 Subject: [PATCH 2/4] Added the missing header. --- hnswlib/visited_list_pool.h | 1 + 1 file changed, 1 insertion(+) diff --git a/hnswlib/visited_list_pool.h b/hnswlib/visited_list_pool.h index 6b0f4458..5e1a4a58 100644 --- a/hnswlib/visited_list_pool.h +++ b/hnswlib/visited_list_pool.h @@ -2,6 +2,7 @@ #include #include +#include namespace hnswlib { typedef unsigned short int vl_type; From c41ee3bf1f56d326354e0b60f4d859ffa45416d0 Mon Sep 17 00:00:00 2001 From: LTLA Date: Sat, 10 Jul 2021 00:29:20 -0700 Subject: [PATCH 3/4] Made the data getter const. --- hnswlib/hnswalg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hnswlib/hnswalg.h b/hnswlib/hnswalg.h index f23c17d9..2bd2eb5e 100644 --- a/hnswlib/hnswalg.h +++ b/hnswlib/hnswalg.h @@ -744,7 +744,7 @@ namespace hnswlib { } template - std::vector getDataByLabel(labeltype label) + std::vector getDataByLabel(labeltype label) const { tableint label_c; auto search = label_lookup_.find(label); From d6c8e3a3896129a7f642bc23cdce4536e8b45a65 Mon Sep 17 00:00:00 2001 From: LTLA Date: Wed, 15 Sep 2021 23:05:10 -0700 Subject: [PATCH 4/4] Lowered minimum CMake version back to 2.6. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ec91f568..e2f3d716 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.14) +cmake_minimum_required (VERSION 2.6) project(hnsw_lib LANGUAGES CXX)