Browse Source

Align on a single CMake style.

We currently write a mix of "if (FOO)" and "if(FOO)". While the former looks
more like a usual language, CMake believes everything, even "if" and "else", is
just a really really funny function call (a "command").

We should pick something for consistency. Upstream CMake writes "if(FOO)", so
go with that one.

Change-Id: I67e0eb650a52670110b417312a362c9f161c8721
Reviewed-on: https://boringssl-review.googlesource.com/30807
Reviewed-by: Adam Langley <agl@google.com>
kris/onging/CECPQ3_patch15
David Benjamin 6 years ago
committed by Adam Langley
parent
commit
e6fd125d31
11 changed files with 61 additions and 61 deletions
  1. +33
    -33
      CMakeLists.txt
  2. +11
    -11
      crypto/CMakeLists.txt
  3. +4
    -4
      crypto/chacha/CMakeLists.txt
  4. +1
    -1
      crypto/cipher_extra/CMakeLists.txt
  5. +1
    -1
      crypto/curve25519/CMakeLists.txt
  6. +5
    -5
      crypto/fipsmodule/CMakeLists.txt
  7. +1
    -1
      crypto/poly1305/CMakeLists.txt
  8. +1
    -1
      decrepit/CMakeLists.txt
  9. +1
    -1
      fipstools/CMakeLists.txt
  10. +1
    -1
      ssl/CMakeLists.txt
  11. +2
    -2
      tool/CMakeLists.txt

+ 33
- 33
CMakeLists.txt View File

@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 2.8.11)
cmake_minimum_required(VERSION 2.8.11)

# Report AppleClang separately from Clang. Their version numbers are different.
# https://cmake.org/cmake/help/v3.0/policy/CMP0025.html
@@ -7,7 +7,7 @@ if(POLICY CMP0025)
endif()

# Defer enabling C and CXX languages.
project (BoringSSL NONE)
project(BoringSSL NONE)

if(WIN32)
# On Windows, prefer cl over gcc if both are available. By default most of
@@ -34,14 +34,14 @@ else()
find_program(GO_EXECUTABLE go)
endif()

if (NOT GO_EXECUTABLE)
if(NOT GO_EXECUTABLE)
message(FATAL_ERROR "Could not find Go")
endif()

if (USE_CUSTOM_LIBCXX)
if(USE_CUSTOM_LIBCXX)
set(BORINGSSL_ALLOW_CXX_RUNTIME 1)
endif()
if (BORINGSSL_ALLOW_CXX_RUNTIME)
if(BORINGSSL_ALLOW_CXX_RUNTIME)
add_definitions(-DBORINGSSL_ALLOW_CXX_RUNTIME)
endif()

@@ -189,7 +189,7 @@ if((CMAKE_COMPILER_IS_GNUCXX AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.7.9
endif()

if(CMAKE_COMPILER_IS_GNUCXX)
if ((CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.8.99") OR CLANG)
if((CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.8.99") OR CLANG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
@@ -222,19 +222,19 @@ endif()

add_definitions(-DBORINGSSL_IMPLEMENTATION)

if (BUILD_SHARED_LIBS)
if(BUILD_SHARED_LIBS)
add_definitions(-DBORINGSSL_SHARED_LIBRARY)
# Enable position-independent code globally. This is needed because
# some library targets are OBJECT libraries.
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
endif()

if (MSAN)
if(MSAN)
if(NOT CLANG)
message(FATAL_ERROR "Cannot enable MSAN unless using Clang")
endif()

if (ASAN)
if(ASAN)
message(FATAL_ERROR "ASAN and MSAN are mutually exclusive")
endif()

@@ -243,7 +243,7 @@ if (MSAN)
set(OPENSSL_NO_ASM "1")
endif()

if (ASAN)
if(ASAN)
if(NOT CLANG)
message(FATAL_ERROR "Cannot enable ASAN unless using Clang")
endif()
@@ -281,7 +281,7 @@ if(TSAN)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread")
endif()

if (GCOV)
if(GCOV)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
endif()
@@ -307,65 +307,65 @@ endif()
# the source files rather than the build. This does not work for our assembly
# files, so we fix CMAKE_SYSTEM_PROCESSOR and only support single-architecture
# builds.
if (NOT OPENSSL_NO_ASM AND CMAKE_OSX_ARCHITECTURES)
if(NOT OPENSSL_NO_ASM AND CMAKE_OSX_ARCHITECTURES)
list(LENGTH CMAKE_OSX_ARCHITECTURES NUM_ARCHES)
if (NOT ${NUM_ARCHES} EQUAL 1)
if(NOT ${NUM_ARCHES} EQUAL 1)
message(FATAL_ERROR "Universal binaries not supported.")
endif()
list(GET CMAKE_OSX_ARCHITECTURES 0 CMAKE_SYSTEM_PROCESSOR)
endif()

if (OPENSSL_NO_ASM)
if(OPENSSL_NO_ASM)
add_definitions(-DOPENSSL_NO_ASM)
set(ARCH "generic")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(ARCH "x86_64")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
set(ARCH "x86_64")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
# cmake reports AMD64 on Windows, but we might be building for 32-bit.
if (CMAKE_CL_64)
if(CMAKE_CL_64)
set(ARCH "x86_64")
else()
set(ARCH "x86")
endif()
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86")
set(ARCH "x86")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i386")
set(ARCH "x86")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "i686")
set(ARCH "x86")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "aarch64")
set(ARCH "aarch64")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm64")
set(ARCH "aarch64")
elseif (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm*")
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm*")
set(ARCH "arm")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "mips")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "mips")
# Just to avoid the “unknown processor” error.
set(ARCH "generic")
elseif (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "ppc64le")
elseif(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "ppc64le")
set(ARCH "ppc64le")
else()
message(FATAL_ERROR "Unknown processor:" ${CMAKE_SYSTEM_PROCESSOR})
endif()

if (ANDROID AND NOT ANDROID_NDK_REVISION AND ${ARCH} STREQUAL "arm")
if(ANDROID AND NOT ANDROID_NDK_REVISION AND ${ARCH} STREQUAL "arm")
# The third-party Android-NDK CMake files somehow fail to set the -march flag
# for assembly files. Without this flag, the compiler believes that it's
# building for ARMv5.
set(CMAKE_ASM_FLAGS "-march=${CMAKE_SYSTEM_PROCESSOR} ${CMAKE_ASM_FLAGS}")
endif()

if (${ARCH} STREQUAL "x86" AND APPLE AND ${CMAKE_VERSION} VERSION_LESS "3.0")
if(${ARCH} STREQUAL "x86" AND APPLE AND ${CMAKE_VERSION} VERSION_LESS "3.0")
# With CMake 2.8.x, ${CMAKE_SYSTEM_PROCESSOR} evalutes to i386 on OS X,
# but clang defaults to 64-bit builds on OS X unless otherwise told.
# Set ARCH to x86_64 so clang and CMake agree. This is fixed in CMake 3.
set(ARCH "x86_64")
endif()

if (USE_CUSTOM_LIBCXX)
if (NOT CLANG)
if(USE_CUSTOM_LIBCXX)
if(NOT CLANG)
message(FATAL_ERROR "USE_CUSTOM_LIBCXX only supported with Clang")
endif()

@@ -390,7 +390,7 @@ if (USE_CUSTOM_LIBCXX)
list(REMOVE_ITEM LIBCXXABI_SOURCES "trunk/src/cxa_noexception.cpp")
# libc++ also defines new and delete.
list(REMOVE_ITEM LIBCXXABI_SOURCES "trunk/src/stdlib_new_delete.cpp")
if (TSAN)
if(TSAN)
# ThreadSanitizer tries to intercept these symbols. Skip them to avoid
# symbol conflicts.
list(REMOVE_ITEM LIBCXXABI_SOURCES "trunk/src/cxa_guard.cpp")
@@ -404,7 +404,7 @@ if (USE_CUSTOM_LIBCXX)
set_target_properties(libcxxabi PROPERTIES COMPILE_FLAGS "-Wno-missing-prototypes -Wno-implicit-fallthrough")

add_library(libcxx ${LIBCXX_SOURCES})
if (ASAN OR MSAN OR TSAN)
if(ASAN OR MSAN OR TSAN)
# Sanitizers try to intercept new and delete.
target_compile_definitions(
libcxx PRIVATE
@@ -459,7 +459,7 @@ if(FUZZ)
add_subdirectory(fuzz)
endif()

if (NOT ${CMAKE_VERSION} VERSION_LESS "3.2")
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.2")
# USES_TERMINAL is only available in CMake 3.2 or later.
set(MAYBE_USES_TERMINAL USES_TERMINAL)
endif()


+ 11
- 11
crypto/CMakeLists.txt View File

@@ -2,27 +2,27 @@ include_directories(../include)

if(NOT OPENSSL_NO_ASM)
if(UNIX)
if (${ARCH} STREQUAL "aarch64")
if(${ARCH} STREQUAL "aarch64")
# The "armx" Perl scripts look for "64" in the style argument
# in order to decide whether to generate 32- or 64-bit asm.
if (APPLE)
if(APPLE)
set(PERLASM_STYLE ios64)
else()
set(PERLASM_STYLE linux64)
endif()
elseif (${ARCH} STREQUAL "arm")
if (APPLE)
elseif(${ARCH} STREQUAL "arm")
if(APPLE)
set(PERLASM_STYLE ios32)
else()
set(PERLASM_STYLE linux32)
endif()
elseif (${ARCH} STREQUAL "ppc64le")
elseif(${ARCH} STREQUAL "ppc64le")
set(PERLASM_STYLE linux64le)
else()
if (${ARCH} STREQUAL "x86")
if(${ARCH} STREQUAL "x86")
set(PERLASM_FLAGS "-fPIC -DOPENSSL_IA32_SSE2")
endif()
if (APPLE)
if(APPLE)
set(PERLASM_STYLE macosx)
else()
set(PERLASM_STYLE elf)
@@ -38,8 +38,8 @@ if(NOT OPENSSL_NO_ASM)
endif()

# CMake does not add -isysroot and -arch flags to assembly.
if (APPLE)
if (CMAKE_OSX_SYSROOT)
if(APPLE)
if(CMAKE_OSX_SYSROOT)
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -isysroot \"${CMAKE_OSX_SYSROOT}\"")
endif()
foreach(arch ${CMAKE_OSX_ARCHITECTURES})
@@ -47,7 +47,7 @@ if(NOT OPENSSL_NO_ASM)
endforeach()
endif()
else()
if (${ARCH} STREQUAL "x86_64")
if(${ARCH} STREQUAL "x86_64")
set(PERLASM_STYLE nasm)
else()
set(PERLASM_STYLE win32n)
@@ -281,7 +281,7 @@ add_executable(
)

target_link_libraries(crypto_test crypto boringssl_gtest)
if (WIN32)
if(WIN32)
target_link_libraries(crypto_test ws2_32)
endif()
add_dependencies(all_tests crypto_test)

+ 4
- 4
crypto/chacha/CMakeLists.txt View File

@@ -1,6 +1,6 @@
include_directories(../../include)

if (${ARCH} STREQUAL "arm")
if(${ARCH} STREQUAL "arm")
set(
CHACHA_ARCH_SOURCES

@@ -8,7 +8,7 @@ if (${ARCH} STREQUAL "arm")
)
endif()

if (${ARCH} STREQUAL "aarch64")
if(${ARCH} STREQUAL "aarch64")
set(
CHACHA_ARCH_SOURCES

@@ -16,7 +16,7 @@ if (${ARCH} STREQUAL "aarch64")
)
endif()

if (${ARCH} STREQUAL "x86")
if(${ARCH} STREQUAL "x86")
set(
CHACHA_ARCH_SOURCES

@@ -24,7 +24,7 @@ if (${ARCH} STREQUAL "x86")
)
endif()

if (${ARCH} STREQUAL "x86_64")
if(${ARCH} STREQUAL "x86_64")
set(
CHACHA_ARCH_SOURCES



+ 1
- 1
crypto/cipher_extra/CMakeLists.txt View File

@@ -1,6 +1,6 @@
include_directories(../../include)

if (${ARCH} STREQUAL "x86_64")
if(${ARCH} STREQUAL "x86_64")
set(
CIPHER_ARCH_SOURCES



+ 1
- 1
crypto/curve25519/CMakeLists.txt View File

@@ -1,6 +1,6 @@
include_directories(../../include)

if (${ARCH} STREQUAL "arm")
if(${ARCH} STREQUAL "arm")
set(
CURVE25519_ARCH_SOURCES



+ 5
- 5
crypto/fipsmodule/CMakeLists.txt View File

@@ -1,6 +1,6 @@
include_directories(../../include)

if (${ARCH} STREQUAL "x86_64")
if(${ARCH} STREQUAL "x86_64")
set(
BCM_ASM_SOURCES

@@ -22,7 +22,7 @@ if (${ARCH} STREQUAL "x86_64")
)
endif()

if (${ARCH} STREQUAL "x86")
if(${ARCH} STREQUAL "x86")
set(
BCM_ASM_SOURCES

@@ -40,7 +40,7 @@ if (${ARCH} STREQUAL "x86")
)
endif()

if (${ARCH} STREQUAL "arm")
if(${ARCH} STREQUAL "arm")
set(
BCM_ASM_SOURCES

@@ -56,7 +56,7 @@ if (${ARCH} STREQUAL "arm")
)
endif()

if (${ARCH} STREQUAL "aarch64")
if(${ARCH} STREQUAL "aarch64")
set(
BCM_ASM_SOURCES

@@ -69,7 +69,7 @@ if (${ARCH} STREQUAL "aarch64")
)
endif()

if (${ARCH} STREQUAL "ppc64le")
if(${ARCH} STREQUAL "ppc64le")
set(
BCM_ASM_SOURCES



+ 1
- 1
crypto/poly1305/CMakeLists.txt View File

@@ -1,6 +1,6 @@
include_directories(../../include)

if (${ARCH} STREQUAL "arm")
if(${ARCH} STREQUAL "arm")
set(
POLY1305_ARCH_SOURCES



+ 1
- 1
decrepit/CMakeLists.txt View File

@@ -49,7 +49,7 @@ add_executable(
)

target_link_libraries(decrepit_test crypto decrepit boringssl_gtest)
if (WIN32)
if(WIN32)
target_link_libraries(decrepit_test ws2_32)
endif()
add_dependencies(all_tests decrepit_test)

+ 1
- 1
fipstools/CMakeLists.txt View File

@@ -1,6 +1,6 @@
include_directories(../include)

if (FIPS)
if(FIPS)
add_executable(
cavp



+ 1
- 1
ssl/CMakeLists.txt View File

@@ -54,7 +54,7 @@ add_executable(
)

target_link_libraries(ssl_test ssl crypto boringssl_gtest)
if (WIN32)
if(WIN32)
target_link_libraries(ssl_test ws2_32)
endif()
add_dependencies(all_tests ssl_test)

+ 2
- 2
tool/CMakeLists.txt View File

@@ -20,11 +20,11 @@ add_executable(
transport_common.cc
)

if (APPLE OR WIN32 OR ANDROID)
if(APPLE OR WIN32 OR ANDROID)
target_link_libraries(bssl ssl crypto)
else()
find_library(FOUND_LIBRT rt)
if (FOUND_LIBRT)
if(FOUND_LIBRT)
target_link_libraries(bssl ssl crypto -lrt)
else()
target_link_libraries(bssl ssl crypto)


Loading…
Cancel
Save