Skip to content

Commit 41b610c

Browse files
committed
Apply ProtoBuf Atomic patch
1 parent 409190f commit 41b610c

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

dependencies/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,15 @@ if(ENABLE_PROTOBUF_SERVER)
465465
set(protobuf_BUILD_PROTOC_BINARIES OFF CACHE BOOL "Build protobuf libraries and protoc compiler")
466466
endif()
467467

468+
include(FetchContent)
469+
468470
# Add Protobuf directory to the build
469-
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/external/protobuf")
471+
FetchContent_Declare(
472+
protobuf
473+
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external/protobuf"
474+
PATCH_COMMAND git apply "${CMAKE_CURRENT_SOURCE_DIR}/protobuf/atomic.diff"
475+
)
476+
FetchContent_MakeAvailable(protobuf)
470477

471478
if(CMAKE_CROSSCOMPILING)
472479
if(IMPORT_PROTOC)
@@ -479,6 +486,7 @@ if(ENABLE_PROTOBUF_SERVER)
479486
PREFIX ${CMAKE_BINARY_DIR}/dependencies/external/protoc-host
480487
BUILD_ALWAYS OFF
481488
DOWNLOAD_COMMAND ""
489+
PATCH_COMMAND git apply "${CMAKE_CURRENT_SOURCE_DIR}/protobuf/atomic.diff"
482490
INSTALL_COMMAND ""
483491
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/protobuf
484492
CMAKE_ARGS -Dprotobuf_BUILD_LIBPROTOC:BOOL=OFF

dependencies/protobuf/atomic.diff

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/cmake/protobuf-configure-target.cmake b/cmake/protobuf-configure-target.cmake
2+
index c67c57056..171e0a8f0 100644
3+
--- a/cmake/protobuf-configure-target.cmake
4+
+++ b/cmake/protobuf-configure-target.cmake
5+
@@ -7,8 +7,8 @@
6+
7+
# Refactors configuration options set on all Protobuf targets
8+
function(protobuf_configure_target target)
9+
- if(protobuf_LINK_LIBATOMIC)
10+
- target_link_libraries(libprotobuf PRIVATE atomic)
11+
+ if(protobuf_LINK_LIBATOMIC AND "${target}" STREQUAL "libprotobuf")
12+
+ target_link_libraries("${target}" PRIVATE atomic)
13+
endif()
14+
15+
target_compile_features("${target}" PUBLIC cxx_std_17)

0 commit comments

Comments
 (0)