Skip to content

Commit

Permalink
Fix various CMake style issues
Browse files Browse the repository at this point in the history
Remove some spaces at the end of lines. Change how variables are
referenced inside if() statements. Remove the space between if/endif
and the first parenthesis. Remove the duplicated condition from endif()
blocks. Make indentation more consistent. Remove unneeded duplicate
PRIVATE keywords from target_include_directories(). Remove redundant
set_source_files_properties() call, as the file is already GENERATED.
  • Loading branch information
KyleFromKitware committed Oct 25, 2019
1 parent 4284d30 commit 6f881ab
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 119 deletions.
16 changes: 8 additions & 8 deletions cmake/benchmark.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

if("${gRPC_BENCHMARK_PROVIDER}" STREQUAL "module")
if(gRPC_BENCHMARK_PROVIDER STREQUAL "module")
set(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE BOOL "Turn off gTest in gBenchmark")
if(NOT BENCHMARK_ROOT_DIR)
set(BENCHMARK_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/benchmark)
endif()
if(EXISTS "${BENCHMARK_ROOT_DIR}/CMakeLists.txt")
add_subdirectory(${BENCHMARK_ROOT_DIR} third_party/benchmark)
if(TARGET benchmark)
set(_gRPC_BENCHMARK_LIBRARIES benchmark)
set(_gRPC_BENCHMARK_INCLUDE_DIR "${BENCHMARK_ROOT_DIR}/include")
endif()
add_subdirectory(${BENCHMARK_ROOT_DIR} third_party/benchmark)
if(TARGET benchmark)
set(_gRPC_BENCHMARK_LIBRARIES benchmark)
set(_gRPC_BENCHMARK_INCLUDE_DIR "${BENCHMARK_ROOT_DIR}/include")
endif()
else()
message(WARNING "gRPC_BENCHMARK_PROVIDER is \"module\" but BENCHMARK_ROOT_DIR is wrong")
message(WARNING "gRPC_BENCHMARK_PROVIDER is \"module\" but BENCHMARK_ROOT_DIR is wrong")
endif()
elseif("${gRPC_BENCHMARK_PROVIDER}" STREQUAL "package")
elseif(gRPC_BENCHMARK_PROVIDER STREQUAL "package")
# Use "CONFIG" as there is no built-in cmake module for benchmark.
find_package(benchmark REQUIRED CONFIG)
if(TARGET benchmark::benchmark)
Expand Down
4 changes: 2 additions & 2 deletions cmake/cares.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

if("${gRPC_CARES_PROVIDER}" STREQUAL "module")
if(gRPC_CARES_PROVIDER STREQUAL "module")
if(NOT CARES_ROOT_DIR)
set(CARES_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/cares/cares)
endif()
Expand All @@ -33,7 +33,7 @@ if("${gRPC_CARES_PROVIDER}" STREQUAL "module")
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_CARES_PROVIDER is \"module\"")
set(gRPC_INSTALL FALSE)
endif()
elseif("${gRPC_CARES_PROVIDER}" STREQUAL "package")
elseif(gRPC_CARES_PROVIDER STREQUAL "package")
# Use "CONFIG" as there is no built-in cmake module for c-ares.
find_package(c-ares REQUIRED CONFIG)
if(TARGET c-ares::cares)
Expand Down
4 changes: 2 additions & 2 deletions cmake/gflags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

if("${gRPC_GFLAGS_PROVIDER}" STREQUAL "module")
if(gRPC_GFLAGS_PROVIDER STREQUAL "module")
if(NOT GFLAGS_ROOT_DIR)
set(GFLAGS_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/gflags)
endif()
Expand All @@ -23,7 +23,7 @@ if("${gRPC_GFLAGS_PROVIDER}" STREQUAL "module")
else()
message(WARNING "gRPC_GFLAGS_PROVIDER is \"module\" but GFLAGS_ROOT_DIR is wrong")
endif()
elseif("${gRPC_GFLAGS_PROVIDER}" STREQUAL "package")
elseif(gRPC_GFLAGS_PROVIDER STREQUAL "package")
# Use "CONFIG" as there is no built-in cmake module for gflags.
find_package(gflags REQUIRED CONFIG)
if(TARGET gflags::gflags)
Expand Down
8 changes: 4 additions & 4 deletions cmake/msvc_static_runtime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ if(gRPC_MSVC_STATIC_RUNTIME)
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)

if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MD")
endforeach(flag_var)
if(flag_var MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif()
endforeach()
endif()

6 changes: 3 additions & 3 deletions cmake/protobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module")
if(gRPC_PROTOBUF_PROVIDER STREQUAL "module")
# Building the protobuf tests require gmock what is not part of a standard protobuf checkout.
# Disable them unless they are explicitly requested from the cmake command line (when we assume
# gmock is downloaded to the right location inside protobuf).
Expand Down Expand Up @@ -45,13 +45,13 @@ if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module")
# For well-known .proto files distributed with protobuf
set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR "${PROTOBUF_ROOT_DIR}/src")
else()
message(WARNING "gRPC_PROTOBUF_PROVIDER is \"module\" but PROTOBUF_ROOT_DIR is wrong")
message(WARNING "gRPC_PROTOBUF_PROVIDER is \"module\" but PROTOBUF_ROOT_DIR is wrong")
endif()
if(gRPC_INSTALL)
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_PROTOBUF_PROVIDER is \"module\"")
set(gRPC_INSTALL FALSE)
endif()
elseif("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "package")
elseif(gRPC_PROTOBUF_PROVIDER STREQUAL "package")
find_package(Protobuf REQUIRED ${gRPC_PROTOBUF_PACKAGE_TYPE})

# {Protobuf,PROTOBUF}_FOUND is defined based on find_package type ("MODULE" vs "CONFIG").
Expand Down
6 changes: 3 additions & 3 deletions cmake/ssl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

if("${gRPC_SSL_PROVIDER}" STREQUAL "module")
if(gRPC_SSL_PROVIDER STREQUAL "module")
if(NOT BORINGSSL_ROOT_DIR)
set(BORINGSSL_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/boringssl)
endif()
Expand All @@ -31,13 +31,13 @@ if("${gRPC_SSL_PROVIDER}" STREQUAL "module")
set(_gRPC_SSL_INCLUDE_DIR ${BORINGSSL_ROOT_DIR}/include)
endif()
else()
message(WARNING "gRPC_SSL_PROVIDER is \"module\" but BORINGSSL_ROOT_DIR is wrong")
message(WARNING "gRPC_SSL_PROVIDER is \"module\" but BORINGSSL_ROOT_DIR is wrong")
endif()
if(gRPC_INSTALL)
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_SSL_PROVIDER is \"module\"")
set(gRPC_INSTALL FALSE)
endif()
elseif("${gRPC_SSL_PROVIDER}" STREQUAL "package")
elseif(gRPC_SSL_PROVIDER STREQUAL "package")
# OpenSSL installation directory can be configured by setting OPENSSL_ROOT_DIR
# We expect to locate OpenSSL using the built-in cmake module as the openssl
# project itself does not provide installation support in its CMakeLists.txt
Expand Down
6 changes: 3 additions & 3 deletions cmake/zlib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

if("${gRPC_ZLIB_PROVIDER}" STREQUAL "module")
if(gRPC_ZLIB_PROVIDER STREQUAL "module")
if(NOT ZLIB_ROOT_DIR)
set(ZLIB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib)
endif()
Expand All @@ -26,13 +26,13 @@ if("${gRPC_ZLIB_PROVIDER}" STREQUAL "module")
set(_gRPC_ZLIB_INCLUDE_DIR "${ZLIB_ROOT_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/third_party/zlib")
endif()
else()
message(WARNING "gRPC_ZLIB_PROVIDER is \"module\" but ZLIB_ROOT_DIR is wrong")
message(WARNING "gRPC_ZLIB_PROVIDER is \"module\" but ZLIB_ROOT_DIR is wrong")
endif()
if(gRPC_INSTALL)
message(WARNING "gRPC_INSTALL will be forced to FALSE because gRPC_ZLIB_PROVIDER is \"module\"")
set(gRPC_INSTALL FALSE)
endif()
elseif("${gRPC_ZLIB_PROVIDER}" STREQUAL "package")
elseif(gRPC_ZLIB_PROVIDER STREQUAL "package")
# zlib installation directory can be configured by setting ZLIB_ROOT
# We allow locating zlib using both "CONFIG" and "MODULE" as the expectation
# is that many Linux systems will have zlib installed via a distribution
Expand Down
Loading

0 comments on commit 6f881ab

Please sign in to comment.