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>
diff --git a/CMakeLists.txt b/CMakeLists.txt index 82ead7f..4eb0d0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ # 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 @@ 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 @@ 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 @@ 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()
diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index d0a4d97..5f6e327 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt
@@ -2,27 +2,27 @@ 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 @@ 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 @@ 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 @@ ) 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)
diff --git a/crypto/chacha/CMakeLists.txt b/crypto/chacha/CMakeLists.txt index 63de061..bf4920c 100644 --- a/crypto/chacha/CMakeLists.txt +++ b/crypto/chacha/CMakeLists.txt
@@ -1,6 +1,6 @@ include_directories(../../include) -if (${ARCH} STREQUAL "arm") +if(${ARCH} STREQUAL "arm") set( CHACHA_ARCH_SOURCES @@ -8,7 +8,7 @@ ) endif() -if (${ARCH} STREQUAL "aarch64") +if(${ARCH} STREQUAL "aarch64") set( CHACHA_ARCH_SOURCES @@ -16,7 +16,7 @@ ) endif() -if (${ARCH} STREQUAL "x86") +if(${ARCH} STREQUAL "x86") set( CHACHA_ARCH_SOURCES @@ -24,7 +24,7 @@ ) endif() -if (${ARCH} STREQUAL "x86_64") +if(${ARCH} STREQUAL "x86_64") set( CHACHA_ARCH_SOURCES
diff --git a/crypto/cipher_extra/CMakeLists.txt b/crypto/cipher_extra/CMakeLists.txt index 5e0c06f..2c55bd6 100644 --- a/crypto/cipher_extra/CMakeLists.txt +++ b/crypto/cipher_extra/CMakeLists.txt
@@ -1,6 +1,6 @@ include_directories(../../include) -if (${ARCH} STREQUAL "x86_64") +if(${ARCH} STREQUAL "x86_64") set( CIPHER_ARCH_SOURCES
diff --git a/crypto/curve25519/CMakeLists.txt b/crypto/curve25519/CMakeLists.txt index 4894fa8..0f28218 100644 --- a/crypto/curve25519/CMakeLists.txt +++ b/crypto/curve25519/CMakeLists.txt
@@ -1,6 +1,6 @@ include_directories(../../include) -if (${ARCH} STREQUAL "arm") +if(${ARCH} STREQUAL "arm") set( CURVE25519_ARCH_SOURCES
diff --git a/crypto/fipsmodule/CMakeLists.txt b/crypto/fipsmodule/CMakeLists.txt index 3082375..babda94 100644 --- a/crypto/fipsmodule/CMakeLists.txt +++ b/crypto/fipsmodule/CMakeLists.txt
@@ -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 @@ ) endif() -if (${ARCH} STREQUAL "x86") +if(${ARCH} STREQUAL "x86") set( BCM_ASM_SOURCES @@ -40,7 +40,7 @@ ) endif() -if (${ARCH} STREQUAL "arm") +if(${ARCH} STREQUAL "arm") set( BCM_ASM_SOURCES @@ -56,7 +56,7 @@ ) endif() -if (${ARCH} STREQUAL "aarch64") +if(${ARCH} STREQUAL "aarch64") set( BCM_ASM_SOURCES @@ -69,7 +69,7 @@ ) endif() -if (${ARCH} STREQUAL "ppc64le") +if(${ARCH} STREQUAL "ppc64le") set( BCM_ASM_SOURCES
diff --git a/crypto/poly1305/CMakeLists.txt b/crypto/poly1305/CMakeLists.txt index 5534e62..5dc1b19 100644 --- a/crypto/poly1305/CMakeLists.txt +++ b/crypto/poly1305/CMakeLists.txt
@@ -1,6 +1,6 @@ include_directories(../../include) -if (${ARCH} STREQUAL "arm") +if(${ARCH} STREQUAL "arm") set( POLY1305_ARCH_SOURCES
diff --git a/decrepit/CMakeLists.txt b/decrepit/CMakeLists.txt index 80e6518..bebc624 100644 --- a/decrepit/CMakeLists.txt +++ b/decrepit/CMakeLists.txt
@@ -49,7 +49,7 @@ ) 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)
diff --git a/fipstools/CMakeLists.txt b/fipstools/CMakeLists.txt index 4831575..f0f7b2c 100644 --- a/fipstools/CMakeLists.txt +++ b/fipstools/CMakeLists.txt
@@ -1,6 +1,6 @@ include_directories(../include) -if (FIPS) +if(FIPS) add_executable( cavp
diff --git a/ssl/CMakeLists.txt b/ssl/CMakeLists.txt index f2f60ca..6881089 100644 --- a/ssl/CMakeLists.txt +++ b/ssl/CMakeLists.txt
@@ -54,7 +54,7 @@ ) 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)
diff --git a/tool/CMakeLists.txt b/tool/CMakeLists.txt index 244f7df..87efb09 100644 --- a/tool/CMakeLists.txt +++ b/tool/CMakeLists.txt
@@ -20,11 +20,11 @@ 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)