Automatically enable BUILD_LIBUPB when BUILD_LIBPROTOC is enabled (#25459)
This PR force-enables `protobuf_BUILD_LIBUPB` whenever `protobuf_BUILD_LIBPROTOC` is enabled, similar to how `protobuf_BUILD_LIBPROTOC` is automatically enabled when `protobuf_BUILD_PROTOC_BINARIES` is enabled.
___
As of https://github.com/protocolbuffers/protobuf/commit/dce6b0f14bd264d2fc9d92a7f5005d7a87b80b02, building `libprotoc` **requires** building `libupb`.
Currently the CMake options permit you to disable building `libupb`, but if `libprotoc` is to be built you will be met with an unhelpful build-time error:
```
[ 43%] Building CXX object CMakeFiles/libprotoc.dir/upb_generator/common.cc.o
/usr/bin/c++ -DLIBPROTOC_EXPORTS -I/tmp/tmp.ajQg1hUGaR/protobuf/build -I/tmp/tmp.ajQg1hUGaR/protobuf -I/tmp/tmp.ajQg1hUGaR/protobuf/build/src -I/tmp/tmp.ajQg1hUGaR/protobuf/src -I/tmp/tmp.ajQg1hUGaR/protobuf/third_party/utf8_range -fvisibility=hidden -fvisibility-inlines-hidden -MD -MT CMakeFiles/libprotoc.dir/upb_generator/common.cc.o -MF CMakeFiles/libprotoc.dir/upb_generator/common.cc.o.d -o CMakeFiles/libprotoc.dir/upb_generator/common.cc.o -c /tmp/tmp.ajQg1hUGaR/protobuf/upb_generator/common.cc
In file included from /tmp/tmp.ajQg1hUGaR/protobuf/upb/reflection/common.h:15,
from /tmp/tmp.ajQg1hUGaR/protobuf/upb/reflection/def_pool.h:15,
from /tmp/tmp.ajQg1hUGaR/protobuf/upb/reflection/def.h:12,
from /tmp/tmp.ajQg1hUGaR/protobuf/upb/reflection/def.hpp:26,
from /tmp/tmp.ajQg1hUGaR/protobuf/upb_generator/common.h:16,
from /tmp/tmp.ajQg1hUGaR/protobuf/upb_generator/common.cc:8:
/tmp/tmp.ajQg1hUGaR/protobuf/upb/reflection/descriptor_bootstrap.h:14:10: fatal error: google/protobuf/descriptor.upb.h: No such file or directory
14 | #include "google/protobuf/descriptor.upb.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
```
Automatically enabling the option prevents reaching this unhelpful error state. I originally had it throw an error when the options were out-of-sync, but automatically flipping `BUILD_LIBUPB` is more in-line with what other options do when things are out-of-sync.
Closes #20538
Closes #25459
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/25459 from Shadows-of-Fire:patch-1 3e8fe67241b0be70ed12daf7f9b3aca0c35ff091
PiperOrigin-RevId: 917838282 B
Brennan Ravenscroft committed
7c5f667cb92a3ebcf99c5b3fca8e5d4fdebf55a2
Parent: d1e231d
Committed by Copybara-Service <copybara-worker@google.com>
on 5/19/2026, 3:13:53 PM