Commit df0fbbe3 authored by Harris Hancock's avatar Harris Hancock

cmake: Use search-specific-dirs-then-system-dirs idiom

An inconsistency was introduced with the previous fix to allow Cap'n Proto
installations in system directories to be found by CapnProtoTargets.cmake:
if the user installed Cap'n Proto in two locations, one of which is a
system directory, e.g. /usr and /somewhere/else, and set
PKG_CONFIG_PATH=/somewhere/else/lib/pkgconfig, the dependent project
would use headers from /somewhere/else/include, but libraries from /usr/lib.

This change resolves the inconsistency, allowing PKG_CONFIG_PATH to solely
control the location of the desired installation of Cap'n Proto.
parent 25b306ef
......@@ -86,7 +86,14 @@ function(_capnp_import_pkg_config_target target)
find_library(CapnProto_${target}_IMPORTED_LOCATION
NAMES ${target_name_shared} ${target_name_static} # prefer libfoo-version.so over libfoo.a
PATHS ${${target}_LIBRARY_DIRS}
NO_DEFAULT_PATH
)
# If the installed version of Cap'n Proto is in a system location, pkg-config will not have filled
# in ${target}_LIBRARY_DIRS. To account for this, fall back to a regular search.
find_library(CapnProto_${target}_IMPORTED_LOCATION
NAMES ${target_name_shared} ${target_name_static} # prefer libfoo-version.so over libfoo.a
)
if(NOT CapnProto_${target}_IMPORTED_LOCATION)
# Not an error if the library doesn't exist -- we may have found a lite mode installation.
if(CapnProto_DEBUG)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment