Fix target build file for atomic (#24068)

CMake file correction to ensure that builds related to atomic will not fail e.g. on an raspberry PI 1.

Credits to @paulchen-panther who prepared the fix.

Without the correction, builds fail with:

```
-- Protocol Buffers Configuring...
-- protobuf version: 32.1.0
-- Configuration script parsing status [
--   Description : Protocol Buffers
--   Version     : 32.1.0 (6.32.1)
--   Contact     : protobuf@googlegroups.com
-- ]
-- Performing Test protobuf_HAVE_LD_VERSION_SCRIPT
-- Performing Test protobuf_HAVE_LD_VERSION_SCRIPT - Success
-- Performing Test protobuf_HAVE_BUILTIN_ATOMICS
-- Performing Test protobuf_HAVE_BUILTIN_ATOMICS - Failed
-- Could NOT find absl (missing: absl_DIR)
-- Fallback to downloading Abseil 20250512.1 from GitHub
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX17
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX17 - Success
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX20
-- Performing Test ABSL_INTERNAL_AT_LEAST_CXX20 - Failed
CMake Error at hyperion/dependencies/external/protobuf/cmake/protobuf-configure-target.cmake:11 (target_link_libraries):
  Cannot specify link libraries for target "libprotobuf" which is not built
  by this project.
Call Stack (most recent call first):
  hyperion/dependencies/external/protobuf/cmake/libprotobuf-lite.cmake:28 (protobuf_configure_target)
  hyperion/dependencies/external/protobuf/CMakeLists.txt:278 (include)
```

Closes #24068

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/24068 from Lord-Grey:rpi1 4b1e2c8a65
PiperOrigin-RevId: 874095068
This commit is contained in:
LordGrey 2026-02-23 08:50:16 -08:00 committed by Copybara-Service
parent 0ed798a0d2
commit e9efe030ad

View file

@ -7,8 +7,8 @@
# Refactors configuration options set on all Protobuf targets
function(protobuf_configure_target target)
if(protobuf_LINK_LIBATOMIC)
target_link_libraries(libprotobuf PRIVATE atomic)
if(protobuf_LINK_LIBATOMIC AND "${target}" STREQUAL "libprotobuf")
target_link_libraries("${target}" PRIVATE atomic)
endif()
target_compile_features("${target}" PUBLIC cxx_std_17)