Skip to content

Commit 86dd84e

Browse files
committed
Fix lz4 / HDF5 missing from flann.pc Requires: line.
lz4 is an unconditional dependency of flann (see #399), but until now was not correctly generated into the `Requires: lz4` line of `flann.pc`, because the `PKG_EXTERNAL_DEPS` variable used in `flann.pc.in` was not defined at all. This fixes build error `lz4.h: No such file or directory` for properly sandboxed builds, in which undeclared dependencies are not made available. Same thing for HDF5, but conditionally. For lz4, also remove the hardcode of `@LZ4_STATIC_LDFLAGS@` from `flann.pc.in`, as this is no longer necessary. That fixes an incorrect `-L` flag being generated in there, e.g. `-L/usr/lib;-llz4`. Thus fixes #480.
1 parent f9caaf6 commit 86dd84e

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ option(USE_MPI "Use MPI" OFF)
6262

6363
set(NVCC_COMPILER_BINDIR "" CACHE PATH "Directory where nvcc should look for C++ compiler. This is passed to nvcc through the --compiler-bindir option.")
6464

65+
# pkg-config dependencies to be generated into the .pc file
66+
set(PKGCONFIG_EXTERNAL_DEPS_LIST "")
67+
6568
if (NOT BUILD_C_BINDINGS)
6669
set(BUILD_PYTHON_BINDINGS OFF)
6770
set(BUILD_MATLAB_BINDINGS OFF)
@@ -81,6 +84,7 @@ if (NOT HDF5_FOUND)
8184
message(WARNING "hdf5 library not found, some tests will not be run")
8285
else()
8386
include_directories(${HDF5_INCLUDE_DIR})
87+
list(APPEND PKGCONFIG_EXTERNAL_DEPS_LIST "hdf5")
8488
endif()
8589

8690
if (USE_MPI OR HDF5_IS_PARALLEL)
@@ -150,6 +154,7 @@ endif(BUILD_CUDA_LIB)
150154
find_package(PkgConfig REQUIRED)
151155
pkg_check_modules(LZ4 REQUIRED liblz4)
152156
include_directories(${LZ4_INCLUDE_DIRS})
157+
list(APPEND PKGCONFIG_EXTERNAL_DEPS_LIST "liblz4")
153158

154159
#set the C/C++ include path to the "include" directory
155160
include_directories(BEFORE ${PROJECT_SOURCE_DIR}/src/cpp)

cmake/CMakeLists.txt

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
set(PKG_DESC "Fast Library for Approximate Nearest Neighbors")
2+
3+
# Compute `PKG_EXTERNAL_DEPS` string from `PKGCONFIG_EXTERNAL_DEPS_LIST`.
4+
# Once the project has `cmake_minimum_required(VERSION 2.6)`, this
5+
# can be replaced by `list(JOIN ...)`.
6+
set(PKG_EXTERNAL_DEPS "")
7+
foreach(_dep ${PKGCONFIG_EXTERNAL_DEPS_LIST})
8+
string(APPEND PKG_EXTERNAL_DEPS " ${_dep}")
9+
endforeach()
10+
211
set(pkg_conf_file ${CMAKE_CURRENT_BINARY_DIR}/flann.pc)
312
configure_file(flann.pc.in ${pkg_conf_file} @ONLY)
413
install(FILES ${pkg_conf_file}

cmake/flann.pc.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ Name: @PROJECT_NAME@
88
Description: @PKG_DESC@
99
Version: @FLANN_VERSION@
1010
Requires: @PKG_EXTERNAL_DEPS@
11-
Libs: -L${libdir} @LZ4_STATIC_LDFLAGS@ -lflann -lflann_cpp
11+
Libs: -L${libdir} -lflann -lflann_cpp
1212
Cflags: -I${includedir}
1313

0 commit comments

Comments
 (0)