Skip to content

Commit 361035b

Browse files
authored
Update protobuf to v25.1 (#183)
# Changes Since we are upgrading the protobuf version, the location for the root CMakeLists.txt has changed, hence the update. We also updated the swift targets (ex: `swift_add_library` or `swift_add_executable`) so that we can now set a global default C++ version with `SWIFT_CXX_STANDARD`. Lastly tried to unify the interface between `swift_add_test` and the rest of the other swift targets since `swift_add_test` was developed separately to the rest, hence the difference in interface. These changes will allow us to set the C++ for our Swift targets independently from the third party libraries.
1 parent 5bf22f7 commit 361035b

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

FindGrpc.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
include("GenericFindDependency")
22

3-
option(ABSL_PROPAGATE_CXX_STD "Use CMake C++ standard meta features (e.g. cxx_std_11) that propagate to targets that link to Abseil" true)
3+
option(ABSL_PROPAGATE_CXX_STD "Use CMake C++ standard meta features (e.g. cxx_std_14) that propagate to targets that link to Abseil" true)
44
option(protobuf_INSTALL "Install protobuf binaries and files" OFF)
55
option(utf8_range_ENABLE_INSTALL "Configure installation" OFF)
66

FindProtobuf.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
1111
#
1212

13+
option(ABSL_PROPAGATE_CXX_STD "Use CMake C++ standard meta features (e.g. cxx_std_14) that propagate to targets that link to Abseil" true)
1314
option(protobuf_INSTALL "Install protobuf binaries and files" OFF)
1415
option(utf8_range_ENABLE_INSTALL "Configure installation" OFF)
1516

1617
include("GenericFindDependency")
1718
option(protocol_BUILD_TESTS "" OFF)
1819
GenericFindDependency(
1920
TARGET "libprotobuf"
20-
SOURCE_DIR "protobuf/cmake"
21+
SOURCE_DIR "protobuf"
2122
SYSTEM_INCLUDES
2223
)

SwiftTargets.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,11 @@ function(swift_add_target target type)
250250
if (x_C_STANDARD)
251251
list(APPEND language_standards_args C ${x_C_STANDARD})
252252
endif()
253+
253254
if (x_CXX_STANDARD)
254255
list(APPEND language_standards_args CXX ${x_CXX_STANDARD})
256+
elseif (SWIFT_CXX_STANDARD)
257+
list(APPEND language_standards_args CXX ${SWIFT_CXX_STANDARD})
255258
endif()
256259

257260
if (x_INTERFACE AND x_OBJECT)

TestTargets.cmake

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ endfunction()
261261

262262
function(swift_add_test target)
263263
set(argOption "INTEGRATION_TEST" "PARALLEL" "POST_BUILD" "UNIT_TEST" "VALGRIND_MEMCHECK")
264-
set(argSingle "COMMENT" "WORKING_DIRECTORY")
264+
set(argSingle "C_STANDARD" "CXX_STANDARD" "COMMENT" "WORKING_DIRECTORY")
265265
set(argMulti "SRCS" "LINK" "INCLUDE")
266266

267267
cmake_parse_arguments(x "${argOption}" "${argSingle}" "${argMulti}" ${ARGN})
@@ -290,9 +290,19 @@ function(swift_add_test target)
290290
message(FATAL_ERROR "VALGRIND_MEMCHECK can only be specified with UNIT_TEST")
291291
endif()
292292

293+
set(language_standards_args)
294+
if (x_C_STANDARD)
295+
list(APPEND language_standards_args C ${x_C_STANDARD})
296+
endif()
297+
if (x_CXX_STANDARD)
298+
list(APPEND language_standards_args CXX ${x_CXX_STANDARD})
299+
elseif (SWIFT_CXX_STANDARD)
300+
list(APPEND language_standards_args CXX ${SWIFT_CXX_STANDARD})
301+
endif()
302+
293303
add_executable(${target} EXCLUDE_FROM_ALL ${x_SRCS})
294304
set_target_properties(${target} PROPERTIES SWIFT_TYPE "test")
295-
swift_set_language_standards(${target} C_EXTENSIONS_ON)
305+
swift_set_language_standards(${target} ${language_standards_args} C_EXTENSIONS_ON)
296306
target_code_coverage(${target} AUTO ALL)
297307
if(x_INCLUDE)
298308
target_include_directories(${target} PRIVATE ${x_INCLUDE})

0 commit comments

Comments
 (0)