0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-26 23:01:04 +08:00

Problem: include directives are cluttered throughout CMakeLists.txt

Solution: Group include directives together at the beginning of the CMakeLists.txt file
This commit is contained in:
Simon Giesecke 2019-04-23 08:54:40 -04:00
parent 7c53567b93
commit 3e5843d073

View File

@ -7,6 +7,29 @@ else()
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 2.8.12)
endif() endif()
include(CheckIncludeFiles)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CheckLibraryExists)
include(CheckCSourceCompiles)
include(CheckCSourceRuns)
include(CMakeDependentOption)
include(CheckCXXSymbolExists)
include(CheckSymbolExists)
include(FindThreads)
include(GNUInstallDirs)
include(CheckFunctionExists)
include(CheckTypeSize)
include(CMakePackageConfigHelpers)
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}")
set(ZMQ_CMAKE_MODULES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/Modules)
list(APPEND CMAKE_MODULE_PATH ${ZMQ_CMAKE_MODULES_DIR})
include(TestZMQVersion)
include(ZMQSourceRunChecks)
include(ZMQSupportMacros)
option(ENABLE_ASAN "Build with address sanitizer" OFF) option(ENABLE_ASAN "Build with address sanitizer" OFF)
if(ENABLE_ASAN) if(ENABLE_ASAN)
message(STATUS "Instrumenting with Address Sanitizer") message(STATUS "Instrumenting with Address Sanitizer")
@ -22,11 +45,6 @@ if (ENABLE_INTRINSICS)
add_definitions(-DZMQ_HAVE_ATOMIC_INTRINSICS) add_definitions(-DZMQ_HAVE_ATOMIC_INTRINSICS)
endif() endif()
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}")
set(ZMQ_CMAKE_MODULES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/Modules)
list(APPEND CMAKE_MODULE_PATH ${ZMQ_CMAKE_MODULES_DIR})
include(GNUInstallDirs)
if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin) if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
# Find more information: https://cmake.org/Wiki/CMake_RPATH_handling # Find more information: https://cmake.org/Wiki/CMake_RPATH_handling
@ -43,19 +61,15 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif() 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) if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
endif() 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) if(COMPILER_SUPPORTS_C11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
endif() endif()
include(ZMQSupportMacros)
if(NOT MSVC) if(NOT MSVC)
# clang 6 has a warning that does not make sense on multi-platform code # 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)
@ -138,9 +152,6 @@ set(API_POLLER "" CACHE STRING "Choose polling system for zmq_poll(er)_*. valid
set(POLLER "" CACHE STRING "Choose polling system for I/O threads. valid values are set(POLLER "" CACHE STRING "Choose polling system for I/O threads. valid values are
kqueue, epoll, devpoll, pollset, poll or select [default=autodetect]") kqueue, epoll, devpoll, pollset, poll or select [default=autodetect]")
include(CheckFunctionExists)
include(CheckTypeSize)
if(NOT MSVC) if(NOT MSVC)
if(POLLER STREQUAL "") if(POLLER STREQUAL "")
set(CMAKE_REQUIRED_INCLUDES sys/event.h) set(CMAKE_REQUIRED_INCLUDES sys/event.h)
@ -239,19 +250,6 @@ message(STATUS "Using polling method in zmq_poll(er)_* API: ${API_POLLER}")
string(TOUPPER ${API_POLLER} UPPER_API_POLLER) string(TOUPPER ${API_POLLER} UPPER_API_POLLER)
set(ZMQ_POLL_BASED_ON_${UPPER_API_POLLER} 1) set(ZMQ_POLL_BASED_ON_${UPPER_API_POLLER} 1)
include(TestZMQVersion)
include(ZMQSourceRunChecks)
include(CheckIncludeFiles)
include(CheckLibraryExists)
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
include(CheckCSourceCompiles)
include(CheckCSourceRuns)
include(CMakeDependentOption)
include(CheckCXXSymbolExists)
include(CheckSymbolExists)
include(FindThreads)
execute_process(COMMAND getconf LEVEL1_DCACHE_LINESIZE OUTPUT_VARIABLE CACHELINE_SIZE ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process(COMMAND getconf LEVEL1_DCACHE_LINESIZE OUTPUT_VARIABLE CACHELINE_SIZE ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if(CACHELINE_SIZE STREQUAL "" OR CACHELINE_SIZE EQUAL 0 OR CACHELINE_SIZE EQUAL -1) if(CACHELINE_SIZE STREQUAL "" OR CACHELINE_SIZE EQUAL 0 OR CACHELINE_SIZE EQUAL -1)
set(ZMQ_CACHELINE_SIZE 64) set(ZMQ_CACHELINE_SIZE 64)
@ -1419,8 +1417,6 @@ if(WITH_DOC)
endif() endif()
endif() endif()
include(CMakePackageConfigHelpers)
if(WIN32) if(WIN32)
set(ZEROMQ_CMAKECONFIG_INSTALL_DIR "CMake" CACHE STRING "install path for ZeroMQConfig.cmake") set(ZEROMQ_CMAKECONFIG_INSTALL_DIR "CMake" CACHE STRING "install path for ZeroMQConfig.cmake")
else() else()
@ -1548,4 +1544,5 @@ if(MSVC_VERSION EQUAL 1600)
endif() endif()
endif() endif()
# this cannot be moved, as it does not only contain function/macro definitions
include(ClangFormat) include(ClangFormat)