diff --git a/WORKSPACE b/WORKSPACE index 60ab1a301ce..98436d9624e 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -101,7 +101,7 @@ git_repository( # This statement defines the @com_google_protobuf repo. git_repository( name = "com_google_protobuf", - patches = ["//patches:protobuf-v27.2.patch"], + patches = ["//patches:protobuf-v27.patch"], patch_args = ["-p1"], tag = "v27.2", remote = "https://github.com/protocolbuffers/protobuf.git", diff --git a/cmake/dependencies/CMakeLists.txt b/cmake/dependencies/CMakeLists.txt index 92393c92f92..176a59067e2 100644 --- a/cmake/dependencies/CMakeLists.txt +++ b/cmake/dependencies/CMakeLists.txt @@ -106,11 +106,20 @@ if(BUILD_Protobuf) #set(protobuf_BUILD_LIBUPB ON) FetchContent_Declare( Protobuf + #SOURCE_DIR "${CMAKE_SOURCE_DIR}/pb" + GIT_REPOSITORY "https://github.com/protocolbuffers/protobuf.git" - GIT_TAG "v27.2" + GIT_TAG "v27.2" # NACK + #GIT_TAG "v27.1" # NACK + #GIT_TAG "v27.0" # NACK + PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/protobuf-v27.patch" + + #GIT_TAG "v26.1" # ACK + #PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/protobuf-v26.patch" + GIT_SHALLOW TRUE GIT_SUBMODULES "" - PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/protobuf-v27.2.patch") + ) FetchContent_MakeAvailable(Protobuf) list(POP_BACK CMAKE_MESSAGE_INDENT) message(CHECK_PASS "fetched") diff --git a/patches/protobuf-v26.patch b/patches/protobuf-v26.patch new file mode 100644 index 00000000000..3e0935fcf88 --- /dev/null +++ b/patches/protobuf-v26.patch @@ -0,0 +1,68 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 312eeb928..3e154785b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -41,7 +41,7 @@ else (BUILD_SHARED_LIBS) + endif (BUILD_SHARED_LIBS) + option(protobuf_BUILD_SHARED_LIBS "Build Shared Libraries" ${protobuf_BUILD_SHARED_LIBS_DEFAULT}) + include(CMakeDependentOption) +-cmake_dependent_option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON ++cmake_dependent_option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" OFF + "NOT protobuf_BUILD_SHARED_LIBS" OFF) + set(protobuf_WITH_ZLIB_DEFAULT ON) + option(protobuf_WITH_ZLIB "Build with zlib support" ${protobuf_WITH_ZLIB_DEFAULT}) +@@ -158,24 +158,16 @@ endif() + + set(_protobuf_FIND_ZLIB) + if (protobuf_WITH_ZLIB) +- find_package(ZLIB) +- if (ZLIB_FOUND) +- set(HAVE_ZLIB 1) +- # FindZLIB module define ZLIB_INCLUDE_DIRS variable +- # Set ZLIB_INCLUDE_DIRECTORIES for compatible +- set(ZLIB_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIRECTORIES} ${ZLIB_INCLUDE_DIRS}) +- # Using imported target if exists +- if (TARGET ZLIB::ZLIB) +- set(ZLIB_LIBRARIES ZLIB::ZLIB) +- set(_protobuf_FIND_ZLIB "if(NOT ZLIB_FOUND)\n find_package(ZLIB)\nendif()") +- endif (TARGET ZLIB::ZLIB) +- else (ZLIB_FOUND) +- set(HAVE_ZLIB 0) +- # Explicitly set these to empty (override NOT_FOUND) so cmake doesn't +- # complain when we use them later. +- set(ZLIB_INCLUDE_DIRECTORIES) +- set(ZLIB_LIBRARIES) +- endif (ZLIB_FOUND) ++ if (NOT TARGET ZLIB::ZLIB) ++ find_package(ZLIB REQUIRED) ++ endif() ++ set(HAVE_ZLIB 1) ++ # FindZLIB module define ZLIB_INCLUDE_DIRS variable ++ # Set ZLIB_INCLUDE_DIRECTORIES for compatible ++ set(ZLIB_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIRECTORIES} ${ZLIB_INCLUDE_DIRS}) ++ # Using imported target if exists ++ set(ZLIB_LIBRARIES ZLIB::ZLIB) ++ set(_protobuf_FIND_ZLIB "if(NOT ZLIB_FOUND AND NOT TARGET ZLIB::ZLIB)\n find_package(ZLIB REQUIRED)\nendif()") + endif (protobuf_WITH_ZLIB) + + # We need to link with libatomic on systems that do not have builtin atomics, or +@@ -277,7 +269,6 @@ else (MSVC) + endif (MSVC) + + include_directories( +- ${ZLIB_INCLUDE_DIRECTORIES} + ${protobuf_BINARY_DIR} + # Support #include-ing other top-level directories, i.e. upb_generator. + ${protobuf_SOURCE_DIR} +diff --git a/cmake/install.cmake b/cmake/install.cmake +index 52914a8ea..d7dc5f232 100644 +--- a/cmake/install.cmake ++++ b/cmake/install.cmake +@@ -31,6 +31,7 @@ foreach(_library ${_protobuf_libraries}) + set_property(TARGET ${_library} + PROPERTY INTERFACE_INCLUDE_DIRECTORIES + $ ++ $ + $) + if (UNIX AND NOT APPLE) + set_property(TARGET ${_library} diff --git a/patches/protobuf-v27.2.patch b/patches/protobuf-v27.patch similarity index 88% rename from patches/protobuf-v27.2.patch rename to patches/protobuf-v27.patch index 21de3f4f779..729eef8e596 100644 --- a/patches/protobuf-v27.2.patch +++ b/patches/protobuf-v27.patch @@ -1,5 +1,5 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 9b51e9722..33c1021d4 100644 +index 9b51e972..33c1021d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ else (BUILD_SHARED_LIBS) @@ -54,8 +54,20 @@ index 9b51e9722..33c1021d4 100644 ${protobuf_BINARY_DIR} # Support #include-ing other top-level directories, i.e. upb_generator. ${protobuf_SOURCE_DIR} +diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake +index 11c09b1b..fdea9ce1 100644 +--- a/cmake/libprotobuf.cmake ++++ b/cmake/libprotobuf.cmake +@@ -28,6 +28,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Android") + endif() + target_include_directories(libprotobuf PUBLIC + $ ++ $ + $ + ) + target_link_libraries(libprotobuf PUBLIC ${protobuf_ABSL_USED_TARGETS}) diff --git a/src/google/protobuf/port.h b/src/google/protobuf/port.h -index 4fec7dc13..afb6f846a 100644 +index 4fec7dc1..afb6f846 100644 --- a/src/google/protobuf/port.h +++ b/src/google/protobuf/port.h @@ -49,31 +49,35 @@ inline PROTOBUF_ALWAYS_INLINE void StrongPointer(T* var) {