Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,37 @@ install(EXPORT hnswlibTargets
NAMESPACE hnswlib::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hnswlib)

# pkg-config / pkgconf support
option(HNSWLIB_PKG_CONFIG "Build pkg-config manifest" ON)
if(HNSWLIB_PKG_CONFIG)

function(JOIN_PATHS joined_path first_path_segment)
set(temp_path "${first_path_segment}")
foreach(current_segment IN LISTS ARGN)
if(NOT ("${current_segment}" STREQUAL ""))
if(IS_ABSOLUTE "${current_segment}")
set(temp_path "${current_segment}")
else()
set(temp_path "${temp_path}/${current_segment}")
endif()
endif()
endforeach()
set(${joined_path} "${temp_path}" PARENT_SCOPE)
endfunction()

JOIN_PATHS(libdir_for_pc_file "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}")
JOIN_PATHS(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")

configure_file(
"libhnswlib.pc.in"
"libhnswlib.pc"
@ONLY)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libhnswlib.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")

endif()

# Examples and tests
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
option(HNSWLIB_EXAMPLES "Build examples and tests." ON)
Expand Down
12 changes: 12 additions & 0 deletions libhnswlib.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@
libdir=@libdir_for_pc_file@
includedir=@includedir_for_pc_file@

Name: lib@CMAKE_PROJECT_NAME@
Description: Header-only C++/python library for fast approximate nearest neighbors.
Version:
URL: https://github.com/nmslib/hnswlib
Libs: -L${libdir}
Cflags: -I${includedir}