From 7239a977c3000a3b075b6dd63a0c508106e7005e Mon Sep 17 00:00:00 2001 From: VijayabaskarR-06 <240424846+VijayabaskarR-06@users.noreply.github.com> Date: Wed, 7 Oct 2026 13:56:44 +0530 Subject: [PATCH] cmake: Pass installed include dir to mpgen mpgen finds /mp/proxy.capnp using the CMAKE_INSTALL_PREFIX that was set when it was built. If libmultiprocess is installed somewhere else, for example with `cmake --install build --prefix ~/.local`, or the install is moved, code generation fails with "Import failed: /mp/proxy.capnp". When target_capnp_sources uses the imported Libmultiprocess::mpgen target, pass its include directory to mpgen as an import path. That path comes from the installed package location, so it is correct wherever the package ends up. Builds that use libmultiprocess as a subdirectory already pass MP_INCLUDE_DIR and are unchanged. Fixes #134 --- cmake/TargetCapnpSources.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/TargetCapnpSources.cmake b/cmake/TargetCapnpSources.cmake index 2334e260..9f17ba4b 100644 --- a/cmake/TargetCapnpSources.cmake +++ b/cmake/TargetCapnpSources.cmake @@ -78,11 +78,15 @@ function(target_capnp_sources target include_prefix) endif() get_property(mp_include_dir GLOBAL PROPERTY MP_INCLUDE_DIR) + set(mpgen_import_paths ${mp_include_dir}) + if(NOT mp_include_dir AND MPGEN_BINARY STREQUAL "Libmultiprocess::mpgen") + get_property(mpgen_import_paths TARGET Libmultiprocess::mpgen PROPERTY INTERFACE_INCLUDE_DIRECTORIES) + endif() set(generated_headers "") foreach(capnp_file IN LISTS TCS_UNPARSED_ARGUMENTS) add_custom_command( OUTPUT ${capnp_file}.c++ ${capnp_file}.h ${capnp_file}.proxy-client.c++ ${capnp_file}.proxy-types.h ${capnp_file}.proxy-server.c++ ${capnp_file}.proxy-types.c++ ${capnp_file}.proxy.h - COMMAND ${MPGEN_BINARY} ${CMAKE_CURRENT_SOURCE_DIR} ${include_prefix} ${CMAKE_CURRENT_SOURCE_DIR}/${capnp_file} ${TCS_IMPORT_PATHS} ${mp_include_dir} + COMMAND ${MPGEN_BINARY} ${CMAKE_CURRENT_SOURCE_DIR} ${include_prefix} ${CMAKE_CURRENT_SOURCE_DIR}/${capnp_file} ${TCS_IMPORT_PATHS} ${mpgen_import_paths} DEPENDS ${capnp_file} ${MPGEN_BINARY} VERBATIM )