0
0
mirror of https://github.com/zeromq/libzmq.git synced 2025-01-14 01:37:56 +08:00

Conform to cmakelint --filter=-linelength

- Lowercase all commands
- Unify indent to 2 spaces
- Remove spaces around brackets
- Remove repitition of condition in else(...) and endif(...)

Note: (re-)running CMake did not change the content of the generated files
This commit is contained in:
Christoph Schulz 2018-09-10 00:12:07 +02:00
parent ca7c03f825
commit a21228b664
3 changed files with 1224 additions and 1233 deletions

View File

@ -1,6 +1,6 @@
# CMake build script for ZeroMQ
cmake_minimum_required(VERSION 2.8.12)
project(ZeroMQ)
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}")
@ -25,12 +25,12 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
endif()
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=gnu++11" COMPILER_SUPPORTS_CXX11)
check_cxx_compiler_flag("-std=gnu++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif()
include(CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG("-std=gnu11" COMPILER_SUPPORTS_C11)
check_c_compiler_flag("-std=gnu11" COMPILER_SUPPORTS_C11)
if(COMPILER_SUPPORTS_C11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
endif()
@ -39,11 +39,11 @@ include (ZMQSupportMacros)
if(NOT MSVC)
# clang 6 has a warning that does not make sense on multi-platform code
CHECK_CXX_COMPILER_FLAG("-Wno-tautological-constant-compare" CXX_HAS_TAUT_WARNING)
check_cxx_compiler_flag("-Wno-tautological-constant-compare" CXX_HAS_TAUT_WARNING)
if(CXX_HAS_TAUT_WARNING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-tautological-constant-compare")
endif()
CHECK_C_COMPILER_FLAG("-Wno-tautological-constant-compare" CC_HAS_TAUT_WARNING)
check_c_compiler_flag("-Wno-tautological-constant-compare" CC_HAS_TAUT_WARNING)
if(CC_HAS_TAUT_WARNING)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-tautological-constant-compare")
endif()
@ -68,7 +68,6 @@ option (ENABLE_CURVE "Enable CURVE security" ON)
if(NOT ENABLE_CURVE)
message(STATUS "CURVE security is disabled")
elseif(WITH_LIBSODIUM)
find_package(Sodium)
if(SODIUM_FOUND)
@ -81,7 +80,6 @@ elseif (WITH_LIBSODIUM)
message(FATAL_ERROR
"libsodium is not installed. Install it, then run CMake again")
endif()
else()
message(STATUS "Using tweetnacl for CURVE security")
list(APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/src/tweetnacl.c)
@ -92,16 +90,16 @@ endif ()
set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
if(EXISTS "${SOURCE_DIR}/.git")
OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" ON)
option(ENABLE_DRAFTS "Build and install draft classes and methods" ON)
else()
OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" OFF)
option(ENABLE_DRAFTS "Build and install draft classes and methods" OFF)
endif()
IF (ENABLE_DRAFTS)
ADD_DEFINITIONS (-DZMQ_BUILD_DRAFT_API)
if(ENABLE_DRAFTS)
add_definitions(-DZMQ_BUILD_DRAFT_API)
set(pkg_config_defines "-DZMQ_BUILD_DRAFT_API=1")
ELSE (ENABLE_DRAFTS)
else()
set(pkg_config_defines "")
ENDIF (ENABLE_DRAFTS)
endif()
option(WITH_MILITANT "Enable militant assertions" OFF)
if(WITH_MILITANT)
@ -235,8 +233,8 @@ if (NOT CYGWIN)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND CMAKE_SYSTEM_VERSION STREQUAL "10.0")
SET(ZMQ_HAVE_WINDOWS_UWP ON)
ADD_DEFINITIONS(-D_WIN32_WINNT=_WIN32_WINNT_WIN10)
set(ZMQ_HAVE_WINDOWS_UWP ON)
add_definitions(-D_WIN32_WINNT=_WIN32_WINNT_WIN10)
endif()
if(NOT MSVC)
check_include_files(ifaddrs.h ZMQ_HAVE_IFADDRS)
@ -270,7 +268,6 @@ find_library (RT_LIBRARY rt)
find_package(Threads)
if(WIN32 AND NOT CYGWIN)
if(NOT HAVE_WS2_32 AND NOT HAVE_WS2)
message(FATAL_ERROR "Cannot link to ws2_32 or ws2")
@ -320,7 +317,7 @@ macro (zmq_check_cxx_flag_prepend flag)
endif()
endmacro()
OPTION (ENABLE_ANALYSIS "Build with static analysis (make take very long)" OFF)
option(ENABLE_ANALYSIS "Build with static analysis(make take very long)" OFF)
if(MSVC)
if(ENABLE_ANALYSIS)
@ -400,19 +397,18 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro")
zmq_check_cxx_flag_prepend("-features=zla")
endif()
if(CMAKE_SYSTEM_NAME MATCHES "SunOS" OR CMAKE_SYSTEM_NAME MATCHES "NetBSD")
message(STATUS "Checking whether atomic operations can be used")
check_c_source_compiles(
"
#include <atomic.h>
int main ()
{
uint32_t value;
atomic_cas_32 (&value, 0, 0);
return 0;
}
"\
#include <atomic.h> \
\
int main() \
{ \
uint32_t value; \
atomic_cas_32(&value, 0, 0); \
return 0; \
} \
"
HAVE_ATOMIC_H)
@ -474,18 +470,16 @@ if (MSVC)
find_path(OPENPGM_ROOT include/pgm/pgm.h
PATHS
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Miru\\OpenPGM ${OPENPGM_VERSION_MAJOR}.${OPENPGM_VERSION_MINOR}.${OPENPGM_VERSION_MICRO}]"
NO_DEFAULT_PATH
)
NO_DEFAULT_PATH)
message(STATUS "OpenPGM x64 detected - ${OPENPGM_ROOT}")
else()
find_path(OPENPGM_ROOT include/pgm/pgm.h
PATHS
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Miru\\OpenPGM ${OPENPGM_VERSION_MAJOR}.${OPENPGM_VERSION_MINOR}.${OPENPGM_VERSION_MICRO}]"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Miru\\OpenPGM ${OPENPGM_VERSION_MAJOR}.${OPENPGM_VERSION_MINOR}.${OPENPGM_VERSION_MICRO}]"
NO_DEFAULT_PATH
)
NO_DEFAULT_PATH)
message(STATUS "OpenPGM x86 detected - ${OPENPGM_ROOT}")
endif (CMAKE_CL_64)
endif()
set(OPENPGM_INCLUDE_DIRS ${OPENPGM_ROOT}/include)
set(OPENPGM_LIBRARY_DIRS ${OPENPGM_ROOT}/lib)
set(OPENPGM_LIBRARIES
@ -497,10 +491,10 @@ else ()
# message(FATAL_ERROR "WITH_OPENPGM not implemented")
if(NOT OPENPGM_PKGCONFIG_NAME)
SET (OPENPGM_PKGCONFIG_NAME "openpgm-5.2")
endif(NOT OPENPGM_PKGCONFIG_NAME)
set(OPENPGM_PKGCONFIG_NAME "openpgm-5.2")
endif()
SET (OPENPGM_PKGCONFIG_NAME ${OPENPGM_PKGCONFIG_NAME} CACHE STRING
set(OPENPGM_PKGCONFIG_NAME ${OPENPGM_PKGCONFIG_NAME} CACHE STRING
"Name pkg-config shall use to find openpgm libraries and include paths"
FORCE)
@ -528,14 +522,13 @@ endif ()
# force off-tree build
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
message (FATAL_ERROR "CMake generation is not allowed within the source directory!
Remove the CMakeCache.txt file and try again from another folder, e.g.:
rm CMakeCache.txt
mkdir cmake-make
cd cmake-make
cmake ..
")
message(FATAL_ERROR "CMake generation is not allowed within the source directory! \
Remove the CMakeCache.txt file and try again from another folder, e.g.: \
\
rm CMakeCache.txt \
mkdir cmake-make \
cd cmake-make \
cmake ..")
endif()
#-----------------------------------------------------------------------------
@ -835,11 +828,11 @@ if (MINGW)
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR})
endif()
# Also happens on x86_64 systems...what a worthless variable
if(CMAKE_SYSTEM_PROCESSOR MATCHES "i386"
OR CMAKE_SYSTEM_PROCESSOR MATCHES "i486"
OR CMAKE_SYSTEM_PROCESSOR MATCHES "i586"
OR CMAKE_SYSTEM_PROCESSOR MATCHES "i686"
# This also happens on x86_64 systems...what a worthless variable
OR CMAKE_SYSTEM_PROCESSOR MATCHES "x86"
OR CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64"
OR CMAKE_SYSTEM_PROCESSOR MATCHES "amd64")
@ -852,10 +845,12 @@ if (MINGW)
endif()
endif()
set (public_headers include/zmq.h
set(public_headers
include/zmq.h
include/zmq_utils.h)
set (readme-docs AUTHORS
set(readme-docs
AUTHORS
COPYING
COPYING.LESSER
NEWS)
@ -868,18 +863,18 @@ if (WITH_OPENPGM)
include_directories(${OPENPGM_INCLUDE_DIRS})
link_directories(${OPENPGM_LIBRARY_DIRS})
set(OPTIONAL_LIBRARIES ${OPENPGM_LIBRARIES})
endif (WITH_OPENPGM)
endif()
if(WITH_VMCI)
add_definitions(-DZMQ_HAVE_VMCI)
include_directories(${VMCI_INCLUDE_DIRS})
list(APPEND cxx-sources vmci_address.cpp vmci_connecter.cpp vmci_listener.cpp vmci.cpp)
endif (WITH_VMCI)
endif()
if(ZMQ_HAVE_TIPC)
add_definitions(-DZMQ_HAVE_TIPC)
list(APPEND cxx-sources tipc_address.cpp tipc_connecter.cpp tipc_listener.cpp)
endif (ZMQ_HAVE_TIPC)
endif()
#-----------------------------------------------------------------------------
# source generators
@ -961,16 +956,14 @@ if (MSVC)
set_source_files_properties(${source}
PROPERTIES
COMPILE_FLAGS "/Yuprecompiled.hpp"
OBJECT_DEPENDS precompiled.hpp
)
OBJECT_DEPENDS precompiled.hpp)
endif()
endforeach()
# create precompiled header
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/src/precompiled.cpp
PROPERTIES
COMPILE_FLAGS "/Ycprecompiled.hpp"
OBJECT_OUTPUTS precompiled.hpp
)
OBJECT_OUTPUTS precompiled.hpp)
endif()
@ -1038,8 +1031,7 @@ else ()
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
)
$<INSTALL_INTERFACE:include>)
endif()
if(BUILD_SHARED)
@ -1073,22 +1065,22 @@ else ()
if(BUILD_STATIC)
if(MINGW)
add_library (libzmq-static STATIC ${sources} ${public_headers} ${html-docs} ${readme-docs} ${zmq-pkgconfig} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
add_library(libzmq-static STATIC ${sources} ${public_headers} ${html-docs}
${readme-docs} ${zmq-pkgconfig} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
else()
add_library (libzmq-static STATIC $<TARGET_OBJECTS:objects> ${public_headers} ${html-docs} ${readme-docs} ${zmq-pkgconfig} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
add_library(libzmq-static STATIC $<TARGET_OBJECTS:objects> ${public_headers}
${html-docs} ${readme-docs} ${zmq-pkgconfig} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
endif()
set_target_properties(libzmq-static PROPERTIES
PUBLIC_HEADER "${public_headers}"
OUTPUT_NAME "zmq"
PREFIX "lib")
endif()
endif()
if(BUILD_STATIC)
target_compile_definitions(libzmq-static
PUBLIC ZMQ_STATIC
)
PUBLIC ZMQ_STATIC)
endif()
foreach(target ${target_outputs})
@ -1096,8 +1088,7 @@ foreach (target ${target_outputs})
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
)
$<INSTALL_INTERFACE:include>)
endforeach()
if(BUILD_SHARED)
@ -1161,7 +1152,8 @@ if (BUILD_STATIC)
endif()
if(BUILD_SHARED)
set (perf-tools local_lat
set(perf-tools
local_lat
remote_lat
local_thr
remote_thr
@ -1208,7 +1200,7 @@ set (ZMQ_BUILD_TESTS ${BUILD_TESTS} CACHE BOOL "Build the tests for ZeroMQ")
if(ZMQ_BUILD_TESTS)
enable_testing() # Enable testing only works in root scope
ADD_SUBDIRECTORY (tests)
add_subdirectory(tests)
if(BUILD_STATIC)
add_subdirectory(unittests)
else()

View File

@ -2,7 +2,7 @@
cmake_minimum_required(VERSION "2.8.1")
# On Windows: solution file will be called tests.sln
PROJECT(tests)
project(tests)
set(tests
test_ancillaries
@ -73,10 +73,12 @@ set(tests
test_reconnect_ivl
test_mock_pub_sub
)
if(ZMQ_HAVE_CURVE)
list(APPEND tests
test_security_curve)
endif()
if(NOT WIN32)
list(APPEND tests
test_ipc_wildcard
@ -123,8 +125,7 @@ if(WITH_VMCI)
)
endif()
IF (ENABLE_DRAFTS)
if(ENABLE_DRAFTS)
list(APPEND tests
test_poller
test_thread_safe
@ -136,7 +137,7 @@ IF (ENABLE_DRAFTS)
test_app_meta
test_router_notify
)
ENDIF (ENABLE_DRAFTS)
endif()
# add location of platform.hpp for Windows builds
if(WIN32)
@ -146,8 +147,7 @@ if(WIN32)
link_libraries(ws2_32.lib)
endif()
add_library (unity
STATIC
add_library(unity STATIC
"${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.c"
"${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.h"
"${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity_internals.h")
@ -156,13 +156,13 @@ set_target_properties (unity PROPERTIES
target_compile_definitions(unity PUBLIC "UNITY_USE_COMMAND_LINE_ARGS" "UNITY_EXCLUDE_FLOAT")
target_include_directories(unity PUBLIC "${CMAKE_CURRENT_LIST_DIR}/../external/unity")
IF (MSVC_VERSION LESS 1700)
SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.c" PROPERTIES LANGUAGE CXX)
ENDIF()
if(MSVC_VERSION LESS 1700)
set_source_files_properties("${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.c" PROPERTIES LANGUAGE CXX)
endif()
IF (MSVC_VERSION LESS 1600)
if(MSVC_VERSION LESS 1600)
target_compile_definitions(unity PUBLIC "UNITY_EXCLUDE_STDINT_H")
ENDIF()
endif()
# add library and include dirs for all targets
if(BUILD_SHARED)
@ -192,7 +192,7 @@ foreach(test ${tests})
# You should provide the correct directory, don't know how to do it automatically
find_path(LIBZMQ_PATH "libzmq.lib" PATHS "../bin/Win32/Debug/v120/dynamic")
if(NOT ${LIBZMQ_PATH} STREQUAL "LIBZMQ_PATH-NOTFOUND")
SET_TARGET_PROPERTIES( ${test} PROPERTIES LINK_FLAGS "/LIBPATH:${LIBZMQ_PATH}" )
set_target_properties(${test} PROPERTIES LINK_FLAGS "/LIBPATH:${LIBZMQ_PATH}")
endif()
else()
# per-test directories not generated on OS X / Darwin
@ -201,7 +201,6 @@ foreach(test ${tests})
endif()
endif()
if(RT_LIBRARY)
target_link_libraries(${test} ${RT_LIBRARY})
endif()

View File

@ -9,10 +9,10 @@ set(unittests
unittest_udp_address
)
#IF (ENABLE_DRAFTS)
#if(ENABLE_DRAFTS)
# list(APPEND tests
# )
#ENDIF (ENABLE_DRAFTS)
#endif(ENABLE_DRAFTS)
# add location of platform.hpp for Windows builds
if(WIN32)