CMake's better handling c++14 requirement (#31916)

* Bumped the cmake version version to 3.8

* Switch to target_compile_features for cxx_std_14

* Regen
pull/32194/merge
Esun Kim 2 years ago committed by GitHub
parent 9f1b5dab69
commit b64d623f24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 894
      CMakeLists.txt
  2. 7
      examples/android/helloworld/app/CMakeLists.txt
  3. 6
      examples/cpp/cmake/common.cmake
  4. 2
      examples/cpp/compression/CMakeLists.txt
  5. 2
      examples/cpp/helloworld/CMakeLists.txt
  6. 2
      examples/cpp/helloworld/cmake_externalproject/CMakeLists.txt
  7. 2
      examples/cpp/keyvaluestore/CMakeLists.txt
  8. 2
      examples/cpp/load_balancing/CMakeLists.txt
  9. 2
      examples/cpp/metadata/CMakeLists.txt
  10. 2
      examples/cpp/route_guide/CMakeLists.txt
  11. 7
      src/android/test/interop/app/CMakeLists.txt
  12. 26
      templates/CMakeLists.txt.template
  13. 2
      tools/run_tests/run_tests.py

894
CMakeLists.txt generated

File diff suppressed because it is too large Load Diff

@ -1,9 +1,4 @@
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
# https://github.com/abseil/abseil-cpp/issues/626
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DABSL_NO_XRAY_ATTRIBUTES=1")
cmake_minimum_required(VERSION 3.8)
set(helloworld_PROTOBUF_PROTOC_EXECUTABLE "/usr/local/bin/protoc" CACHE STRING "Protoc binary on host")
set(helloworld_GRPC_CPP_PLUGIN_EXECUTABLE "/usr/local/bin/grpc_cpp_plugin" CACHE STRING "gRPC CPP plugin binary on host")

@ -17,11 +17,7 @@
# See cmake_externalproject/CMakeLists.txt for all-in-one cmake build
# that automatically builds all the dependencies before building route_guide.
cmake_minimum_required(VERSION 3.5.1)
if (NOT DEFINED CMAKE_CXX_STANDARD)
set (CMAKE_CXX_STANDARD 14)
endif()
cmake_minimum_required(VERSION 3.8)
if(MSVC)
add_definitions(-D_WIN32_WINNT=0x600)

@ -17,7 +17,7 @@
# See cmake_externalproject/CMakeLists.txt for all-in-one cmake build
# that automatically builds all the dependencies before building helloworld.
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.8)
project(Compression C CXX)

@ -17,7 +17,7 @@
# See cmake_externalproject/CMakeLists.txt for all-in-one cmake build
# that automatically builds all the dependencies before building helloworld.
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.8)
project(HelloWorld C CXX)

@ -20,7 +20,7 @@
# including the "helloworld" project itself.
# See https://blog.kitware.com/cmake-superbuilds-git-submodules/
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.8)
# Project
project(HelloWorld-SuperBuild C CXX)

@ -17,7 +17,7 @@
# See cmake_externalproject/CMakeLists.txt for all-in-one cmake build
# that automatically builds all the dependencies before building keyvaluestore.
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.8)
project(KeyValueStore C CXX)

@ -17,7 +17,7 @@
# See cmake_externalproject/CMakeLists.txt for all-in-one cmake build
# that automatically builds all the dependencies before building helloworld.
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.8)
project(LoadBalancing C CXX)

@ -17,7 +17,7 @@
# See cmake_externalproject/CMakeLists.txt for all-in-one cmake build
# that automatically builds all the dependencies before building helloworld.
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.8)
project(Metadata C CXX)

@ -17,7 +17,7 @@
# See cmake_externalproject/CMakeLists.txt for all-in-one cmake build
# that automatically builds all the dependencies before building route_guide.
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.8)
project(RouteGuide C CXX)

@ -1,9 +1,4 @@
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
# https://github.com/abseil/abseil-cpp/issues/626
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DABSL_NO_XRAY_ATTRIBUTES=1")
cmake_minimum_required(VERSION 3.8)
set(PROTOBUF_PROTOC_EXECUTABLE "/usr/local/bin/protoc" CACHE STRING "Protoc binary on host")
set(gRPC_CPP_PLUGIN_EXECUTABLE "/usr/local/bin/grpc_cpp_plugin" CACHE STRING "gRPC CPP plugin binary on host")

@ -154,7 +154,7 @@
protobuf_gen_files.add(src)
%>
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.8)
set(PACKAGE_NAME "grpc")
set(PACKAGE_VERSION "${settings.cpp_version}")
@ -264,26 +264,6 @@
set(_gRPC_PLATFORM_WINDOWS ON)
endif()
# Use C11 standard
if (NOT DEFINED CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 11)
endif()
# Add c++14 flags
if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
else()
if (CMAKE_CXX_STANDARD LESS 14)
message(FATAL_ERROR "CMAKE_CXX_STANDARD is less than 14, please specify at least SET(CMAKE_CXX_STANDARD 14)")
endif()
endif()
if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
if (NOT DEFINED CMAKE_CXX_EXTENSIONS)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
## Some libraries are shared even with BUILD_SHARED_LIBRARIES=OFF
if (NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
@ -660,6 +640,8 @@
% endfor
)
target_compile_features(${lib.name} PUBLIC cxx_std_14)
set_target_properties(${lib.name} PROPERTIES
% if lib.language == 'c++':
VERSION <%text>${gRPC_CPP_VERSION}</%text>
@ -764,7 +746,7 @@
third_party/googletest/googlemock/src/gmock-all.cc
% endif
)
target_compile_features(${tgt.name} PUBLIC cxx_std_14)
target_include_directories(${tgt.name}
PRIVATE
<%text>${CMAKE_CURRENT_SOURCE_DIR}</%text>

@ -477,7 +477,7 @@ class CLanguage(object):
_check_compiler(compiler, ['default', 'cmake'])
if compiler == 'default' or compiler == 'cmake':
return ('debian11', [])
return ('debian11', ["-DCMAKE_CXX_STANDARD=14"])
elif compiler == 'gcc7':
return ('gcc_7', [])
elif compiler == 'gcc10.2':

Loading…
Cancel
Save