Dear Maintainer,
the bundled CMake configuration of this package contains invalid paths.
I also checked version 1.4.0-3 which has the same problem.
The problem is in the file
/usr/lib/x86_64-linux-gnu/cmake/CapnProto/CapnProtoTargets.cmake
When importing this in a CMake project, e.g. via
find_package(CapnProto REQUIRED)
the imported location of CapnProto::capnp_tool will be set to
/usr/lib/bin/capnp
However, the tool is located at
/usr/bin/capnp
This is because in CapnProtoTargets.cmake, the path is calculated as
follows (lines 200-212 in 1.1.0-2):
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
# [snip]
add_executable(CapnProto::capnp_tool IMPORTED)
set_target_properties(CapnProto::capnp_tool PROPERTIES
IMPORTED_LOCATION "${_IMPORT_PREFIX}/bin/capnp${CMAKE_EXECUTABLE_SUFFIX}"
)
This path calculation apparently does not account for the x86_64-linux-gnu
component in the path.
As a result, when I do something like this in my CMake configuration:
add_custom_command(OUTPUT foo.c++ foo.h
COMMAND CapnProto::capnp_tool compile
-I${CAPNP_INCLUDE_DIRECTORY}
-o$<TARGET_FILE:CapnProto::capnpc_cpp>:${CMAKE_CURRENT_BINARY_DIR}
foo.spec
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
MAIN_DEPENDENCY foo.spec
)
CMake will exit with an error because it tries to invoke
/usr/lib/bin/capnp.
This also affects the paths of CapnProto::capnpc_cpp and
CapnProto::capnpc_capnp.
The top comment in CapnProtoTargets.cmake explicitly states that this
file is *not* generated by CMake but by Cap'n Proto's autotools build.
So this may be an upstream bug where the script generating this file
does not account for the path component.