Package: libcapnp-dev
Version: 1.1.0-2
Severity: normal
X-Debbugs-Cc: [email protected]

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.

-- System Information:
Debian Release: 13.6
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.18.35 (SMP w/5 CPU threads)
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: unable to detect

Versions of packages libcapnp-dev depends on:
ii  libcapnp-1.1.0  1.1.0-2
ii  libssl-dev      3.5.7-1~deb13u2

libcapnp-dev recommends no packages.

libcapnp-dev suggests no packages.

-- no debconf information

Reply via email to