From 579fa4e46f4666eb0fe06b3bcf60ce8a9b5778b7 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Thu, 30 Jan 2025 18:32:39 +0000 Subject: [PATCH 1/2] build: split capnp includes into build/install interfaces and mark them as SYSTEM We're not interested in warnings from Capnp's headers. The interfaces will be treated differently in the next commit. --- CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index de8c95a4..da50e396 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,7 +92,15 @@ target_include_directories(multiprocess PUBLIC $ $ $ - ${CAPNP_INCLUDE_DIRECTORY}) +) + +target_include_directories(multiprocess SYSTEM PUBLIC + $ +) +target_include_directories(multiprocess SYSTEM PUBLIC + $ +) + target_link_libraries(multiprocess PRIVATE CapnProto::capnp) target_link_libraries(multiprocess PRIVATE CapnProto::capnp-rpc) target_link_libraries(multiprocess PRIVATE CapnProto::kj) From 7ac1237ea32aad4a174aaf1958fe2fe0ac129662 Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Thu, 30 Jan 2025 18:39:18 +0000 Subject: [PATCH 2/2] build: work around CMake quirk when building as a subdir of Bitcoin Core When building as a subdir of Core and using depends, capnp includes may end up being installed in a path like: /dev/bitcoin/depends/HOST/include It then detects that the install interface has been given an absolute path inside of the project dir: /dev/bitcoin/ In that case it throws an error because it wants paths within the project to always be relative. This shouldn't matter *at all* because we're never actually going to install the lib anyway, but CMake populates the install interface despite the EXCLUDE_FROM_ALL property being set. Since other projects may wish to include libmultiprocess as a subdir and also install it, don't use the subdir condition to check for this case. Instead, test for the EXCLUDE_FROM_ALL on the directory, as if that's set, the parent project won't be installing. --- CMakeLists.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index da50e396..24049e08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,9 +97,18 @@ target_include_directories(multiprocess PUBLIC target_include_directories(multiprocess SYSTEM PUBLIC $ ) -target_include_directories(multiprocess SYSTEM PUBLIC - $ -) + +# Hack to avoid exporting a path "which is prefixed in the source directory". +# If we're in another project's subdir and capnp is installed somewhere inside +# that project (as it is with depends in Bicoin Core) CMake refuses to allow it +# in the install interface. Use the "EXCLUDE_FROM_ALL" property as a proxy for +# detecting this condition, as in that case install won't happen anyway. +get_directory_property(mp_skip_install EXCLUDE_FROM_ALL) +if(NOT "${mp_skip_install}") + target_include_directories(multiprocess SYSTEM PUBLIC + $ + ) +endif() target_link_libraries(multiprocess PRIVATE CapnProto::capnp) target_link_libraries(multiprocess PRIVATE CapnProto::capnp-rpc)