Skip to content

Commit dccd4f9

Browse files
authored
Add CMake install targets (#446)
* Add CMake install targets * Set CMake version range
1 parent b3fb472 commit dccd4f9

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

CMakeLists.txt

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
1-
cmake_minimum_required (VERSION 2.6)
2-
project(hnsw_lib
1+
cmake_minimum_required(VERSION 3.0...3.26)
2+
3+
project(hnswlib
34
LANGUAGES CXX)
45

6+
include(GNUInstallDirs)
7+
58
add_library(hnswlib INTERFACE)
6-
target_include_directories(hnswlib INTERFACE .)
9+
add_library(hnswlib::hnswlib ALIAS hnswlib)
10+
11+
target_include_directories(hnswlib INTERFACE
12+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
13+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
14+
15+
# Install
16+
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/hnswlib
17+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
718

19+
install(TARGETS hnswlib
20+
EXPORT hnswlibTargets)
21+
22+
install(EXPORT hnswlibTargets
23+
FILE hnswlibConfig.cmake
24+
NAMESPACE hnswlib::
25+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hnswlib)
26+
27+
# Examples and tests
828
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
29+
option(HNSWLIB_EXAMPLES "Build examples and tests." ON)
30+
else()
31+
option(HNSWLIB_EXAMPLES "Build examples and tests." OFF)
32+
endif()
33+
if(HNSWLIB_EXAMPLES)
934
set(CMAKE_CXX_STANDARD 11)
1035

1136
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")

0 commit comments

Comments
 (0)