Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backwards compatible dependencies #48

Merged
merged 3 commits into from
Oct 4, 2024
Merged
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: 24 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,34 @@ message(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}")
# -----------------------------------------------------------------------------
# Dependencies
# -----------------------------------------------------------------------------
find_package(lz4 CONFIG REQUIRED)
find_package(flann CONFIG REQUIRED)
find_package(OpenMP)
find_package(lz4 CONFIG)
if(NOT ${lz4_FOUND})
find_package(PkgConfig REQUIRED)

pkg_check_modules(lz4 REQUIRED IMPORTED_TARGET liblz4)
set(LZ4_TARGET PkgConfig::lz4)
endif()

if(NOT ${lz4_FOUND})
message (FATAL_ERROR "lz4 NOT found")
endif()
message (STATUS "Found lz4 version ${lz4_VERSION}")

find_package(flann CONFIG)
if(NOT ${flann_FOUND})
find_package(PkgConfig REQUIRED)

if(${flann_FOUND})
message (STATUS "Found flann version ${flann_VERSION}")
pkg_check_modules(flann REQUIRED flann)
set(FLANN_TARGET flann_cpp)
set(flann_INCLUDE_DIR "${flann_INCLUDE_DIRS}/flann")
endif()

if(${lz4_FOUND})
message (STATUS "Found lz4 version ${lz4_VERSION}")
if(NOT ${flann_FOUND})
message (FATAL_ERROR "flann NOT found")
endif()
message (STATUS "Found flann version ${flann_VERSION}")

find_package(OpenMP)

if(OpenMP_CXX_FOUND)
message (STATUS "OpenMP found")
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ When configuring cmake make sure to setup vcpkg with CMAKE_TOOLCHAIN_FILE (`PATH

You may also use system-specific package managers, e.g. on Linux with
```bash
sudo apt-get -y install libflann-dev liblz4-dev
sudo apt-get -y install libflann-dev liblz4-dev pkg-config
```
and Mac OS with
```
brew install flann lz4
brew install flann lz4 pkg-config
```

### Generate the build files
Expand Down
16 changes: 10 additions & 6 deletions hdi/dimensionality_reduction/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,17 @@ if(${HDILib_INSTALL})
)

# Install dependency headers
if(DEFINED flann_INCLUDE_DIR)
install(DIRECTORY "${flann_INCLUDE_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/include" COMPONENT FLANN_HEADERS)
else()
get_target_property(FLANN_INCLUDE_DIR ${FLANN_TARGET} INTERFACE_INCLUDE_DIRECTORIES)
if(FLANN_INCLUDE_DIR)
install(DIRECTORY "${FLANN_INCLUDE_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/include" COMPONENT FLANN_HEADERS)
if(NOT flann_INCLUDE_DIR)
get_target_property(flann_INCLUDE_DIR ${FLANN_TARGET} INTERFACE_INCLUDE_DIRECTORIES)
endif()

if(flann_INCLUDE_DIR)
if(NOT flann_INCLUDE_DIR MATCHES "flann$")
set(flann_INCLUDE_DIR "${flann_INCLUDE_DIR}/flann")
endif()

message(STATUS "Using flann includes at: ${flann_INCLUDE_DIR}")
install(DIRECTORY "${flann_INCLUDE_DIR}/" DESTINATION "${CMAKE_INSTALL_PREFIX}/include/flann" COMPONENT FLANN_HEADERS)
endif()

install(DIRECTORY "${HNSWLIB_INCLUDE_DIR}/hnswlib/" DESTINATION "${CMAKE_INSTALL_PREFIX}/include/hnswlib" COMPONENT HNSW_HEADERS)
Expand Down
Loading