Repository: bitcoin/bitcoin (language: cpp)

Issue:
depends: capnp build ignores config_opts
### Is there an existing issue for this?

- [x] I have searched the existing issues

### Current behaviour

It seems that when building capnp via depends the `config_opts` in `capnp.mk` are ignored, i.e. `-DBUILD_TESTING=OFF`, `-DWITH_OPENSSL=OFF` and `-DWITH_ZLIB=OFF`.

This can be seen in the depends build log by e.g. `Built target capnp-heavy-tests`, a target that should be skipped entirely. It becomes a problem during the `cmake -B build --toolchain ...` step, because it will complain about not finding OpenSSL and zlib, both of which it shouldn't need. 

### Expected behaviour

Don't build test target and, more importantly, don't look for OpenSSL.

### Steps to reproduce

```sh
git clean -dfx
make -C depends NO_QT=1 NO_USDT=1 NO_ZMQ=1 NO_BDB=1 MULTIPROCESS=1
cmake -B build --toolchain /Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0/toolchain.cmake
...
  Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
```

### Relevant log output

Depends build with `V=1`: https://gist.github.com/Sjors/4e851f2455c67372ad40a8382432acf5

It looks like it does set `-DBUILD_TESTING=OFF -DWITH_OPENSSL=OFF -DWITH_ZLIB=OFF` for the native build:

```
{ cd /Users/sjors/dev/bitcoin/depends/work/build/aarch64-apple-darwin24.3.0/native_capnp/1.1.0-c8c5a5f0b88/.; export     PKG_CONFIG_LIBDIR=/Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0/native/lib/pkgconfig PKG_CONFIG_PATH=/Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0/native/share/pkgconfig PKG_CONFIG_SYSROOT_DIR=/ CMAKE_MODULE_PATH=/Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0/native/lib/cmake PATH="/Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0/native/bin:/opt/homebrew/opt/gnu-sed/libexec/gnubin:/opt/homebrew/opt/grep/libexec/gnubin:/Users/sjors/.nvm/versions/node/v16.20.2/bin:/Users/sjors/.local/bin:/Users/sjors/.pyenv/shims:/Users/sjors/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/Users/sjors/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/MacGPG2/bin:/opt/podman/bin:/Users/sjors/.cargo/bin:/Applications/iTerm.app/Contents/Resources/utilities";   env CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" CFLAGS="  -I/Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0/native/include          " CXX="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" CXXFLAGS="  -I/Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0/native/include          " LDFLAGS="  -L/Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0/native/lib    " cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX:PATH="/Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0/native" -DCMAKE_AR=`which /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar` -DCMAKE_NM=`which /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm` -DCMAKE_RANLIB=`which /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib` -DCMAKE_INSTALL_LIBDIR=lib/ -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=1 -DBUILD_TESTING=OFF -DWITH_OPENSSL=OFF -DWITH_ZLIB=OFF        -DCMAKE_INSTALL_RPATH:PATH="/Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0/native/lib" .; }
```

But not for the non-native(?) one:

```
{ cd /Users/sjors/dev/bitcoin/depends/work/build/aarch64-apple-darwin24.3.0/capnp/1.1.0-31298932310/.; export     PKG_CONFIG_LIBDIR=/Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0/lib/pkgconfig PKG_CONFIG_PATH=/Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0/share/pkgconfig PKG_CONFIG_SYSROOT_DIR=/ CMAKE_MODULE_PATH=/Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0/lib/cmake PATH="/Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0/native/bin:/opt/homebrew/opt/gnu-sed/libexec/gnubin:/opt/homebrew/opt/grep/libexec/gnubin:/Users/sjors/.nvm/versions/node/v16.20.2/bin:/Users/sjors/.local/bin:/Users/sjors/.pyenv/shims:/Users/sjors/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/Users/sjors/.rbenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/MacGPG2/bin:/opt/podman/bin:/Users/sjors/.cargo/bin:/Applications/iTerm.app/Contents/Resources/utilities";   env CC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" CFLAGS="  -I/Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0/include     -pipe -std=c11 -mmacos-version-min=13.0 -arch arm64 -O2    " CXX="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -stdlib=libc++ -isysroot/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk" CXXFLAGS="  -I/Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0/include     -pipe -std=c++20 -mmacos-version-min=13.0 -arch arm64 -O2    " LDFLAGS="-Wl,-platform_version,macos,13.0,14.0  -L/Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0/lib    " cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX:PATH="/Users/sjors/dev/bitcoin/depends/aarch64-apple-darwin24.3.0" -DCMAKE_AR=`which /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar` -DCMAKE_NM=`which /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm` -DCMAKE_RANLIB=`which /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib` -DCMAKE_INSTALL_LIBDIR=lib/ -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=1        .; }
```

### How did you obtain Bitcoin Core

Compiled from source

### What version of Bitcoin Core are you using?

master@698f86964c68041d938aaf54fdd39466266c371c

### Operating system and version

macOS 15.3.2

### Machine specifications

M4 Mac

XCode 16.2
cmake version 3.31.4

```
xcode-select -p
/Applications/Xcode.app/Contents/Developer
```


Discussion / hints:
The macOS native builds don't use depends, so #30975 would not pick this is up.

cc @ryanofsky
I can also reproduce this on Intel macOS 13.7.4 with Xcode 15.2.
Not sure if I can reproduce this locally. At least if I run `make -C depends NO_QT=1 NO_USDT=1 NO_ZMQ=1 NO_BDB=1 MULTIPROCESS=1 capnp V=1` I do see cmake being called with `-DBUILD_TESTING=OFF -DWITH_OPENSSL=OFF -DWITH_ZLIB=OFF`.

Diffing the native and non-native packages though, I wonder if there's a chance this could caused by syntax affecting older version of make, because the non-native package seems to have an extra := following the define. Could try:

```diff
--- a/depends/packages/capnp.mk
+++ b/depends/packages/capnp.mk
@@ -5,7 +5,7 @@ $(package)_download_file=$(native_$(package)_download_file)
 $(package)_file_name=$(native_$(package)_file_name)
 $(package)_sha256_hash=$(native_$(package)_sha256_hash)
 
-define $(package)_set_vars :=
+define $(package)_set_vars
   $(package)_config_opts := -DBUILD_TESTING=OFF
   $(package)_config_opts += -DWITH_OPENSSL=OFF
   $(package)_config_opts += -DWITH_ZLIB=OFF
diff --git a/depends/packages/libmultiprocess.mk b/depends/packages/libmultiprocess.mk
index a181e05100bb..bf705ddb9e7e 100644
@@ -8,7 +8,7 @@ ifneq ($(host),$(build))
 $(package)_dependencies += native_capnp
 endif
 
-define $(package)_set_vars :=
+define $(package)_set_vars
 ifneq ($(host),$(build))
 $(package)_config_opts := -DCAPNP_EXECUTABLE="$$(native_capnp_prefixbin)/capnp"
 $(package)_config_opts += -DCAPNPC_CXX_EXECUTABLE="$$(native_capnp_prefixbin)/capnpc-c++"
```
Both macs have GNU Make 3.81

Trying your modification. If it works, it's yet another reason to migrate depends to cmake...?


That did the trick.
Opened #32070 to fix it.

Fix patch:
diff --git a/depends/packages/capnp.mk b/depends/packages/capnp.mk
index dff92d9e61fe8..f8c4406f3e236 100644
--- a/depends/packages/capnp.mk
+++ b/depends/packages/capnp.mk
@@ -6,7 +6,7 @@ $(package)_file_name=$(native_$(package)_file_name)
 $(package)_sha256_hash=$(native_$(package)_sha256_hash)
 $(package)_patches=abi_placement_new.patch
 
-define $(package)_set_vars :=
+define $(package)_set_vars
   $(package)_config_opts := -DBUILD_TESTING=OFF
   $(package)_config_opts += -DWITH_OPENSSL=OFF
   $(package)_config_opts += -DWITH_ZLIB=OFF
diff --git a/depends/packages/libmultiprocess.mk b/depends/packages/libmultiprocess.mk
index afbd315e38806..47064a9bb6c30 100644
--- a/depends/packages/libmultiprocess.mk
+++ b/depends/packages/libmultiprocess.mk
@@ -8,7 +8,7 @@ ifneq ($(host),$(build))
 $(package)_dependencies += native_capnp
 endif
 
-define $(package)_set_vars :=
+define $(package)_set_vars
 ifneq ($(host),$(build))
 $(package)_config_opts := -DCAPNP_EXECUTABLE="$$(native_capnp_prefixbin)/capnp"
 $(package)_config_opts += -DCAPNPC_CXX_EXECUTABLE="$$(native_capnp_prefixbin)/capnpc-c++"


Test patch: