Error seen (MSVC native build):
mpgen error: mp\util.cpp:332: failed: CreateProcessA(...): #2 The system
cannot find the file specified.
Problem: mpgen constructs capnp tool paths as capnp_PREFIX + "/bin/capnp"
and capnp_PREFIX + "/bin/capnpc-c++". capnp_PREFIX is derived from the
capnproto include directory parent, so on a vcpkg install it resolves to
something like vcpkg_installed/x64-windows-release. But vcpkg installs
executables under tools/capnproto/, not bin/, so the constructed path
does not exist and CreateProcessA fails with ERROR_FILE_NOT_FOUND.
Fix: pass the CAPNP_EXECUTABLE and CAPNPC_CXX_EXECUTABLE cmake variables
from CapnProtoConfig.cmake as compile definitions to mpgen, and use them
in gen.cpp instead of constructing paths from capnp_PREFIX.
Using these cmake variables rather than reading the CapnProto::capnp_tool
imported target IMPORTED_LOCATION directly is important: on Debian/Ubuntu,
IMPORTED_LOCATION is set to a non-existent path due to a multiarch cmake
packaging bug in libcapnp-dev (see
https://github.com/bitcoin-core/libmultiprocess/issues/328). The cmake
variables avoid this because CapnProtoConfig.cmake hardcodes the correct
paths on Debian/Ubuntu, and on other platforms (including vcpkg) the
variables hold generator expressions that target_compile_definitions
evaluates correctly at generation time.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>