Skip to content

Commit fa1f951

Browse files
authored
impl(generator): update emitted build files for c++17 (#16209)
1 parent f744904 commit fa1f951

487 files changed

Lines changed: 1208 additions & 850 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

generator/internal/scaffold_generator.cc

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,9 @@ void GenerateQuickstartCMake(
10221022
cmake_minimum_required(VERSION 3.22...3.31)
10231023
project(google-cloud-cpp-$library$-quickstart CXX)
10241024
1025+
set(CMAKE_CXX_STANDARD 17)
1026+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1027+
10251028
find_package(google_cloud_cpp_$library$ REQUIRED)
10261029
10271030
# MSVC requires some additional code to select the correct runtime library
@@ -1062,7 +1065,7 @@ void GenerateQuickstartMakefile(
10621065
# The CXX, CXXFLAGS and CXXLD variables are hard-coded. These values work for
10631066
# our tests, but applications would typically make them configurable parameters.
10641067
CXX=g++
1065-
CXXFLAGS=
1068+
CXXFLAGS=-std=c++17
10661069
CXXLD=$$(CXX)
10671070
BIN=.
10681071
@@ -1147,14 +1150,13 @@ void GenerateQuickstartBazelrc(
11471150
# Use host-OS-specific config lines from bazelrc files.
11481151
build --enable_platform_specific_config=true
11491152
1150-
# The project requires C++ >= 14. By default Bazel adds `-std=c++0x` which
1151-
# disables C++14 features, even if the compilers defaults to C++ >= 14
1152-
build:linux --cxxopt=-std=c++14
1153-
build:macos --cxxopt=-std=c++14
1154-
# Protobuf and gRPC require (or soon will require) C++14 to compile the "host"
1153+
# The project requires C++ >= 17.
1154+
build:linux --cxxopt=-std=c++17
1155+
build:macos --cxxopt=-std=c++17
1156+
# Protobuf and gRPC require (or soon will require) C++17 to compile the "host"
11551157
# targets, such as protoc and the grpc plugin.
1156-
build:linux --host_cxxopt=-std=c++14
1157-
build:macos --host_cxxopt=-std=c++14
1158+
build:linux --host_cxxopt=-std=c++17
1159+
build:macos --host_cxxopt=-std=c++17
11581160
11591161
# Do not create the convenience links. They are inconvenient when the build
11601162
# runs inside a docker image or if one builds a quickstart and then builds

generator/internal/scaffold_generator_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ TEST_F(ScaffoldGenerator, QuickstartCMake) {
411411
EXPECT_THAT(actual, HasSubstr("2034"));
412412
EXPECT_THAT(actual, Not(HasSubstr("$copyright_year$")));
413413
EXPECT_THAT(actual, Not(HasSubstr("$library_prefix$")));
414+
EXPECT_THAT(actual, HasSubstr("CMAKE_CXX_STANDARD 17"));
414415
}
415416

416417
TEST_F(ScaffoldGenerator, QuickstartMakefile) {
@@ -421,6 +422,7 @@ TEST_F(ScaffoldGenerator, QuickstartMakefile) {
421422
EXPECT_THAT(actual, HasSubstr("2034"));
422423
EXPECT_THAT(actual, Not(HasSubstr("$copyright_year$")));
423424
EXPECT_THAT(actual, HasSubstr("\t$(CXXLD) "));
425+
EXPECT_THAT(actual, HasSubstr("CXXFLAGS=-std=c++17"));
424426
}
425427

426428
TEST_F(ScaffoldGenerator, QuickstartWorkspace) {
@@ -461,6 +463,8 @@ TEST_F(ScaffoldGenerator, QuickstartBazelrc) {
461463
auto const actual = std::move(os).str();
462464
EXPECT_THAT(actual, HasSubstr("2034"));
463465
EXPECT_THAT(actual, Not(HasSubstr("$copyright_year$")));
466+
EXPECT_THAT(actual, HasSubstr("c++17"));
467+
EXPECT_THAT(actual, Not(HasSubstr("c++14")));
464468
}
465469

466470
} // namespace

google/cloud/accessapproval/quickstart/.bazelrc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
# Use host-OS-specific config lines from bazelrc files.
1616
build --enable_platform_specific_config=true
1717

18-
19-
18+
# The project requires C++ >= 17.
2019
build:linux --cxxopt=-std=c++17
2120
build:macos --cxxopt=-std=c++17
22-
23-
21+
# Protobuf and gRPC require (or soon will require) C++17 to compile the "host"
22+
# targets, such as protoc and the grpc plugin.
2423
build:linux --host_cxxopt=-std=c++17
2524
build:macos --host_cxxopt=-std=c++17
2625

google/cloud/accessapproval/quickstart/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
cmake_minimum_required(VERSION 3.22...3.31)
1919
project(google-cloud-cpp-accessapproval-quickstart CXX)
2020

21+
set(CMAKE_CXX_STANDARD 17)
22+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
23+
2124
find_package(google_cloud_cpp_accessapproval REQUIRED)
2225

2326
# MSVC requires some additional code to select the correct runtime library

google/cloud/accessapproval/quickstart/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# The CXX, CXXFLAGS and CXXLD variables are hard-coded. These values work for
1919
# our tests, but applications would typically make them configurable parameters.
2020
CXX=g++
21-
CXXFLAGS=
21+
CXXFLAGS=-std=c++17
2222
CXXLD=$(CXX)
2323
BIN=.
2424

google/cloud/accesscontextmanager/quickstart/.bazelrc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
# Use host-OS-specific config lines from bazelrc files.
1616
build --enable_platform_specific_config=true
1717

18-
19-
18+
# The project requires C++ >= 17.
2019
build:linux --cxxopt=-std=c++17
2120
build:macos --cxxopt=-std=c++17
22-
23-
21+
# Protobuf and gRPC require (or soon will require) C++17 to compile the "host"
22+
# targets, such as protoc and the grpc plugin.
2423
build:linux --host_cxxopt=-std=c++17
2524
build:macos --host_cxxopt=-std=c++17
2625

google/cloud/accesscontextmanager/quickstart/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
cmake_minimum_required(VERSION 3.22...3.31)
1919
project(google-cloud-cpp-accesscontextmanager-quickstart CXX)
2020

21+
set(CMAKE_CXX_STANDARD 17)
22+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
23+
2124
find_package(google_cloud_cpp_accesscontextmanager REQUIRED)
2225

2326
# MSVC requires some additional code to select the correct runtime library

google/cloud/accesscontextmanager/quickstart/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# The CXX, CXXFLAGS and CXXLD variables are hard-coded. These values work for
1919
# our tests, but applications would typically make them configurable parameters.
2020
CXX=g++
21-
CXXFLAGS=
21+
CXXFLAGS=-std=c++17
2222
CXXLD=$(CXX)
2323
BIN=.
2424

google/cloud/advisorynotifications/quickstart/.bazelrc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@
1515
# Use host-OS-specific config lines from bazelrc files.
1616
build --enable_platform_specific_config=true
1717

18-
19-
18+
# The project requires C++ >= 17.
2019
build:linux --cxxopt=-std=c++17
2120
build:macos --cxxopt=-std=c++17
22-
23-
21+
# Protobuf and gRPC require (or soon will require) C++17 to compile the "host"
22+
# targets, such as protoc and the grpc plugin.
2423
build:linux --host_cxxopt=-std=c++17
2524
build:macos --host_cxxopt=-std=c++17
2625

google/cloud/advisorynotifications/quickstart/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
cmake_minimum_required(VERSION 3.22...3.31)
1919
project(google-cloud-cpp-advisorynotifications-quickstart CXX)
2020

21+
set(CMAKE_CXX_STANDARD 17)
22+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
23+
2124
find_package(google_cloud_cpp_advisorynotifications REQUIRED)
2225

2326
# MSVC requires some additional code to select the correct runtime library

0 commit comments

Comments
 (0)