mirror of
https://github.com/zeromq/libzmq.git
synced 2025-01-14 01:37:56 +08:00
Some changes for CMakeLists.txt:
- MacOS version requires CMake version 3.0.2 (because of policy CMP0042) - Add option to build instrumented binaries with Address Sanitizer - Add option to select compiler intrinsics for atomic ops - Only build docs on request (saves build time)
This commit is contained in:
parent
efc9a3021f
commit
29c369ff0b
@ -1,19 +1,38 @@
|
|||||||
# CMake build script for ZeroMQ
|
# CMake build script for ZeroMQ
|
||||||
cmake_minimum_required(VERSION 2.8.12)
|
|
||||||
|
|
||||||
project(ZeroMQ)
|
project(ZeroMQ)
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
|
||||||
|
cmake_minimum_required(VERSION 3.0.2)
|
||||||
|
else()
|
||||||
|
cmake_minimum_required(VERSION 2.8.12)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(ENABLE_ASAN "Build with address sanitizer)" OFF)
|
||||||
|
if(ENABLE_ASAN)
|
||||||
|
message(STATUS "Instrumenting with Address Sanitizer")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope -fno-omit-frame-pointer")
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -fsanitize-address-use-after-scope")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option (ENABLE_INTRINSICS "Build using compiler intrinsics for atomic ops" OFF)
|
||||||
|
if (ENABLE_INTRINSICS)
|
||||||
|
message(STATUS "Using compiler intrinsics for atomic ops")
|
||||||
|
add_definitions(-DZMQ_HAVE_ATOMIC_INTRINSICS)
|
||||||
|
endif()
|
||||||
|
|
||||||
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}")
|
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
set(ZMQ_CMAKE_MODULES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/Modules)
|
set(ZMQ_CMAKE_MODULES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/Modules)
|
||||||
list(APPEND CMAKE_MODULE_PATH ${ZMQ_CMAKE_MODULES_DIR})
|
list(APPEND CMAKE_MODULE_PATH ${ZMQ_CMAKE_MODULES_DIR})
|
||||||
|
|
||||||
# Apply CMP0042: MACOSX_RPATH is enabled by default
|
|
||||||
cmake_policy(SET CMP0042 NEW)
|
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
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
|
||||||
|
|
||||||
|
# Apply CMP0042: MACOSX_RPATH is enabled by default
|
||||||
|
cmake_policy(SET CMP0042 NEW)
|
||||||
|
|
||||||
# Add an install rpath if it is not a system directory
|
# Add an install rpath if it is not a system directory
|
||||||
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir)
|
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir)
|
||||||
if("${isSystemDir}" STREQUAL "-1")
|
if("${isSystemDir}" STREQUAL "-1")
|
||||||
@ -916,29 +935,32 @@ if(MSVC)
|
|||||||
DEPENDS ${nsis-template})
|
DEPENDS ${nsis-template})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc)
|
option (WITH_DOCS "Build html docs" ON)
|
||||||
file(GLOB docs RELATIVE ${CMAKE_CURRENT_BINARY_DIR}/ "${CMAKE_CURRENT_SOURCE_DIR}/doc/*.txt")
|
if (WITH_DOCS)
|
||||||
set(html-docs)
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc)
|
||||||
foreach(txt ${docs})
|
file(GLOB docs RELATIVE ${CMAKE_CURRENT_BINARY_DIR}/ "${CMAKE_CURRENT_SOURCE_DIR}/doc/*.txt")
|
||||||
string(REGEX REPLACE ".*/(.*)\\.txt" "\\1.html" html ${txt})
|
set(html-docs)
|
||||||
set(src ${txt})
|
foreach(txt ${docs})
|
||||||
set(dst doc/${html})
|
string(REGEX REPLACE ".*/(.*)\\.txt" "\\1.html" html ${txt})
|
||||||
if(WITH_DOC)
|
set(src ${txt})
|
||||||
add_custom_command(
|
set(dst doc/${html})
|
||||||
OUTPUT ${dst}
|
if(WITH_DOC)
|
||||||
COMMAND ${ASCIIDOC_EXECUTABLE}
|
add_custom_command(
|
||||||
-d manpage
|
OUTPUT ${dst}
|
||||||
-b xhtml11
|
COMMAND ${ASCIIDOC_EXECUTABLE}
|
||||||
-f ${CMAKE_CURRENT_SOURCE_DIR}/doc/asciidoc.conf
|
-d manpage
|
||||||
-azmq_version=${ZMQ_VERSION}
|
-b xhtml11
|
||||||
-o ${dst}
|
-f ${CMAKE_CURRENT_SOURCE_DIR}/doc/asciidoc.conf
|
||||||
${src}
|
-azmq_version=${ZMQ_VERSION}
|
||||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${src}
|
-o ${dst}
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
${src}
|
||||||
COMMENT "Generating ${html}")
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${src}
|
||||||
list(APPEND html-docs ${CMAKE_CURRENT_BINARY_DIR}/${dst})
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
endif()
|
COMMENT "Generating ${html}")
|
||||||
endforeach()
|
list(APPEND html-docs ${CMAKE_CURRENT_BINARY_DIR}/${dst})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(ZMQ_BUILD_FRAMEWORK)
|
if(ZMQ_BUILD_FRAMEWORK)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user