From 42a809c236019c72256827cb579574683c36994f Mon Sep 17 00:00:00 2001 From: Adam Cozzette Date: Thu, 26 May 2022 17:21:51 +0000 Subject: [PATCH] Revert "Update CMake configuration to add a dependency on Abseil (#9793)" This reverts commit e9246cd789d250727cbc03884795d92ed1f09a88. --- .bazelignore | 1 - .gitmodules | 4 - CMakeLists.txt | 13 --- Makefile.am | 1 - cmake/abseil-cpp.cmake | 28 ----- cmake/libprotobuf-lite.cmake | 3 - cmake/libprotobuf.cmake | 3 - cmake/libprotoc.cmake | 3 - cmake/protobuf-config.cmake.in | 1 - cmake/protobuf/protobuf-targets.cmake | 103 ++++++++++++++++++ cmake/protoc.cmake | 1 - cmake/tests.cmake | 17 +-- .../release/python/linux/build_artifacts.sh | 2 +- .../release/python/macos/build_artifacts.sh | 2 +- .../python/windows/build_artifacts.bat | 7 +- .../python/windows/build_single_artifact.bat | 2 +- third_party/abseil-cpp | 1 - 17 files changed, 109 insertions(+), 83 deletions(-) delete mode 100644 cmake/abseil-cpp.cmake create mode 100644 cmake/protobuf/protobuf-targets.cmake delete mode 160000 third_party/abseil-cpp diff --git a/.bazelignore b/.bazelignore index b92bad0bf4f1d..5c3a81cce932d 100644 --- a/.bazelignore +++ b/.bazelignore @@ -1,5 +1,4 @@ # These are fetched as external repositories. -third_party/abseil-cpp third_party/benchmark third_party/googletest _build/ diff --git a/.gitmodules b/.gitmodules index a287f070e84d0..bcd125a49582a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,7 +5,3 @@ path = third_party/googletest url = https://github.com/google/googletest.git ignore = dirty -[submodule "third_party/abseil-cpp"] - path = third_party/abseil-cpp - url = https://github.com/abseil/abseil-cpp.git - branch = lts_2021_11_02 diff --git a/CMakeLists.txt b/CMakeLists.txt index dd8977843a73e..04cb3303ac6a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,15 +162,6 @@ file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map) find_package(Threads REQUIRED) -# We can install dependencies from submodules if we're running -# CMake v3.13 or newer. -if(CMAKE_VERSION VERSION_LESS 3.13) - set(_protobuf_INSTALL_SUPPORTED_FROM_MODULE OFF) -else() - set(_protobuf_INSTALL_SUPPORTED_FROM_MODULE ON) -endif() - - set(_protobuf_FIND_ZLIB) if (protobuf_WITH_ZLIB) find_package(ZLIB) @@ -313,10 +304,6 @@ if (protobuf_UNICODE) add_definitions(-DUNICODE -D_UNICODE) endif (protobuf_UNICODE) -set(protobuf_ABSL_PROVIDER "module" CACHE STRING "Provider of absl library") -set_property(CACHE protobuf_ABSL_PROVIDER PROPERTY STRINGS "module" "package") - -include(${protobuf_SOURCE_DIR}/cmake/abseil-cpp.cmake) include(${protobuf_SOURCE_DIR}/cmake/libprotobuf-lite.cmake) include(${protobuf_SOURCE_DIR}/cmake/libprotobuf.cmake) if (protobuf_BUILD_LIBPROTOC) diff --git a/Makefile.am b/Makefile.am index 22c85a4059bd9..cb52f3791118a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1212,7 +1212,6 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \ build_files_updated_unittest.sh \ cmake/CMakeLists.txt \ cmake/README.md \ - cmake/abseil-cpp.cmake \ cmake/conformance.cmake \ cmake/examples.cmake \ cmake/extract_includes.bat.in \ diff --git a/cmake/abseil-cpp.cmake b/cmake/abseil-cpp.cmake deleted file mode 100644 index 10e7e5c00b604..0000000000000 --- a/cmake/abseil-cpp.cmake +++ /dev/null @@ -1,28 +0,0 @@ -if(protobuf_ABSL_PROVIDER STREQUAL "module") - if(NOT ABSL_ROOT_DIR) - set(ABSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/abseil-cpp) - endif() - if(EXISTS "${ABSL_ROOT_DIR}/CMakeLists.txt") - if(protobuf_INSTALL) - # When protobuf_INSTALL is enabled and Abseil will be built as a module, - # Abseil will be installed along with protobuf for convenience. - set(ABSL_ENABLE_INSTALL ON) - endif() - add_subdirectory(${ABSL_ROOT_DIR} third_party/abseil-cpp) - else() - message(WARNING "protobuf_ABSL_PROVIDER is \"module\" but ABSL_ROOT_DIR is wrong") - endif() - if(protobuf_INSTALL AND NOT _protobuf_INSTALL_SUPPORTED_FROM_MODULE) - message(WARNING "protobuf_INSTALL will be forced to FALSE because protobuf_ABSL_PROVIDER is \"module\" and CMake version (${CMAKE_VERSION}) is less than 3.13.") - set(protobuf_INSTALL FALSE) - endif() -elseif(protobuf_ABSL_PROVIDER STREQUAL "package") - # Use "CONFIG" as there is no built-in cmake module for absl. - find_package(absl REQUIRED CONFIG) -endif() -set(_protobuf_FIND_ABSL "if(NOT TARGET absl::strings)\n find_package(absl CONFIG)\nendif()") - -set(protobuf_ABSL_USED_TARGETS - absl::strings - absl::strings_internal -) diff --git a/cmake/libprotobuf-lite.cmake b/cmake/libprotobuf-lite.cmake index 1e4444e20c391..83e970312c40a 100644 --- a/cmake/libprotobuf-lite.cmake +++ b/cmake/libprotobuf-lite.cmake @@ -98,9 +98,6 @@ if(protobuf_HAVE_LD_VERSION_SCRIPT) LINK_DEPENDS ${protobuf_SOURCE_DIR}/src/libprotobuf-lite.map) endif() target_link_libraries(libprotobuf-lite PRIVATE ${CMAKE_THREAD_LIBS_INIT}) -target_include_directories(libprotobuf-lite - PRIVATE ${ABSL_ROOT_DIR} -) if(protobuf_LINK_LIBATOMIC) target_link_libraries(libprotobuf-lite PRIVATE atomic) endif() diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake index e597959d20371..07e4bcf57fac1 100644 --- a/cmake/libprotobuf.cmake +++ b/cmake/libprotobuf.cmake @@ -111,9 +111,6 @@ if(protobuf_HAVE_LD_VERSION_SCRIPT) LINK_DEPENDS ${protobuf_SOURCE_DIR}/src/libprotobuf.map) endif() target_link_libraries(libprotobuf PRIVATE ${CMAKE_THREAD_LIBS_INIT}) -target_include_directories(libprotobuf - PRIVATE ${ABSL_ROOT_DIR} -) if(protobuf_WITH_ZLIB) target_link_libraries(libprotobuf PRIVATE ${ZLIB_LIBRARIES}) endif() diff --git a/cmake/libprotoc.cmake b/cmake/libprotoc.cmake index 7506b0220fae7..15a47e53fa188 100644 --- a/cmake/libprotoc.cmake +++ b/cmake/libprotoc.cmake @@ -122,9 +122,6 @@ if(protobuf_HAVE_LD_VERSION_SCRIPT) LINK_DEPENDS ${protobuf_SOURCE_DIR}/src/libprotoc.map) endif() target_link_libraries(libprotoc PRIVATE libprotobuf) -target_include_directories(libprotoc - PRIVATE ${ABSL_ROOT_DIR} -) if(protobuf_BUILD_SHARED_LIBS) target_compile_definitions(libprotoc PUBLIC PROTOBUF_USE_DLLS diff --git a/cmake/protobuf-config.cmake.in b/cmake/protobuf-config.cmake.in index 597f588603ace..61669118cd57d 100644 --- a/cmake/protobuf-config.cmake.in +++ b/cmake/protobuf-config.cmake.in @@ -3,7 +3,6 @@ include("${CMAKE_CURRENT_LIST_DIR}/protobuf-options.cmake") # Depend packages @_protobuf_FIND_ZLIB@ -@_protobuf_FIND_ABSL@ # Imported targets include("${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake") diff --git a/cmake/protobuf/protobuf-targets.cmake b/cmake/protobuf/protobuf-targets.cmake new file mode 100644 index 0000000000000..02915e2713870 --- /dev/null +++ b/cmake/protobuf/protobuf-targets.cmake @@ -0,0 +1,103 @@ +# Generated by CMake + +if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.6) + message(FATAL_ERROR "CMake >= 2.6.0 required") +endif() +cmake_policy(PUSH) +cmake_policy(VERSION 2.6...3.21) +#---------------------------------------------------------------- +# Generated CMake target import file. +#---------------------------------------------------------------- + +# Commands may need to know the format version. +set(CMAKE_IMPORT_FILE_VERSION 1) + +# Protect against multiple inclusion, which would fail when already imported targets are added once more. +set(_targetsDefined) +set(_targetsNotDefined) +set(_expectedTargets) +foreach(_expectedTarget protobuf::libprotobuf-lite protobuf::libprotobuf protobuf::libprotoc protobuf::protoc) + list(APPEND _expectedTargets ${_expectedTarget}) + if(NOT TARGET ${_expectedTarget}) + list(APPEND _targetsNotDefined ${_expectedTarget}) + endif() + if(TARGET ${_expectedTarget}) + list(APPEND _targetsDefined ${_expectedTarget}) + endif() +endforeach() +if("${_targetsDefined}" STREQUAL "${_expectedTargets}") + unset(_targetsDefined) + unset(_targetsNotDefined) + unset(_expectedTargets) + set(CMAKE_IMPORT_FILE_VERSION) + cmake_policy(POP) + return() +endif() +if(NOT "${_targetsDefined}" STREQUAL "") + message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") +endif() +unset(_targetsDefined) +unset(_targetsNotDefined) +unset(_expectedTargets) + + +# Create imported target protobuf::libprotobuf-lite +add_library(protobuf::libprotobuf-lite STATIC IMPORTED) + +set_target_properties(protobuf::libprotobuf-lite PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "/usr/local/google/home/acozzette/src/protobuf/src" + INTERFACE_LINK_LIBRARIES "\$" +) + +# Create imported target protobuf::libprotobuf +add_library(protobuf::libprotobuf STATIC IMPORTED) + +set_target_properties(protobuf::libprotobuf PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "/usr/local/google/home/acozzette/src/protobuf/src" + INTERFACE_LINK_LIBRARIES "\$;\$" +) + +# Create imported target protobuf::libprotoc +add_library(protobuf::libprotoc STATIC IMPORTED) + +set_target_properties(protobuf::libprotoc PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "/usr/local/google/home/acozzette/src/protobuf/src" + INTERFACE_LINK_LIBRARIES "\$" +) + +# Create imported target protobuf::protoc +add_executable(protobuf::protoc IMPORTED) + +# Import target "protobuf::libprotobuf-lite" for configuration "" +set_property(TARGET protobuf::libprotobuf-lite APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG) +set_target_properties(protobuf::libprotobuf-lite PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_NOCONFIG "CXX" + IMPORTED_LOCATION_NOCONFIG "/usr/local/google/home/acozzette/src/protobuf/libprotobuf-lite.a" + ) + +# Import target "protobuf::libprotobuf" for configuration "" +set_property(TARGET protobuf::libprotobuf APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG) +set_target_properties(protobuf::libprotobuf PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_NOCONFIG "CXX" + IMPORTED_LOCATION_NOCONFIG "/usr/local/google/home/acozzette/src/protobuf/libprotobuf.a" + ) + +# Import target "protobuf::libprotoc" for configuration "" +set_property(TARGET protobuf::libprotoc APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG) +set_target_properties(protobuf::libprotoc PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES_NOCONFIG "CXX" + IMPORTED_LOCATION_NOCONFIG "/usr/local/google/home/acozzette/src/protobuf/libprotoc.a" + ) + +# Import target "protobuf::protoc" for configuration "" +set_property(TARGET protobuf::protoc APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG) +set_target_properties(protobuf::protoc PROPERTIES + IMPORTED_LOCATION_NOCONFIG "/usr/local/google/home/acozzette/src/protobuf/protoc-3.21.0.0" + ) + +# This file does not depend on other imported targets which have +# been exported from the same project but in a separate export set. + +# Commands beyond this point should not need to know the version. +set(CMAKE_IMPORT_FILE_VERSION) +cmake_policy(POP) diff --git a/cmake/protoc.cmake b/cmake/protoc.cmake index 385a7a3f3989f..472b6421b5f93 100644 --- a/cmake/protoc.cmake +++ b/cmake/protoc.cmake @@ -6,7 +6,6 @@ add_executable(protoc ${protoc_files} ${protobuf_version_rc_file}) target_link_libraries(protoc libprotoc libprotobuf - ${protobuf_ABSL_USED_TARGETS} ) add_executable(protobuf::protoc ALIAS protoc) diff --git a/cmake/tests.cmake b/cmake/tests.cmake index 1f8bbc9d4307f..1905673bd4161 100644 --- a/cmake/tests.cmake +++ b/cmake/tests.cmake @@ -21,7 +21,6 @@ else() set(googlemock_source_dir "${protobuf_SOURCE_DIR}/third_party/googletest/googlemock") set(googletest_source_dir "${protobuf_SOURCE_DIR}/third_party/googletest/googletest") include_directories( - ${ABSL_ROOT_DIR} ${googlemock_source_dir} ${googletest_source_dir} ${googletest_source_dir}/include @@ -255,14 +254,7 @@ if (MSVC) /wd4146 # unary minus operator applied to unsigned type, result still unsigned ) endif() -target_link_libraries(tests - protobuf-lite-test-common - protobuf-test-common - libprotoc - libprotobuf - GTest::gmock_main - ${protobuf_ABSL_USED_TARGETS} -) +target_link_libraries(tests protobuf-lite-test-common protobuf-test-common libprotoc libprotobuf GTest::gmock_main) set(test_plugin_files ${protobuf_SOURCE_DIR}/src/google/protobuf/compiler/mock_code_generator.cc @@ -272,12 +264,7 @@ set(test_plugin_files ) add_executable(test_plugin ${test_plugin_files}) -target_link_libraries(test_plugin - libprotoc - libprotobuf - GTest::gmock - ${protobuf_ABSL_USED_TARGETS} -) +target_link_libraries(test_plugin libprotoc libprotobuf GTest::gmock) set(lite_test_files ${protobuf_SOURCE_DIR}/src/google/protobuf/lite_unittest.cc diff --git a/kokoro/release/python/linux/build_artifacts.sh b/kokoro/release/python/linux/build_artifacts.sh index 3ddec7444f986..9a3fc5841f4e2 100755 --- a/kokoro/release/python/linux/build_artifacts.sh +++ b/kokoro/release/python/linux/build_artifacts.sh @@ -30,7 +30,7 @@ git clone https://github.com/matthew-brett/multibuild.git # silently creeping in (see https://github.com/protocolbuffers/protobuf/issues/9180). # IMPORTANT: always pin multibuild at the same commit for: # - linux/build_artifacts.sh -# - macos/build_artifacts.sh +# - linux/build_artifacts.sh # - windows/build_artifacts.bat (cd multibuild; git checkout b89bb903e94308be79abefa4f436bf123ebb1313) cp kokoro/release/python/linux/config.sh config.sh diff --git a/kokoro/release/python/macos/build_artifacts.sh b/kokoro/release/python/macos/build_artifacts.sh index bd60d75fa3e14..aeb4242a6b9b1 100755 --- a/kokoro/release/python/macos/build_artifacts.sh +++ b/kokoro/release/python/macos/build_artifacts.sh @@ -30,7 +30,7 @@ git clone https://github.com/matthew-brett/multibuild.git # silently creeping in (see https://github.com/protocolbuffers/protobuf/issues/9180). # IMPORTANT: always pin multibuild at the same commit for: # - linux/build_artifacts.sh -# - macos/build_artifacts.sh +# - linux/build_artifacts.sh # - windows/build_artifacts.bat (cd multibuild; git checkout b89bb903e94308be79abefa4f436bf123ebb1313) cp kokoro/release/python/macos/config.sh config.sh diff --git a/kokoro/release/python/windows/build_artifacts.bat b/kokoro/release/python/windows/build_artifacts.bat index 32fbec4e1c3db..121283a438248 100644 --- a/kokoro/release/python/windows/build_artifacts.bat +++ b/kokoro/release/python/windows/build_artifacts.bat @@ -18,7 +18,7 @@ REM Pin multibuild scripts at a known commit to avoid potentially unwanted futur REM silently creeping in (see https://github.com/protocolbuffers/protobuf/issues/9180). REM IMPORTANT: always pin multibuild at the same commit for: REM - linux/build_artifacts.sh -REM - macos/build_artifacts.sh +REM - linux/build_artifacts.sh REM - windows/build_artifacts.bat cd multibuild git checkout b89bb903e94308be79abefa4f436bf123ebb1313 @@ -34,11 +34,6 @@ SET ZLIB_ROOT=%cd%\zlib del /Q zlib.zip del /Q zlib-src.zip -REM Update Submodules -REM This is needed because this build uses CMake <3.13. -git submodule update --init --recursive -SET ABSL_ROOT_DIR=%cd%\third_party\abseil-cpp - REM Create directory for artifacts SET ARTIFACT_DIR=%cd%\artifacts mkdir %ARTIFACT_DIR% diff --git a/kokoro/release/python/windows/build_single_artifact.bat b/kokoro/release/python/windows/build_single_artifact.bat index d2c96c3463d3c..af2d265263a7e 100644 --- a/kokoro/release/python/windows/build_single_artifact.bat +++ b/kokoro/release/python/windows/build_single_artifact.bat @@ -49,7 +49,7 @@ mkdir src\.libs mkdir vcprojects pushd vcprojects -cmake -G "%generator%" -Dprotobuf_BUILD_SHARED_LIBS=%BUILD_DLL% -Dprotobuf_UNICODE=%UNICODE% -Dprotobuf_BUILD_TESTS=OFF -DABSL_ROOT_DIR=%ABSL_ROOT_DIR% ../cmake || goto :error +cmake -G "%generator%" -Dprotobuf_BUILD_SHARED_LIBS=%BUILD_DLL% -Dprotobuf_UNICODE=%UNICODE% -Dprotobuf_BUILD_TESTS=OFF ../cmake || goto :error msbuild protobuf.sln /p:Platform=%vcplatform% /p:Configuration=Release || goto :error dir /s /b popd diff --git a/third_party/abseil-cpp b/third_party/abseil-cpp deleted file mode 160000 index 8c6e53ef3adb1..0000000000000 --- a/third_party/abseil-cpp +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8c6e53ef3adb1227fffa442c50349dab134a54bc