Skip to content

Commit 7c63a15

Browse files
authored
Merge pull request #340 from LTLA/master
Expose CMake target for use via FetchContent
2 parents ff10e88 + d6c8e3a commit 7c63a15

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

CMakeLists.txt

+19-20
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
cmake_minimum_required (VERSION 2.6)
2-
project (hnsw_lib)
2+
project(hnsw_lib
3+
LANGUAGES CXX)
34

4-
include_directories("${PROJECT_BINARY_DIR}")
5+
add_library(hnswlib INTERFACE)
6+
target_include_directories(hnswlib INTERFACE .)
57

8+
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
9+
set(CMAKE_CXX_STANDARD 11)
610

11+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
12+
SET( CMAKE_CXX_FLAGS "-Ofast -DNDEBUG -std=c++11 -DHAVE_CXX0X -openmp -march=native -fpic -ftree-vectorize")
13+
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
14+
SET( CMAKE_CXX_FLAGS "-Ofast -lrt -DNDEBUG -std=c++11 -DHAVE_CXX0X -march=native -fpic -w -fopenmp -ftree-vectorize -ftree-vectorizer-verbose=0" )
15+
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
16+
SET( CMAKE_CXX_FLAGS "-Ofast -lrt -DNDEBUG -std=c++11 -DHAVE_CXX0X -openmp -march=native -fpic -w -fopenmp -ftree-vectorize" )
17+
endif()
718

8-
set(SOURCE_EXE main.cpp)
19+
add_executable(test_updates examples/updates_test.cpp)
20+
target_link_libraries(test_updates hnswlib)
921

10-
set(SOURCE_LIB sift_1b.cpp)
22+
add_executable(searchKnnCloserFirst_test examples/searchKnnCloserFirst_test.cpp)
23+
target_link_libraries(searchKnnCloserFirst_test hnswlib)
1124

12-
add_library(sift_test STATIC ${SOURCE_LIB})
13-
14-
15-
add_executable(main ${SOURCE_EXE})
16-
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
17-
SET( CMAKE_CXX_FLAGS "-Ofast -DNDEBUG -std=c++11 -DHAVE_CXX0X -openmp -march=native -fpic -ftree-vectorize")
18-
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
19-
SET( CMAKE_CXX_FLAGS "-Ofast -lrt -DNDEBUG -std=c++11 -DHAVE_CXX0X -openmp -march=native -fpic -w -fopenmp -ftree-vectorize -ftree-vectorizer-verbose=0" )
20-
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
21-
SET( CMAKE_CXX_FLAGS "-Ofast -lrt -DNDEBUG -std=c++11 -DHAVE_CXX0X -openmp -march=native -fpic -w -fopenmp -ftree-vectorize" )
25+
add_executable(main main.cpp sift_1b.cpp)
26+
target_link_libraries(main hnswlib)
2227
endif()
23-
24-
add_executable(test_updates examples/updates_test.cpp)
25-
26-
add_executable(searchKnnCloserFirst_test examples/searchKnnCloserFirst_test.cpp)
27-
28-
target_link_libraries(main sift_test)

hnswlib/hnswalg.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ namespace hnswlib {
744744
}
745745

746746
template<typename data_t>
747-
std::vector<data_t> getDataByLabel(labeltype label)
747+
std::vector<data_t> getDataByLabel(labeltype label) const
748748
{
749749
tableint label_c;
750750
auto search = label_lookup_.find(label);

hnswlib/visited_list_pool.h

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include <mutex>
44
#include <string.h>
5+
#include <deque>
56

67
namespace hnswlib {
78
typedef unsigned short int vl_type;

0 commit comments

Comments
 (0)