Skip to content

Commit

Permalink
Add CMake install targets (#446)
Browse files Browse the repository at this point in the history
* Add CMake install targets
* Set CMake version range
  • Loading branch information
moritz-h authored May 7, 2023
1 parent b3fb472 commit dccd4f9
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)

# 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")
Expand Down

0 comments on commit dccd4f9

Please sign in to comment.