2012-12-31 17:52:32 -05:00
# CMake build script for ZeroMQ
2018-09-10 00:12:07 +02:00
project ( ZeroMQ )
2016-02-11 13:32:01 +01:00
2018-11-02 11:10:14 -04:00
if ( ${ CMAKE_SYSTEM_NAME } STREQUAL Darwin )
cmake_minimum_required ( VERSION 3.0.2 )
else ( )
cmake_minimum_required ( VERSION 2.8.12 )
endif ( )
2019-04-23 08:54:40 -04:00
include ( CheckIncludeFiles )
include ( CheckCCompilerFlag )
include ( CheckCXXCompilerFlag )
include ( CheckLibraryExists )
include ( CheckCSourceCompiles )
include ( CheckCSourceRuns )
include ( CMakeDependentOption )
include ( CheckCXXSymbolExists )
2019-04-23 09:12:56 -04:00
include ( CheckTypeSize )
2019-04-23 08:54:40 -04:00
include ( FindThreads )
include ( GNUInstallDirs )
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 )
2019-04-23 08:46:27 -04:00
option ( ENABLE_ASAN "Build with address sanitizer" OFF )
2018-11-02 11:10:14 -04:00
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 ( )
2019-11-13 12:00:47 +01:00
set ( ZMQ_OUTPUT_BASENAME "zmq" CACHE STRING "Output zmq library base name" )
2018-09-10 00:12:07 +02:00
if ( ${ CMAKE_SYSTEM_NAME } STREQUAL Darwin )
2018-04-25 19:06:21 +02:00
# Find more information: https://cmake.org/Wiki/CMake_RPATH_handling
2018-11-02 11:10:14 -04:00
# Apply CMP0042: MACOSX_RPATH is enabled by default
cmake_policy ( SET CMP0042 NEW )
2018-04-25 19:06:21 +02:00
# Add an install rpath if it is not a system directory
2018-09-10 00:12:07 +02:00
list ( FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" isSystemDir )
if ( "${isSystemDir}" STREQUAL "-1" )
set ( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" )
endif ( )
2018-04-25 19:06:21 +02:00
# Add linker search paths pointing to external dependencies
2018-09-10 00:12:07 +02:00
set ( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
endif ( )
2018-04-25 19:06:21 +02:00
2018-09-10 00:12:07 +02:00
check_cxx_compiler_flag ( "-std=gnu++11" COMPILER_SUPPORTS_CXX11 )
2016-02-19 21:48:43 +00:00
if ( COMPILER_SUPPORTS_CXX11 )
2018-09-10 00:12:07 +02:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11" )
2016-02-19 21:48:43 +00:00
endif ( )
2018-09-10 00:12:07 +02:00
check_c_compiler_flag ( "-std=gnu11" COMPILER_SUPPORTS_C11 )
2016-02-19 21:48:43 +00:00
if ( COMPILER_SUPPORTS_C11 )
2018-09-10 00:12:07 +02:00
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11" )
2019-08-01 05:43:55 +02:00
else ( )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99" )
2016-02-19 21:48:43 +00:00
endif ( )
2018-05-26 20:05:14 +01:00
if ( NOT MSVC )
2018-09-10 00:12:07 +02:00
# 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 )
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 )
if ( CC_HAS_TAUT_WARNING )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-tautological-constant-compare" )
endif ( )
2018-05-26 20:05:14 +01:00
endif ( )
2016-09-27 18:39:07 +01:00
# Will be used to add flags to pkg-config useful when apps want to statically link
2018-09-10 00:12:07 +02:00
set ( pkg_config_libs_private "" )
2018-12-14 21:45:27 +00:00
set ( pkg_config_names_private "" )
2016-09-27 18:39:07 +01:00
2018-09-10 00:12:07 +02:00
option ( WITH_OPENPGM "Build with support for OpenPGM" OFF )
option ( WITH_VMCI "Build with support for VMware VMCI socket" OFF )
2016-02-11 13:32:01 +01:00
2018-09-10 00:12:07 +02:00
if ( APPLE )
option ( ZMQ_BUILD_FRAMEWORK "Build as OS X framework" OFF )
endif ( )
2016-02-11 13:32:01 +01:00
2019-09-11 13:09:22 +03:00
# Disable webSocket transport
option ( DISABLE_WS "Disable WebSocket transport" OFF )
option ( WITH_NSS "Use NSS instead of builtin sha1" OFF )
if ( NOT DISABLE_WS )
list ( APPEND sources
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / w s _ a d d r e s s . c p p
2019-11-28 12:32:31 +00:00
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / w s s _ a d d r e s s . c p p
2019-09-11 13:09:22 +03:00
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / w s _ c o n n e c t e r . c p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / w s _ d e c o d e r . c p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / w s _ e n c o d e r . c p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / w s _ e n g i n e . c p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / w s _ l i s t e n e r . c p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / w s _ a d d r e s s . h p p
2019-11-28 12:32:31 +00:00
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / w s s _ a d d r e s s . h p p
2019-09-11 13:09:22 +03:00
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / w s _ c o n n e c t e r . h p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / w s _ d e c o d e r . h p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / w s _ e n c o d e r . h p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / w s _ e n g i n e . h p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / w s _ l i s t e n e r . h p p
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / s r c / w s _ p r o t o c o l . h p p )
set ( ZMQ_HAVE_WS 1 )
if ( WITH_NSS )
find_package ( "NSS3" )
if ( NSS3_FOUND )
message ( STATUS "Using NSS" )
include_directories ( ${ NSS3_INCLUDE_DIRS } )
set ( pkg_config_names_private "${pkg_config_names_private} nss3" )
set ( pkg_config_libs_private "${pkg_config_libs_private} -lnss3" )
set ( ZMQ_USE_NSS 1 )
else ( )
message ( FATAL_ERROR
" n s s i s n o t i n s t a l l e d . I n s t a l l i t , t h e n r u n C M a k e a g a i n " )
endif ( )
else ( )
list ( APPEND sources ${ CMAKE_CURRENT_SOURCE_DIR } /external/sha1/sha1.c ${ CMAKE_CURRENT_SOURCE_DIR } /external/sha1/sha1.h )
message ( "Using builtin sha1" )
set ( ZMQ_USE_BUILTIN_SHA1 1 )
endif ( )
endif ( )
2016-02-11 13:32:01 +01:00
# Select curve encryption library, defaults to tweetnacl
2018-09-10 00:12:07 +02:00
# To use libsodium instead, use --with-libsodium(must be installed)
2016-02-11 13:32:01 +01:00
# To disable curve, use --disable-curve
2018-09-10 00:12:07 +02:00
option ( WITH_LIBSODIUM "Use libsodium instead of built-in tweetnacl" OFF )
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 )
message ( STATUS "Using libsodium for CURVE security" )
include_directories ( ${ SODIUM_INCLUDE_DIRS } )
set ( ZMQ_USE_LIBSODIUM 1 )
set ( ZMQ_HAVE_CURVE 1 )
else ( )
message ( FATAL_ERROR
" l i b s o d i u m i s n o t i n s t a l l e d . I n s t a l l i t , t h e n r u n C M a k e a g a i n " )
endif ( )
else ( )
message ( STATUS "Using tweetnacl for CURVE security" )
list ( APPEND sources ${ CMAKE_CURRENT_SOURCE_DIR } /src/tweetnacl.c )
set ( ZMQ_USE_TWEETNACL 1 )
set ( ZMQ_HAVE_CURVE 1 )
endif ( )
2016-02-11 13:32:01 +01:00
2016-05-02 19:44:35 +01:00
set ( SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" )
2018-09-10 00:12:07 +02:00
if ( EXISTS "${SOURCE_DIR}/.git" )
option ( ENABLE_DRAFTS "Build and install draft classes and methods" ON )
else ( )
option ( ENABLE_DRAFTS "Build and install draft classes and methods" OFF )
endif ( )
if ( ENABLE_DRAFTS )
2018-11-12 16:57:11 -05:00
option ( ENABLE_RADIX_TREE "Use radix tree implementation to manage subscriptions" ON )
2018-09-10 00:12:07 +02:00
add_definitions ( -DZMQ_BUILD_DRAFT_API )
set ( pkg_config_defines "-DZMQ_BUILD_DRAFT_API=1" )
else ( )
2018-11-12 16:57:11 -05:00
option ( ENABLE_RADIX_TREE "Use radix tree implementation to manage subscriptions" OFF )
2018-09-10 00:12:07 +02:00
set ( pkg_config_defines "" )
2016-05-06 20:50:56 +01:00
endif ( )
2018-11-12 16:57:11 -05:00
if ( ENABLE_RADIX_TREE )
message ( STATUS "Using radix tree implementation to manage subscriptions" )
add_definitions ( -DZMQ_USE_RADIX_TREE )
endif ( )
2018-09-10 00:12:07 +02:00
option ( WITH_MILITANT "Enable militant assertions" OFF )
if ( WITH_MILITANT )
add_definitions ( -DZMQ_ACT_MILITANT )
2018-05-23 16:47:13 +02:00
endif ( )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
set ( API_POLLER "" CACHE STRING " Choose polling system for zmq_poll(er ) _ * . v a l i d v a l u e s a r e
p o l l o r s e l e c t [ d e f a u l t = p o l l u n l e s s P O L L E R = s e l e c t ] " )
set ( POLLER "" CACHE STRING " Choose polling system for I/O threads. valid values are
k q u e u e , e p o l l , d e v p o l l , p o l l s e t , p o l l o r s e l e c t [ d e f a u l t = a u t o d e t e c t ] " )
2019-10-19 14:46:53 +02:00
if ( WIN32 )
2019-12-06 14:27:24 +01:00
if ( CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND CMAKE_SYSTEM_VERSION MATCHES "^10.0" )
set ( ZMQ_HAVE_WINDOWS_UWP ON )
set ( ZMQ_HAVE_IPC OFF )
# to remove compile warninging "D9002 ignoring unknown option"
string ( REPLACE "/Zi" "" CMAKE_CXX_FLAGS_DEBUG ${ CMAKE_CXX_FLAGS_DEBUG } )
set ( CMAKE_CXX_FLAGS_DEBUG ${ CMAKE_CXX_FLAGS_DEBUG } CACHE STRING "" FORCE )
string ( REPLACE "/Zi" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${ CMAKE_CXX_FLAGS_RELWITHDEBINFO } )
set ( CMAKE_CXX_FLAGS_RELWITHDEBINFO ${ CMAKE_CXX_FLAGS_RELWITHDEBINFO } CACHE STRING "" FORCE )
string ( REPLACE "/Zi" "" CMAKE_CXX_FLAGS_DEBUG ${ CMAKE_CXX_FLAGS_DEBUG } )
endif ( )
2019-10-19 14:46:53 +02:00
# from https://stackoverflow.com/a/40217291/2019765
macro ( get_WIN32_WINNT version )
if ( CMAKE_SYSTEM_VERSION )
set ( ver ${ CMAKE_SYSTEM_VERSION } )
string ( REGEX MATCH "^([0-9]+).([0-9])" ver ${ ver } )
string ( REGEX MATCH "^([0-9]+)" verMajor ${ ver } )
# Check for Windows 10, b/c we'll need to convert to hex 'A'.
if ( "${verMajor}" MATCHES "10" )
set ( verMajor "A" )
string ( REGEX REPLACE "^([0-9]+)" ${ verMajor } ver ${ ver } )
endif ( "${verMajor}" MATCHES "10" )
# Remove all remaining '.' characters.
string ( REPLACE "." "" ver ${ ver } )
# Prepend each digit with a zero.
string ( REGEX REPLACE "([0-9A-Z])" "0\\1" ver ${ ver } )
set ( ${ version } "0x${ver}" )
endif ( CMAKE_SYSTEM_VERSION )
endmacro ( get_WIN32_WINNT )
get_WIN32_WINNT ( ZMQ_WIN32_WINNT_DEFAULT )
message ( STATUS "Detected _WIN32_WINNT from CMAKE_SYSTEM_VERSION: ${ZMQ_WIN32_WINNT_DEFAULT}" )
# TODO limit _WIN32_WINNT to the actual Windows SDK version, which might be different from the default version installed with Visual Studio
if ( MSVC_VERSION STREQUAL "1500" AND CMAKE_SYSTEM_VERSION VERSION_GREATER "6.0" )
set ( ZMQ_WIN32_WINNT_LIMIT "0x0600" )
elseif ( MSVC_VERSION STREQUAL "1600" AND CMAKE_SYSTEM_VERSION VERSION_GREATER "6.1" )
set ( ZMQ_WIN32_WINNT_LIMIT "0x0601" )
elseif ( MSVC_VERSION STREQUAL "1700" AND CMAKE_SYSTEM_VERSION VERSION_GREATER "6.1" )
set ( ZMQ_WIN32_WINNT_LIMIT "0x0601" )
elseif ( MSVC_VERSION STREQUAL "1800" AND CMAKE_SYSTEM_VERSION VERSION_GREATER "6.2" )
set ( ZMQ_WIN32_WINNT_LIMIT "0x0602" )
endif ( )
if ( ZMQ_WIN32_WINNT_LIMIT )
message ( STATUS "Mismatch of Visual Studio Version (${MSVC_VERSION}) and CMAKE_SYSTEM_VERSION (${CMAKE_SYSTEM_VERSION}), limiting _WIN32_WINNT to ${ZMQ_WIN32_WINNT_LIMIT}, you may override this by setting ZMQ_WIN32_WINNT" )
set ( ZMQ_WIN32_WINNT_DEFAULT "${ZMQ_WIN32_WINNT_LIMIT}" )
endif ( )
set ( ZMQ_WIN32_WINNT "${ZMQ_WIN32_WINNT_DEFAULT}" CACHE STRING "Value to set _WIN32_WINNT to for building [default=autodetect from build environment]" )
2019-12-06 14:27:24 +01:00
# On Windows Vista or greater, with MSVC 2013 or greater, default to epoll (which is required on Win 10 for ipc support)
if ( ZMQ_WIN32_WINNT GREATER "0x05FF" AND MSVC_VERSION GREATER 1799 AND POLLER STREQUAL "" AND NOT ZMQ_HAVE_WINDOWS_UWP )
set ( POLLER "epoll" )
endif ( )
2019-10-19 14:46:53 +02:00
2019-12-06 14:27:24 +01:00
add_definitions ( -D_WIN32_WINNT= ${ ZMQ_WIN32_WINNT } )
2019-10-19 14:46:53 +02:00
endif ( WIN32 )
2018-09-10 00:12:07 +02:00
if ( NOT MSVC )
if ( POLLER STREQUAL "" )
2019-04-23 09:12:56 -04:00
check_cxx_symbol_exists ( kqueue sys/event.h HAVE_KQUEUE )
2018-09-10 00:12:07 +02:00
if ( HAVE_KQUEUE )
set ( POLLER "kqueue" )
endif ( )
endif ( )
if ( POLLER STREQUAL "" )
2019-04-23 09:12:56 -04:00
check_cxx_symbol_exists ( epoll_create sys/epoll.h HAVE_EPOLL )
2018-09-10 00:12:07 +02:00
if ( HAVE_EPOLL )
set ( POLLER "epoll" )
2019-04-23 09:12:56 -04:00
check_cxx_symbol_exists ( epoll_create1 sys/epoll.h HAVE_EPOLL_CLOEXEC )
2018-09-10 00:12:07 +02:00
if ( HAVE_EPOLL_CLOEXEC )
set ( ZMQ_IOTHREAD_POLLER_USE_EPOLL_CLOEXEC 1 )
endif ( )
endif ( )
endif ( )
if ( POLLER STREQUAL "" )
2019-04-23 09:12:56 -04:00
set ( CMAKE_EXTRA_INCLUDE_FILES sys/devpoll.h )
2018-09-10 00:12:07 +02:00
check_type_size ( "struct pollfd" DEVPOLL )
2019-04-23 09:12:56 -04:00
set ( CMAKE_EXTRA_INCLUDE_FILES )
2018-09-10 00:12:07 +02:00
if ( HAVE_DEVPOLL )
set ( POLLER "devpoll" )
endif ( )
endif ( )
if ( POLLER STREQUAL "" )
2019-04-23 09:12:56 -04:00
check_cxx_symbol_exists ( pollset_create sys/pollset.h HAVE_POLLSET )
2018-09-10 00:12:07 +02:00
if ( HAVE_POLLSET )
set ( POLLER "pollset" )
endif ( )
endif ( )
if ( POLLER STREQUAL "" )
2019-04-23 09:12:56 -04:00
check_cxx_symbol_exists ( poll poll.h HAVE_POLL )
2018-09-10 00:12:07 +02:00
if ( HAVE_POLL )
set ( POLLER "poll" )
endif ( )
endif ( )
2018-05-23 11:50:42 +02:00
endif ( )
2018-09-10 00:12:07 +02:00
if ( POLLER STREQUAL "" )
if ( WIN32 )
set ( HAVE_SELECT 1 )
else ( )
2019-04-23 09:12:56 -04:00
check_cxx_symbol_exists ( select sys/select.h HAVE_SELECT )
2018-09-10 00:12:07 +02:00
endif ( )
if ( HAVE_SELECT )
set ( POLLER "select" )
else ( )
message ( FATAL_ERROR
" C o u l d n o t a u t o d e t e c t p o l l i n g m e t h o d " )
endif ( )
endif ( )
if ( POLLER STREQUAL "kqueue"
O R P O L L E R S T R E Q U A L " e p o l l "
O R P O L L E R S T R E Q U A L " d e v p o l l "
O R P O L L E R S T R E Q U A L " p o l l s e t "
O R P O L L E R S T R E Q U A L " p o l l "
O R P O L L E R S T R E Q U A L " s e l e c t " )
message ( STATUS "Using polling method in I/O threads: ${POLLER}" )
string ( TOUPPER ${ POLLER } UPPER_POLLER )
set ( ZMQ_IOTHREAD_POLLER_USE_ ${ UPPER_POLLER } 1 )
else ( )
message ( FATAL_ERROR "Invalid polling method" )
2018-05-22 15:57:20 +02:00
endif ( )
2018-09-10 00:12:07 +02:00
if ( POLLER STREQUAL "epoll" AND WIN32 )
message ( STATUS "Including wepoll" )
list ( APPEND sources ${ CMAKE_CURRENT_SOURCE_DIR } /external/wepoll/wepoll.c ${ CMAKE_CURRENT_SOURCE_DIR } /external/wepoll/wepoll.h )
endif ( )
if ( API_POLLER STREQUAL "" )
if ( POLLER STREQUAL "select" )
set ( API_POLLER "select" )
else ( )
set ( API_POLLER "poll" )
endif ( )
endif ( )
message ( STATUS "Using polling method in zmq_poll(er)_* API: ${API_POLLER}" )
string ( TOUPPER ${ API_POLLER } UPPER_API_POLLER )
set ( ZMQ_POLL_BASED_ON_ ${ UPPER_API_POLLER } 1 )
2019-01-19 19:39:42 +00:00
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 )
set ( ZMQ_CACHELINE_SIZE 64 )
else ( )
set ( ZMQ_CACHELINE_SIZE ${ CACHELINE_SIZE } )
endif ( )
message ( STATUS "Using ${ZMQ_CACHELINE_SIZE} bytes alignment for lock-free data structures" )
2018-09-10 00:12:07 +02:00
if ( NOT CYGWIN )
# TODO cannot we simply do 'if(WIN32) set(ZMQ_HAVE_WINDOWS ON)' or similar?
check_include_files ( windows.h ZMQ_HAVE_WINDOWS )
2018-05-24 15:12:57 +02:00
endif ( )
2019-10-19 14:46:53 +02:00
if ( NOT WIN32 )
set ( ZMQ_HAVE_IPC 1 )
else ( )
check_include_files ( "winsock2.h;afunix.h" ZMQ_HAVE_IPC )
endif ( )
2019-02-11 05:35:24 -05:00
2019-02-11 07:05:04 -05:00
###################### BEGIN condition_variable_t selection
if ( NOT ZMQ_CV_IMPL )
# prefer C++11 STL std::condition_variable implementation, if available
check_include_files ( condition_variable ZMQ_HAVE_STL_CONDITION_VARIABLE LANGUAGE CXX )
if ( ZMQ_HAVE_STL_CONDITION_VARIABLE )
set ( ZMQ_CV_IMPL_DEFAULT "stl11" )
else ( )
if ( WIN32 AND NOT CMAKE_SYSTEM_VERSION VERSION_LESS "6.0" )
# Win32API CONDITION_VARIABLE is supported from Windows Vista only
set ( ZMQ_CV_IMPL_DEFAULT "win32api" )
elseif ( CMAKE_USE_PTHREADS_INIT )
set ( ZMQ_CV_IMPL_DEFAULT "pthreads" )
else ( )
set ( ZMQ_CV_IMPL_DEFAULT "none" )
endif ( )
endif ( )
# TODO a vxworks implementation also exists, but vxworks is not currently supported with cmake at all
set ( ZMQ_CV_IMPL "${ZMQ_CV_IMPL_DEFAULT}" CACHE STRING " Choose condition_variable_t implementation. Valid values are
s t l 1 1 , w i n 3 2 a p i , p t h r e a d s , n o n e [ d e f a u l t = a u t o d e t e c t ] " )
endif ( )
message ( STATUS "Using condition_variable_t implementation: ${ZMQ_CV_IMPL}" )
if ( ZMQ_CV_IMPL STREQUAL "stl11" )
set ( ZMQ_USE_CV_IMPL_STL11 1 )
elseif ( ZMQ_CV_IMPL STREQUAL "win32api" )
set ( ZMQ_USE_CV_IMPL_WIN32API 1 )
elseif ( ZMQ_CV_IMPL STREQUAL "pthreads" )
set ( ZMQ_USE_CV_IMPL_PTHREADS 1 )
elseif ( ZMQ_CV_IMPL STREQUAL "none" )
set ( ZMQ_USE_CV_IMPL_NONE 1 )
else ( )
message ( ERROR "Unknown value for ZMQ_CV_IMPL: ${ZMQ_CV_IMPL}" )
endif ( )
###################### END condition_variable_t selection
2018-09-10 00:12:07 +02:00
if ( NOT MSVC )
check_include_files ( ifaddrs.h ZMQ_HAVE_IFADDRS )
check_include_files ( sys/uio.h ZMQ_HAVE_UIO )
check_include_files ( sys/eventfd.h ZMQ_HAVE_EVENTFD )
if ( ZMQ_HAVE_EVENTFD AND NOT CMAKE_CROSSCOMPILING )
zmq_check_efd_cloexec ( )
endif ( )
2018-05-23 16:47:13 +02:00
endif ( )
2013-12-06 10:55:44 -08:00
2018-09-10 00:12:07 +02:00
if ( ZMQ_HAVE_WINDOWS )
2018-01-09 18:15:24 +01:00
# Cannot use check_library_exists because the symbol is always declared as char(*)(void)
set ( CMAKE_REQUIRED_LIBRARIES "ws2_32.lib" )
2019-04-23 09:12:56 -04:00
check_cxx_symbol_exists ( WSAStartup "winsock2.h" HAVE_WS2_32 )
2018-01-09 18:15:24 +01:00
set ( CMAKE_REQUIRED_LIBRARIES "rpcrt4.lib" )
2019-04-23 09:12:56 -04:00
check_cxx_symbol_exists ( UuidCreateSequential "rpc.h" HAVE_RPCRT4 )
2018-01-09 18:15:24 +01:00
set ( CMAKE_REQUIRED_LIBRARIES "iphlpapi.lib" )
2019-04-23 09:12:56 -04:00
check_cxx_symbol_exists ( GetAdaptersAddresses "winsock2.h;iphlpapi.h" HAVE_IPHLAPI )
2018-01-09 18:15:24 +01:00
set ( CMAKE_REQUIRED_LIBRARIES "" )
# TODO: This not the symbol we're looking for. What is the symbol?
2018-09-10 00:12:07 +02:00
check_library_exists ( ws2 fopen "" HAVE_WS2 )
2018-01-09 18:15:24 +01:00
else ( )
2018-09-10 00:12:07 +02:00
check_cxx_symbol_exists ( SO_PEERCRED sys/socket.h ZMQ_HAVE_SO_PEERCRED )
check_cxx_symbol_exists ( LOCAL_PEERCRED sys/socket.h ZMQ_HAVE_LOCAL_PEERCRED )
2018-01-09 18:15:24 +01:00
endif ( )
2013-01-23 14:31:02 -05:00
2019-06-15 21:48:32 +08:00
if ( NOT MINGW )
find_library ( RT_LIBRARY rt )
if ( RT_LIBRARY )
set ( pkg_config_libs_private "${pkg_config_libs_private} -lrt" )
endif ( )
2018-12-14 21:45:27 +00:00
endif ( )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
find_package ( Threads )
2013-01-01 21:04:19 -05:00
2018-09-10 00:12:07 +02:00
if ( WIN32 AND NOT CYGWIN )
if ( NOT HAVE_WS2_32 AND NOT HAVE_WS2 )
message ( FATAL_ERROR "Cannot link to ws2_32 or ws2" )
endif ( )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
if ( NOT HAVE_RPCRT4 )
message ( FATAL_ERROR "Cannot link to rpcrt4" )
endif ( )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
if ( NOT HAVE_IPHLAPI )
message ( FATAL_ERROR "Cannot link to iphlapi" )
endif ( )
endif ( )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
if ( NOT MSVC )
set ( CMAKE_REQUIRED_LIBRARIES rt )
2019-04-23 09:12:56 -04:00
check_cxx_symbol_exists ( clock_gettime time.h HAVE_CLOCK_GETTIME )
2018-09-10 00:12:07 +02:00
set ( CMAKE_REQUIRED_LIBRARIES )
2012-12-31 17:52:32 -05:00
2019-04-23 09:12:56 -04:00
check_cxx_symbol_exists ( fork unistd.h HAVE_FORK )
check_cxx_symbol_exists ( gethrtimei sys/time.h HAVE_GETHRTIME )
check_cxx_symbol_exists ( mkdtemp stdlib.h HAVE_MKDTEMP )
check_cxx_symbol_exists ( accept4 sys/socket.h HAVE_ACCEPT4 )
check_cxx_symbol_exists ( strnlen string.h HAVE_STRNLEN )
2019-12-11 13:33:00 +01:00
check_cxx_symbol_exists ( strlcpy string.h ZMQ_HAVE_STRLCPY )
2019-10-19 14:46:53 +02:00
else ( )
set ( HAVE_STRNLEN 1 )
2018-05-23 16:47:13 +02:00
endif ( )
2017-11-17 18:40:53 +00:00
2018-09-10 00:12:07 +02:00
add_definitions ( -D_REENTRANT -D_THREAD_SAFE )
add_definitions ( -DZMQ_CUSTOM_PLATFORM_HPP )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
option ( ENABLE_EVENTFD "Enable/disable eventfd" ZMQ_HAVE_EVENTFD )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
macro ( zmq_check_cxx_flag_prepend flag )
check_cxx_compiler_flag ( "${flag}" HAVE_FLAG_ ${ flag } )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
if ( HAVE_FLAG_ ${ flag } )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" )
endif ( )
endmacro ( )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
option ( ENABLE_ANALYSIS "Build with static analysis(make take very long)" OFF )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
if ( MSVC )
if ( ENABLE_ANALYSIS )
zmq_check_cxx_flag_prepend ( "/W4" )
zmq_check_cxx_flag_prepend ( "/analyze" )
2018-05-16 09:12:26 +02:00
# C++11/14/17-specific, but maybe possible via conditional defines
2018-09-10 00:12:07 +02:00
zmq_check_cxx_flag_prepend ( "/wd26440" ) # Function '...' can be declared 'noexcept'
zmq_check_cxx_flag_prepend ( "/wd26432" ) # If you define or delete any default operation in the type '...', define or delete them all
zmq_check_cxx_flag_prepend ( "/wd26439" ) # This kind of function may not throw. Declare it 'noexcept'
zmq_check_cxx_flag_prepend ( "/wd26447" ) # The function is declared 'noexcept' but calls function '...' which may throw exceptions
zmq_check_cxx_flag_prepend ( "/wd26433" ) # Function '...' should be marked with 'override'
zmq_check_cxx_flag_prepend ( "/wd26409" ) # Avoid calling new and delete explicitly, use std::make_unique<T> instead
2018-05-16 09:12:26 +02:00
# Requires GSL
2018-09-10 00:12:07 +02:00
zmq_check_cxx_flag_prepend ( "/wd26429" ) # Symbol '...' is never tested for nullness, it can be marked as not_null
zmq_check_cxx_flag_prepend ( "/wd26446" ) # Prefer to use gsl::at()
zmq_check_cxx_flag_prepend ( "/wd26481" ) # Don't use pointer arithmetic. Use span instead
zmq_check_cxx_flag_prepend ( "/wd26472" ) # Don't use a static_cast for arithmetic conversions. Use brace initialization, gsl::narrow_cast or gsl::narow
zmq_check_cxx_flag_prepend ( "/wd26448" ) # Consider using gsl::finally if final action is intended
zmq_check_cxx_flag_prepend ( "/wd26400" ) # Do not assign the result of an allocation or a function call with an owner<T> return value to a raw pointer, use owner<T> instead
zmq_check_cxx_flag_prepend ( "/wd26485" ) # Expression '...': No array to pointer decay(bounds.3)
2018-05-16 09:12:26 +02:00
else ( )
2018-09-10 00:12:07 +02:00
zmq_check_cxx_flag_prepend ( "/W3" )
2018-05-16 09:12:26 +02:00
endif ( )
2015-12-18 20:50:41 +06:00
2018-09-10 00:12:07 +02:00
if ( MSVC_IDE )
set ( MSVC_TOOLSET "-${CMAKE_VS_PLATFORM_TOOLSET}" )
else ( )
set ( MSVC_TOOLSET "" )
endif ( )
else ( )
zmq_check_cxx_flag_prepend ( "-Wall" )
2018-05-23 16:47:13 +02:00
endif ( )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
if ( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
zmq_check_cxx_flag_prepend ( "-Wextra" )
endif ( )
option ( LIBZMQ_PEDANTIC "" ON )
option ( LIBZMQ_WERROR "" OFF )
# TODO: why is -Wno-long-long defined differently than in configure.ac?
if ( NOT MSVC )
zmq_check_cxx_flag_prepend ( "-Wno-long-long" )
zmq_check_cxx_flag_prepend ( "-Wno-uninitialized" )
if ( LIBZMQ_PEDANTIC )
zmq_check_cxx_flag_prepend ( "-pedantic" )
if ( ${ CMAKE_CXX_COMPILER_ID } MATCHES "Intel" )
zmq_check_cxx_flag_prepend ( "-strict-ansi" )
endif ( )
if ( ${ CMAKE_CXX_COMPILER_ID } MATCHES "SunPro" )
zmq_check_cxx_flag_prepend ( "-compat=5" )
2018-05-23 16:47:13 +02:00
endif ( )
2018-09-10 00:12:07 +02:00
endif ( )
endif ( )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
if ( LIBZMQ_WERROR )
if ( MSVC )
zmq_check_cxx_flag_prepend ( "/WX" )
else ( )
zmq_check_cxx_flag_prepend ( "-Werror" )
if ( NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
zmq_check_cxx_flag_prepend ( "-errwarn=%all" )
endif ( )
endif ( )
endif ( )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
if ( CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc" )
zmq_check_cxx_flag_prepend ( "-mcpu=v9" )
endif ( )
2013-01-01 05:22:05 -05:00
2018-09-10 00:12:07 +02:00
if ( ${ CMAKE_CXX_COMPILER_ID } MATCHES "SunPro" )
zmq_check_cxx_flag_prepend ( "-features=zla" )
endif ( )
2012-12-31 17:52:32 -05:00
2019-04-18 13:23:36 +02:00
if ( CMAKE_SYSTEM_NAME MATCHES "SunOS" OR CMAKE_SYSTEM_NAME MATCHES "NetBSD" OR CMAKE_SYSTEM_NAME MATCHES "QNX" )
2018-09-10 00:12:07 +02:00
message ( STATUS "Checking whether atomic operations can be used" )
check_c_source_compiles (
" \
#include <atomic.h> \
\
i n t main ( ) \
{ \
u i n t 3 2 _ t v a l u e ; \
atomic_cas_32 ( &value, 0, 0 ) ; \
r e t u r n 0 ; \
} \
2012-12-31 17:52:32 -05:00
"
2018-09-10 00:12:07 +02:00
H A V E _ A T O M I C _ H )
2019-04-23 08:41:06 -04:00
2018-09-10 00:12:07 +02:00
if ( NOT HAVE_ATOMIC_H )
set ( ZMQ_FORCE_MUTEXES 1 )
endif ( )
endif ( )
2012-12-31 17:52:32 -05:00
2018-10-09 16:49:19 -05:00
if ( NOT ANDROID )
zmq_check_noexcept ( )
endif ( )
2012-12-31 17:52:32 -05:00
#-----------------------------------------------------------------------------
2018-09-10 00:12:07 +02:00
if ( NOT CMAKE_CROSSCOMPILING AND NOT MSVC )
zmq_check_sock_cloexec ( )
zmq_check_o_cloexec ( )
zmq_check_so_bindtodevice ( )
zmq_check_so_keepalive ( )
zmq_check_tcp_keepcnt ( )
zmq_check_tcp_keepidle ( )
zmq_check_tcp_keepintvl ( )
zmq_check_tcp_keepalive ( )
zmq_check_tcp_tipc ( )
zmq_check_pthread_setname ( )
zmq_check_pthread_setaffinity ( )
zmq_check_getrandom ( )
endif ( )
if ( CMAKE_SYSTEM_NAME MATCHES "Linux"
O R C M A K E _ S Y S T E M _ N A M E M A T C H E S " G N U / k F r e e B S D "
O R C M A K E _ S Y S T E M _ N A M E M A T C H E S " G N U / H u r d "
O R CYGWIN )
add_definitions ( -D_GNU_SOURCE )
elseif ( CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
add_definitions ( -D__BSD_VISIBLE )
elseif ( CMAKE_SYSTEM_NAME MATCHES "NetBSD" )
add_definitions ( -D_NETBSD_SOURCE )
elseif ( CMAKE_SYSTEM_NAME MATCHES "OpenBSD" )
add_definitions ( -D_OPENBSD_SOURCE )
elseif ( CMAKE_SYSTEM_NAME MATCHES "SunOS" )
add_definitions ( -D_PTHREADS )
elseif ( CMAKE_SYSTEM_NAME MATCHES "HP-UX" )
add_definitions ( -D_POSIX_C_SOURCE=200112L )
zmq_check_cxx_flag_prepend ( -Ae )
elseif ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
add_definitions ( -D_DARWIN_C_SOURCE )
endif ( )
find_package ( AsciiDoc )
cmake_dependent_option ( WITH_DOC "Build Reference Guide documentation(requires DocBook)" ON
" A S C I I D O C _ F O U N D ; N O T WIN32 " O F F ) # Do not build docs on Windows due to issues with symlinks
if ( MSVC )
if ( WITH_OPENPGM )
#set(OPENPGM_ROOT "" CACHE PATH "Location of OpenPGM")
set ( OPENPGM_VERSION_MAJOR 5 )
set ( OPENPGM_VERSION_MINOR 2 )
set ( OPENPGM_VERSION_MICRO 122 )
if ( CMAKE_CL_64 )
find_path ( OPENPGM_ROOT include/pgm/pgm.h
P A T H S
" [ H K E Y _ L O C A L _ M A C H I N E \ \ S O F T W A R E \ \ M i r u \ \ O p e n P G M $ { O P E N P G M _ V E R S I O N _ M A J O R } . $ { O P E N P G M _ V E R S I O N _ M I N O R } . $ { O P E N P G M _ V E R S I O N _ M I C R O } ] "
N O _ D E F A U L T _ P A T H )
message ( STATUS "OpenPGM x64 detected - ${OPENPGM_ROOT}" )
else ( )
find_path ( OPENPGM_ROOT include/pgm/pgm.h
P A T H S
" [ H K E Y _ L O C A L _ M A C H I N E \ \ S O F T W A R E \ \ W o w 6 4 3 2 N o d e \ \ M i r u \ \ O p e n P G M $ { O P E N P G M _ V E R S I O N _ M A J O R } . $ { O P E N P G M _ V E R S I O N _ M I N O R } . $ { O P E N P G M _ V E R S I O N _ M I C R O } ] "
" [ H K E Y _ L O C A L _ M A C H I N E \ \ S O F T W A R E \ \ M i r u \ \ O p e n P G M $ { O P E N P G M _ V E R S I O N _ M A J O R } . $ { O P E N P G M _ V E R S I O N _ M I N O R } . $ { O P E N P G M _ V E R S I O N _ M I C R O } ] "
N O _ D E F A U L T _ P A T H )
message ( STATUS "OpenPGM x86 detected - ${OPENPGM_ROOT}" )
endif ( )
set ( OPENPGM_INCLUDE_DIRS ${ OPENPGM_ROOT } /include )
set ( OPENPGM_LIBRARY_DIRS ${ OPENPGM_ROOT } /lib )
set ( OPENPGM_LIBRARIES
2015-12-18 20:50:41 +06:00
o p t i m i z e d l i b p g m $ { M S V C _ T O O L S E T } - m t - $ { O P E N P G M _ V E R S I O N _ M A J O R } _ $ { O P E N P G M _ V E R S I O N _ M I N O R } _ $ { O P E N P G M _ V E R S I O N _ M I C R O } . l i b
d e b u g l i b p g m $ { M S V C _ T O O L S E T } - m t - g d - $ { O P E N P G M _ V E R S I O N _ M A J O R } _ $ { O P E N P G M _ V E R S I O N _ M I N O R } _ $ { O P E N P G M _ V E R S I O N _ M I C R O } . l i b )
2018-09-10 00:12:07 +02:00
endif ( )
else ( )
if ( WITH_OPENPGM )
# message(FATAL_ERROR "WITH_OPENPGM not implemented")
2018-01-09 18:15:24 +01:00
2018-09-10 00:12:07 +02:00
if ( NOT OPENPGM_PKGCONFIG_NAME )
set ( OPENPGM_PKGCONFIG_NAME "openpgm-5.2" )
endif ( )
2018-01-09 18:15:24 +01:00
2018-09-10 00:12:07 +02:00
set ( OPENPGM_PKGCONFIG_NAME ${ OPENPGM_PKGCONFIG_NAME } CACHE STRING
2016-11-01 12:31:40 +01:00
" N a m e p k g - c o n f i g s h a l l u s e t o f i n d o p e n p g m l i b r a r i e s a n d i n c l u d e p a t h s "
2018-09-10 00:12:07 +02:00
F O R C E )
2018-01-09 18:15:24 +01:00
2016-11-01 12:31:40 +01:00
find_package ( PkgConfig )
2018-09-10 00:12:07 +02:00
pkg_check_modules ( OPENPGM ${ OPENPGM_PKGCONFIG_NAME } )
2016-11-01 12:31:40 +01:00
2018-09-10 00:12:07 +02:00
if ( OPENPGM_FOUND )
message ( STATUS ${ OPENPGM_PKGCONFIG_NAME } " found" )
2018-12-14 21:45:27 +00:00
set ( pkg_config_names_private "${pkg_config_names_private} ${OPENPGM_PKGCONFIG_NAME}" )
2018-09-10 00:12:07 +02:00
else ( )
message ( FATAL_ERROR
$ { O P E N P G M _ P K G C O N F I G _ N A M E } " n o t f o u n d . o p e n p g m i s s e a r c h d v i a ` p k g - c o n f i g $ { O P E N P G M _ P K G C O N F I G _ N A M E } ` . C o n s i d e r p r o v i d i n g a v a l i d O P E N P G M _ P K G C O N F I G _ N A M E " )
endif ( )
2016-11-01 12:31:40 +01:00
2012-12-31 17:52:32 -05:00
# DSO symbol visibility for openpgm
2018-09-10 00:12:07 +02:00
if ( HAVE_FLAG_VISIBILITY_HIDDEN )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
elseif ( HAVE_FLAG_LDSCOPE_HIDDEN )
2018-01-09 18:15:24 +01:00
2018-09-10 00:12:07 +02:00
endif ( )
endif ( )
endif ( )
2012-12-31 17:52:32 -05:00
2012-10-11 19:31:30 +09:00
#-----------------------------------------------------------------------------
# force off-tree build
2018-09-10 00:12:07 +02:00
if ( ${ CMAKE_CURRENT_SOURCE_DIR } STREQUAL ${ CMAKE_CURRENT_BINARY_DIR } )
message ( FATAL_ERROR " CMake generation is not allowed within the source directory! \
R e m o v e t h e C M a k e C a c h e . t x t f i l e a n d t r y a g a i n f r o m a n o t h e r f o l d e r , e . g . : \
\
r m C M a k e C a c h e . t x t \
m k d i r c m a k e - m a k e \
c d c m a k e - m a k e \
c m a k e . . " )
endif ( )
2012-10-11 19:31:30 +09:00
#-----------------------------------------------------------------------------
# default to Release build
2018-09-10 00:12:07 +02:00
if ( NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
2015-08-21 13:45:59 +10:00
# CMAKE_BUILD_TYPE is not used for multi-configuration generators like Visual Studio/XCode
# which instead use CMAKE_CONFIGURATION_TYPES
2018-09-10 00:12:07 +02:00
set ( CMAKE_BUILD_TYPE Release CACHE STRING
" C h o o s e t h e t y p e o f b u i l d , o p t i o n s a r e : N o n e D e b u g R e l e a s e R e l W i t h D e b I n f o M i n S i z e R e l . "
F O R C E )
endif ( )
2012-10-11 19:31:30 +09:00
2018-06-28 15:51:43 -04:00
#-----------------------------------------------------------------------------
# output directories
zmq_set_with_default ( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${ZeroMQ_BINARY_DIR}/bin" )
if ( UNIX )
set ( zmq_library_directory "lib" )
else ( )
set ( zmq_library_directory "bin" )
endif ( )
zmq_set_with_default ( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${ZeroMQ_BINARY_DIR}/${zmq_library_directory}" )
zmq_set_with_default ( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${ZeroMQ_BINARY_DIR}/lib" )
2015-02-12 21:29:09 +02:00
2012-10-11 19:31:30 +09:00
#-----------------------------------------------------------------------------
# platform specifics
2018-09-10 00:12:07 +02:00
if ( WIN32 )
# Socket limit is 16K(can be raised arbitrarily)
add_definitions ( -DFD_SETSIZE=16384 )
add_definitions ( -D_CRT_SECURE_NO_WARNINGS )
add_definitions ( -D_WINSOCK_DEPRECATED_NO_WARNINGS )
endif ( )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
if ( MSVC )
2012-12-31 17:52:32 -05:00
# Parallel make.
2018-09-10 00:12:07 +02:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP" )
2012-10-11 19:31:30 +09:00
2018-04-04 11:48:36 +02:00
# Compile the static lib with debug information included
2018-08-16 11:39:40 +02:00
# note: we assume here that the default flags contain some /Z flag
2019-09-04 19:41:34 +02:00
string ( REGEX REPLACE "/Z.[^:]" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" )
string ( REGEX REPLACE "/Z.[^:]" "/Z7" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
2018-04-04 11:48:36 +02:00
2012-12-31 17:52:32 -05:00
# Optimization flags.
# http://msdn.microsoft.com/en-us/magazine/cc301698.aspx
2018-09-10 00:12:07 +02:00
if ( NOT ${ CMAKE_BUILD_TYPE } MATCHES "Debug" )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GL" )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG" )
set ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LTCG" )
set ( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /LTCG" )
endif ( )
endif ( )
2012-10-12 18:18:04 +00:00
2012-10-11 19:31:30 +09:00
#-----------------------------------------------------------------------------
# source files
2018-09-10 00:12:07 +02:00
set ( cxx-sources
p r e c o m p i l e d . c p p
a d d r e s s . c p p
c l i e n t . c p p
c l o c k . c p p
c t x . c p p
c u r v e _ m e c h a n i s m _ b a s e . c p p
c u r v e _ c l i e n t . c p p
c u r v e _ s e r v e r . c p p
d e a l e r . c p p
d e v p o l l . c p p
d g r a m . c p p
d i s t . c p p
2019-02-01 05:43:45 -05:00
e n d p o i n t . c p p
2018-09-10 00:12:07 +02:00
e p o l l . c p p
e r r . c p p
f q . c p p
i o _ o b j e c t . c p p
i o _ t h r e a d . c p p
i p . c p p
i p c _ a d d r e s s . c p p
i p c _ c o n n e c t e r . c p p
i p c _ l i s t e n e r . c p p
k q u e u e . c p p
l b . c p p
m a i l b o x . c p p
m a i l b o x _ s a f e . c p p
m e c h a n i s m . c p p
m e c h a n i s m _ b a s e . c p p
m e t a d a t a . c p p
m s g . c p p
m t r i e . c p p
2019-02-02 14:31:00 +01:00
n o r m _ e n g i n e . c p p
2018-09-10 00:12:07 +02:00
o b j e c t . c p p
o p t i o n s . c p p
o w n . c p p
n u l l _ m e c h a n i s m . c p p
p a i r . c p p
p g m _ r e c e i v e r . c p p
p g m _ s e n d e r . c p p
p g m _ s o c k e t . c p p
p i p e . c p p
p l a i n _ c l i e n t . c p p
p l a i n _ s e r v e r . c p p
p o l l . c p p
p o l l e r _ b a s e . c p p
p o l l i n g _ u t i l . c p p
p o l l s e t . c p p
p r o x y . c p p
p u b . c p p
p u l l . c p p
p u s h . c p p
r a n d o m . c p p
r a w _ e n c o d e r . c p p
r a w _ d e c o d e r . c p p
2019-07-17 17:57:44 +03:00
r a w _ e n g i n e . c p p
2018-09-10 00:12:07 +02:00
r e a p e r . c p p
r e p . c p p
r e q . c p p
r o u t e r . c p p
s e l e c t . c p p
s e r v e r . c p p
s e s s i o n _ b a s e . c p p
s i g n a l e r . c p p
s o c k e t _ b a s e . c p p
s o c k s . c p p
s o c k s _ c o n n e c t e r . c p p
s t r e a m . c p p
2019-07-17 17:57:44 +03:00
s t r e a m _ e n g i n e _ b a s e . c p p
2018-09-10 00:12:07 +02:00
s u b . c p p
t c p . c p p
t c p _ a d d r e s s . c p p
t c p _ c o n n e c t e r . c p p
t c p _ l i s t e n e r . c p p
t h r e a d . c p p
t r i e . c p p
2018-10-23 07:29:56 -04:00
r a d i x _ t r e e . c p p
2018-09-10 00:12:07 +02:00
v 1 _ d e c o d e r . c p p
v 1 _ e n c o d e r . c p p
v 2 _ d e c o d e r . c p p
v 2 _ e n c o d e r . c p p
x p u b . c p p
x s u b . c p p
z m q . c p p
z m q _ u t i l s . c p p
d e c o d e r _ a l l o c a t o r s . c p p
s o c k e t _ p o l l e r . c p p
t i m e r s . c p p
c o n f i g . h p p
r a d i o . c p p
d i s h . c p p
u d p _ e n g i n e . c p p
u d p _ a d d r e s s . c p p
s c a t t e r . c p p
g a t h e r . c p p
i p _ r e s o l v e r . c p p
z a p _ c l i e n t . c p p
2019-07-17 17:57:44 +03:00
z m t p _ e n g i n e . c p p
2018-09-10 00:12:07 +02:00
# at least for VS, the header files must also be listed
a d d r e s s . h p p
a r r a y . h p p
a t o m i c _ c o u n t e r . h p p
a t o m i c _ p t r . h p p
b l o b . h p p
c l i e n t . h p p
c l o c k . h p p
c o m m a n d . h p p
c o n d i t i o n _ v a r i a b l e . h p p
c o n f i g . h p p
c t x . h p p
c u r v e _ c l i e n t . h p p
c u r v e _ c l i e n t _ t o o l s . h p p
c u r v e _ m e c h a n i s m _ b a s e . h p p
c u r v e _ s e r v e r . h p p
d b u f f e r . h p p
d e a l e r . h p p
d e c o d e r . h p p
d e c o d e r _ a l l o c a t o r s . h p p
d e v p o l l . h p p
d g r a m . h p p
d i s h . h p p
d i s t . h p p
e n c o d e r . h p p
2019-02-01 05:43:45 -05:00
e n d p o i n t . h p p
2018-09-10 00:12:07 +02:00
e p o l l . h p p
e r r . h p p
f d . h p p
f q . h p p
g a t h e r . h p p
g e n e r i c _ m t r i e . h p p
g e n e r i c _ m t r i e _ i m p l . h p p
g s s a p i _ c l i e n t . h p p
g s s a p i _ m e c h a n i s m _ b a s e . h p p
g s s a p i _ s e r v e r . h p p
i _ d e c o d e r . h p p
i _ e n c o d e r . h p p
i _ e n g i n e . h p p
i _ m a i l b o x . h p p
i _ p o l l _ e v e n t s . h p p
i o _ o b j e c t . h p p
i o _ t h r e a d . h p p
i p . h p p
i p c _ a d d r e s s . h p p
i p c _ c o n n e c t e r . h p p
i p c _ l i s t e n e r . h p p
k q u e u e . h p p
l b . h p p
l i k e l y . h p p
m a c r o s . h p p
m a i l b o x . h p p
m a i l b o x _ s a f e . h p p
m e c h a n i s m . h p p
m e c h a n i s m _ b a s e . h p p
m e t a d a t a . h p p
m s g . h p p
m t r i e . h p p
m u t e x . h p p
n o r m _ e n g i n e . h p p
n u l l _ m e c h a n i s m . h p p
o b j e c t . h p p
o p t i o n s . h p p
o w n . h p p
p a i r . h p p
p g m _ r e c e i v e r . h p p
p g m _ s e n d e r . h p p
p g m _ s o c k e t . h p p
p i p e . h p p
p l a i n _ c l i e n t . h p p
p l a i n _ c o m m o n . h p p
p l a i n _ s e r v e r . h p p
p o l l . h p p
p o l l e r . h p p
p o l l e r _ b a s e . h p p
p o l l i n g _ u t i l . h p p
p o l l s e t . h p p
p r e c o m p i l e d . h p p
p r o x y . h p p
p u b . h p p
p u l l . h p p
p u s h . h p p
r a d i o . h p p
r a n d o m . h p p
r a w _ d e c o d e r . h p p
r a w _ e n c o d e r . h p p
2019-07-17 17:57:44 +03:00
r a w _ e n g i n e . h p p
2018-09-10 00:12:07 +02:00
r e a p e r . h p p
r e p . h p p
r e q . h p p
r o u t e r . h p p
s c a t t e r . h p p
2019-07-11 12:59:23 +02:00
s e c u r e _ a l l o c a t o r . h p p
2018-09-10 00:12:07 +02:00
s e l e c t . h p p
s e r v e r . h p p
s e s s i o n _ b a s e . h p p
s i g n a l e r . h p p
s o c k e t _ b a s e . h p p
s o c k e t _ p o l l e r . h p p
s o c k s . h p p
s o c k s _ c o n n e c t e r . h p p
s t d i n t . h p p
s t r e a m . h p p
2019-07-17 17:57:44 +03:00
s t r e a m _ e n g i n e _ b a s e . h p p
2019-02-01 04:58:47 -05:00
s t r e a m _ c o n n e c t e r _ b a s e . h p p
s t r e a m _ c o n n e c t e r _ b a s e . c p p
2019-01-31 10:52:51 -05:00
s t r e a m _ l i s t e n e r _ b a s e . h p p
s t r e a m _ l i s t e n e r _ b a s e . c p p
2018-09-10 00:12:07 +02:00
s u b . h p p
t c p . h p p
t c p _ a d d r e s s . h p p
t c p _ c o n n e c t e r . h p p
t c p _ l i s t e n e r . h p p
t h r e a d . h p p
t i m e r s . h p p
t i p c _ a d d r e s s . h p p
t i p c _ c o n n e c t e r . h p p
t i p c _ l i s t e n e r . h p p
t r i e . h p p
u d p _ a d d r e s s . h p p
u d p _ e n g i n e . h p p
v 1 _ d e c o d e r . h p p
v 1 _ e n c o d e r . h p p
v 2 _ d e c o d e r . h p p
v 2 _ e n c o d e r . h p p
v 2 _ p r o t o c o l . h p p
v m c i . h p p
v m c i _ a d d r e s s . h p p
v m c i _ c o n n e c t e r . h p p
v m c i _ l i s t e n e r . h p p
w i n d o w s . h p p
w i r e . h p p
x p u b . h p p
x s u b . h p p
y p i p e . h p p
y p i p e _ b a s e . h p p
y p i p e _ c o n f l a t e . h p p
y q u e u e . h p p
z a p _ c l i e n t . h p p
2019-07-17 17:57:44 +03:00
z m t p _ e n g i n e . h p p
2018-09-10 00:12:07 +02:00
)
if ( MINGW )
2013-01-01 21:04:19 -05:00
# Generate the right type when using -m32 or -m64
2018-09-10 00:12:07 +02:00
macro ( set_rc_arch rc_target )
set ( CMAKE_RC_COMPILER_INIT windres )
enable_language ( RC )
set ( CMAKE_RC_COMPILE_OBJECT
" < C M A K E _ R C _ C O M P I L E R > < F L A G S > - O c o f f - - t a r g e t = $ { r c _ t a r g e t } < D E F I N E S > - i < S O U R C E > - o < O B J E C T > " )
endmacro ( )
if ( NOT CMAKE_SYSTEM_PROCESSOR )
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"
O R C M A K E _ S Y S T E M _ P R O C E S S O R M A T C H E S " i 4 8 6 "
O R C M A K E _ S Y S T E M _ P R O C E S S O R M A T C H E S " i 5 8 6 "
O R C M A K E _ S Y S T E M _ P R O C E S S O R M A T C H E S " i 6 8 6 "
O R C M A K E _ S Y S T E M _ P R O C E S S O R M A T C H E S " x 8 6 "
O R C M A K E _ S Y S T E M _ P R O C E S S O R M A T C H E S " x 8 6 _ 6 4 "
O R C M A K E _ S Y S T E M _ P R O C E S S O R M A T C H E S " a m d 6 4 " )
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set_rc_arch ( "pe-x86-64" )
else ( )
set_rc_arch ( "pe-i386" )
endif ( )
endif ( )
endif ( )
set ( public_headers
i n c l u d e / z m q . h
i n c l u d e / z m q _ u t i l s . h )
set ( readme-docs
A U T H O R S
C O P Y I N G
C O P Y I N G . L E S S E R
N E W S )
2012-10-11 19:31:30 +09:00
#-----------------------------------------------------------------------------
# optional modules
2018-09-10 00:12:07 +02:00
if ( WITH_OPENPGM )
add_definitions ( -DZMQ_HAVE_OPENPGM )
include_directories ( ${ OPENPGM_INCLUDE_DIRS } )
link_directories ( ${ OPENPGM_LIBRARY_DIRS } )
set ( OPTIONAL_LIBRARIES ${ OPENPGM_LIBRARIES } )
endif ( )
2012-10-11 19:31:30 +09:00
2018-09-10 00:12:07 +02:00
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 ( )
2015-12-07 18:19:45 +06:00
2018-09-10 00:12:07 +02:00
if ( ZMQ_HAVE_TIPC )
add_definitions ( -DZMQ_HAVE_TIPC )
list ( APPEND cxx-sources tipc_address.cpp tipc_connecter.cpp tipc_listener.cpp )
endif ( )
2016-04-21 11:33:20 +01:00
2012-10-11 19:31:30 +09:00
#-----------------------------------------------------------------------------
# source generators
2018-09-10 00:12:07 +02:00
foreach ( source ${ cxx-sources } )
list ( APPEND sources ${ CMAKE_CURRENT_SOURCE_DIR } /src/ ${ source } )
endforeach ( )
2012-10-11 19:31:30 +09:00
2018-09-10 00:12:07 +02:00
configure_file ( ${ CMAKE_CURRENT_SOURCE_DIR } /src/version.rc.in ${ CMAKE_CURRENT_BINARY_DIR } /version.rc )
2014-05-01 21:24:20 +02:00
2016-02-11 13:38:02 +01:00
# Delete any src/platform.hpp left by configure
2018-09-10 00:12:07 +02:00
file ( REMOVE ${ CMAKE_CURRENT_SOURCE_DIR } /src/platform.hpp )
2016-02-11 13:38:02 +01:00
2018-09-10 00:12:07 +02:00
configure_file ( ${ CMAKE_CURRENT_SOURCE_DIR } /builds/cmake/platform.hpp.in ${ CMAKE_CURRENT_BINARY_DIR } /platform.hpp )
list ( APPEND sources ${ CMAKE_CURRENT_BINARY_DIR } /platform.hpp )
2013-01-01 02:25:15 -05:00
2018-12-14 21:51:32 +00:00
set ( prefix ${ CMAKE_INSTALL_PREFIX } )
set ( exec_prefix ${ prefix } )
set ( libdir ${ prefix } /lib )
set ( includedir ${ prefix } /include )
set ( VERSION ${ ZMQ_VERSION_MAJOR } . ${ ZMQ_VERSION_MINOR } . ${ ZMQ_VERSION_PATCH } )
configure_file ( ${ CMAKE_CURRENT_SOURCE_DIR } /src/libzmq.pc.in ${ CMAKE_CURRENT_BINARY_DIR } /libzmq.pc @ONLY )
2018-09-10 00:12:07 +02:00
set ( zmq-pkgconfig ${ CMAKE_CURRENT_BINARY_DIR } /libzmq.pc )
2012-10-11 19:31:30 +09:00
2018-09-10 00:12:07 +02:00
if ( NOT ZMQ_BUILD_FRAMEWORK )
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } /libzmq.pc DESTINATION ${ CMAKE_INSTALL_LIBDIR } /pkgconfig )
endif ( )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
if ( MSVC )
if ( CMAKE_CL_64 )
set ( nsis-template ${ CMAKE_CURRENT_SOURCE_DIR } /builds/cmake/NSIS.template64.in )
else ( )
set ( nsis-template ${ CMAKE_CURRENT_SOURCE_DIR } /builds/cmake/NSIS.template32.in )
endif ( )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
add_custom_command (
2013-01-01 06:53:56 -05:00
O U T P U T $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / N S I S . t e m p l a t e . i n
C O M M A N D $ { C M A K E _ C O M M A N D }
A R G S - E
c o p y
$ { n s i s - t e m p l a t e }
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / N S I S . t e m p l a t e . i n
D E P E N D S $ { n s i s - t e m p l a t e } )
2018-09-10 00:12:07 +02:00
endif ( )
2018-11-02 11:10:14 -04:00
option ( WITH_DOCS "Build html docs" ON )
if ( WITH_DOCS )
file ( MAKE_DIRECTORY ${ CMAKE_CURRENT_BINARY_DIR } /doc )
file ( GLOB docs RELATIVE ${ CMAKE_CURRENT_BINARY_DIR } / "${CMAKE_CURRENT_SOURCE_DIR}/doc/*.txt" )
set ( html-docs )
foreach ( txt ${ docs } )
string ( REGEX REPLACE ".*/(.*)\\.txt" "\\1.html" html ${ txt } )
set ( src ${ txt } )
set ( dst doc/ ${ html } )
if ( WITH_DOC )
add_custom_command (
O U T P U T $ { d s t }
C O M M A N D $ { A S C I I D O C _ E X E C U T A B L E }
- d m a n p a g e
- b x h t m l 1 1
- f $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / d o c / a s c i i d o c . c o n f
- a z m q _ v e r s i o n = $ { Z M Q _ V E R S I O N }
- o $ { d s t }
$ { s r c }
D E P E N D S $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { s r c }
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R }
C O M M E N T " G e n e r a t i n g $ { h t m l } " )
list ( APPEND html-docs ${ CMAKE_CURRENT_BINARY_DIR } / ${ dst } )
endif ( )
endforeach ( )
endif ( )
2018-09-10 00:12:07 +02:00
if ( ZMQ_BUILD_FRAMEWORK )
add_custom_command (
T A R G E T l i b z m q
P O S T _ B U I L D
C O M M A N D $ { C M A K E _ C O M M A N D }
A R G S - E m a k e _ d i r e c t o r y " $ { C M A K E _ L I B R A R Y _ O U T P U T _ P A T H } / Z e r o M Q . f r a m e w o r k / V e r s i o n s / $ { Z M Q _ V E R S I O N } / M a c O S "
C O M M E N T " P e r f t o o l s " )
endif ( )
2019-08-21 14:02:31 +02:00
option ( ENABLE_PRECOMPILED "Enable precompiled headers, if possible" ON )
if ( MSVC AND ENABLE_PRECOMPILED )
2018-09-10 00:12:07 +02:00
# default for all sources is to use precompiled headers
foreach ( source ${ sources } )
# C and C++ can not use the same precompiled header
2019-05-06 20:19:50 +02:00
if ( ${ source } MATCHES ".cpp$" AND NOT ${ source } STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/src/precompiled.cpp" )
2018-09-10 00:12:07 +02:00
set_source_files_properties ( ${ source }
2016-03-06 06:23:26 -06:00
P R O P E R T I E S
2018-09-10 00:12:07 +02:00
C O M P I L E _ F L A G S " / Y u p r e c o m p i l e d . h p p "
O B J E C T _ D E P E N D S p r e c o m p i l e d . h p p )
endif ( )
endforeach ( )
# create precompiled header
set_source_files_properties ( ${ CMAKE_CURRENT_SOURCE_DIR } /src/precompiled.cpp
P R O P E R T I E S
C O M P I L E _ F L A G S " / Y c p r e c o m p i l e d . h p p "
O B J E C T _ O U T P U T S p r e c o m p i l e d . h p p )
endif ( )
2016-03-06 06:23:26 -06:00
2012-10-11 19:31:30 +09:00
#-----------------------------------------------------------------------------
# output
2017-04-17 18:26:04 -04:00
option ( BUILD_SHARED "Whether or not to build the shared object" ON )
option ( BUILD_STATIC "Whether or not to build the static archive" ON )
list ( APPEND target_outputs "" )
2018-09-10 00:12:07 +02:00
if ( BUILD_SHARED )
2017-04-24 15:57:14 +02:00
list ( APPEND target_outputs "libzmq" )
2017-04-17 18:26:04 -04:00
endif ( )
2018-09-10 00:12:07 +02:00
if ( BUILD_STATIC )
2017-04-24 15:57:14 +02:00
list ( APPEND target_outputs "libzmq-static" )
2017-04-17 18:26:04 -04:00
endif ( )
2012-10-11 19:31:30 +09:00
2018-09-10 00:12:07 +02:00
if ( MSVC )
2017-05-20 14:22:29 -04:00
# Suppress linker warnings caused by #ifdef omission
# of file content.
2018-09-09 23:24:33 +02:00
set ( CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221" )
2018-09-10 00:12:07 +02:00
set ( PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" )
2019-11-13 12:00:47 +01:00
set ( PDB_NAME "lib${ZMQ_OUTPUT_BASENAME}${MSVC_TOOLSET}-mt-gd-${ZMQ_VERSION_MAJOR}_${ZMQ_VERSION_MINOR}_${ZMQ_VERSION_PATCH}" )
2018-05-16 09:12:26 +02:00
function ( enable_vs_guideline_checker target )
set_target_properties ( ${ target } PROPERTIES
2018-09-10 00:12:07 +02:00
V S _ G L O B A L _ E n a b l e C p p C o r e C h e c k t r u e
V S _ G L O B A L _ C o d e A n a l y s i s R u l e S e t C p p C o r e C h e c k R u l e s . r u l e s e t
V S _ G L O B A L _ R u n C o d e A n a l y s i s t r u e )
2018-05-16 09:12:26 +02:00
endfunction ( )
2018-09-10 00:12:07 +02:00
if ( BUILD_SHARED )
add_library ( libzmq SHARED ${ sources } ${ public_headers } ${ html-docs } ${ readme-docs } ${ CMAKE_CURRENT_BINARY_DIR } /NSIS.template.in ${ CMAKE_CURRENT_BINARY_DIR } /version.rc )
2018-05-16 09:12:26 +02:00
if ( ENABLE_ANALYSIS )
2018-09-10 00:12:07 +02:00
enable_vs_guideline_checker ( libzmq )
2018-05-16 09:12:26 +02:00
endif ( )
2018-09-10 00:12:07 +02:00
set_target_properties ( libzmq PROPERTIES
2017-04-17 18:26:04 -04:00
P U B L I C _ H E A D E R " $ { p u b l i c _ h e a d e r s } "
R E L E A S E _ P O S T F I X " $ { M S V C _ T O O L S E T } - m t - $ { Z M Q _ V E R S I O N _ M A J O R } _ $ { Z M Q _ V E R S I O N _ M I N O R } _ $ { Z M Q _ V E R S I O N _ P A T C H } "
R E L W I T H D E B I N F O _ P O S T F I X " $ { M S V C _ T O O L S E T } - m t - $ { Z M Q _ V E R S I O N _ M A J O R } _ $ { Z M Q _ V E R S I O N _ M I N O R } _ $ { Z M Q _ V E R S I O N _ P A T C H } "
2016-11-16 17:28:18 +02:00
M I N S I Z E R E L _ P O S T F I X " $ { M S V C _ T O O L S E T } - m t - $ { Z M Q _ V E R S I O N _ M A J O R } _ $ { Z M Q _ V E R S I O N _ M I N O R } _ $ { Z M Q _ V E R S I O N _ P A T C H } "
2017-04-17 18:26:04 -04:00
D E B U G _ P O S T F I X " $ { M S V C _ T O O L S E T } - m t - g d - $ { Z M Q _ V E R S I O N _ M A J O R } _ $ { Z M Q _ V E R S I O N _ M I N O R } _ $ { Z M Q _ V E R S I O N _ P A T C H } "
2018-06-30 06:27:08 +01:00
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ R U N T I M E _ O U T P U T _ D I R E C T O R Y } "
2017-04-17 18:26:04 -04:00
C O M P I L E _ D E F I N I T I O N S " D L L _ E X P O R T "
2019-11-13 12:00:47 +01:00
O U T P U T _ N A M E " l i b $ { Z M Q _ O U T P U T _ B A S E N A M E } " )
2019-12-06 14:27:24 +01:00
if ( ZMQ_HAVE_WINDOWS_UWP )
set_target_properties ( libzmq PROPERTIES LINK_FLAGS_DEBUG "/OPT:NOICF /OPT:NOREF" )
endif ( )
2017-04-17 18:26:04 -04:00
endif ( )
2018-01-09 18:15:24 +01:00
2018-09-10 00:12:07 +02:00
if ( BUILD_STATIC )
add_library ( libzmq-static STATIC ${ sources } ${ CMAKE_CURRENT_BINARY_DIR } /version.rc )
set_target_properties ( libzmq-static PROPERTIES
2017-04-17 18:26:04 -04:00
P U B L I C _ H E A D E R " $ { p u b l i c _ h e a d e r s } "
R E L E A S E _ P O S T F I X " $ { M S V C _ T O O L S E T } - m t - s - $ { Z M Q _ V E R S I O N _ M A J O R } _ $ { Z M Q _ V E R S I O N _ M I N O R } _ $ { Z M Q _ V E R S I O N _ P A T C H } "
R E L W I T H D E B I N F O _ P O S T F I X " $ { M S V C _ T O O L S E T } - m t - s - $ { Z M Q _ V E R S I O N _ M A J O R } _ $ { Z M Q _ V E R S I O N _ M I N O R } _ $ { Z M Q _ V E R S I O N _ P A T C H } "
2016-11-16 17:28:18 +02:00
M I N S I Z E R E L _ P O S T F I X " $ { M S V C _ T O O L S E T } - m t - s - $ { Z M Q _ V E R S I O N _ M A J O R } _ $ { Z M Q _ V E R S I O N _ M I N O R } _ $ { Z M Q _ V E R S I O N _ P A T C H } "
2017-04-17 18:26:04 -04:00
D E B U G _ P O S T F I X " $ { M S V C _ T O O L S E T } - m t - s g d - $ { Z M Q _ V E R S I O N _ M A J O R } _ $ { Z M Q _ V E R S I O N _ M I N O R } _ $ { Z M Q _ V E R S I O N _ P A T C H } "
C O M P I L E _ F L A G S " / D Z M Q _ S T A T I C "
2019-11-27 08:28:07 +01:00
O U T P U T _ N A M E " l i b $ { Z M Q _ O U T P U T _ B A S E N A M E } " )
2017-04-17 18:26:04 -04:00
endif ( )
2018-09-10 00:12:07 +02:00
else ( )
2017-12-10 17:41:02 +00:00
# avoid building everything twice for shared + static
# only on *nix, as Windows needs different preprocessor defines in static builds
2018-09-10 00:12:07 +02:00
if ( NOT MINGW )
add_library ( objects OBJECT ${ sources } )
2018-03-12 20:20:02 +11:00
set_property ( TARGET objects PROPERTY POSITION_INDEPENDENT_CODE ON )
2018-09-10 00:12:07 +02:00
target_include_directories ( objects
2018-03-12 20:20:02 +11:00
P U B L I C
2018-09-10 00:12:07 +02:00
$ < B U I L D _ I N T E R F A C E : $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / i n c l u d e >
$ < B U I L D _ I N T E R F A C E : $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } >
$ < I N S T A L L _ I N T E R F A C E : i n c l u d e > )
2017-04-17 18:26:04 -04:00
endif ( )
2018-09-10 00:12:07 +02:00
if ( BUILD_SHARED )
if ( MINGW )
add_library ( libzmq SHARED ${ sources } ${ public_headers } ${ html-docs } ${ readme-docs } ${ zmq-pkgconfig } ${ CMAKE_CURRENT_BINARY_DIR } /version.rc )
else ( )
add_library ( libzmq SHARED $< TARGET_OBJECTS:objects > ${ public_headers } ${ html-docs } ${ readme-docs } ${ zmq-pkgconfig } ${ CMAKE_CURRENT_BINARY_DIR } /version.rc )
endif ( )
# NOTE: the SOVERSION and VERSION MUST be the same as the one generated by libtool! It is NOT the same as the version of the package.
set_target_properties ( libzmq PROPERTIES
C O M P I L E _ D E F I N I T I O N S " D L L _ E X P O R T "
2014-07-02 16:51:34 -03:00
P U B L I C _ H E A D E R " $ { p u b l i c _ h e a d e r s } "
2019-07-02 23:43:07 +01:00
V E R S I O N " 5 . 2 . 3 "
2018-09-10 00:12:07 +02:00
S O V E R S I O N " 5 "
2019-11-13 12:00:47 +01:00
O U T P U T _ N A M E " $ { Z M Q _ O U T P U T _ B A S E N A M E } "
2017-04-05 18:46:48 +02:00
P R E F I X " l i b " )
2018-09-10 00:12:07 +02:00
if ( ZMQ_BUILD_FRAMEWORK )
set_target_properties ( libzmq PROPERTIES
F R A M E W O R K T R U E
M A C O S X _ F R A M E W O R K _ I D E N T I F I E R " o r g . z e r o m q . l i b z m q "
M A C O S X _ F R A M E W O R K _ S H O R T _ V E R S I O N _ S T R I N G $ { Z M Q _ V E R S I O N }
M A C O S X _ F R A M E W O R K _ B U N D L E _ V E R S I O N $ { Z M Q _ V E R S I O N } )
set_source_files_properties ( ${ html-docs } PROPERTIES
M A C O S X _ P A C K A G E _ L O C A T I O N d o c )
set_source_files_properties ( ${ readme-docs } PROPERTIES
M A C O S X _ P A C K A G E _ L O C A T I O N e t c )
set_source_files_properties ( ${ zmq-pkgconfig } PROPERTIES
M A C O S X _ P A C K A G E _ L O C A T I O N l i b / p k g c o n f i g )
endif ( )
2017-04-17 18:26:04 -04:00
endif ( )
2017-12-10 17:41:02 +00:00
2018-09-10 00:12:07 +02:00
if ( BUILD_STATIC )
if ( MINGW )
add_library ( libzmq-static STATIC ${ sources } ${ public_headers } ${ html-docs }
$ { r e a d m e - d o c s } $ { z m q - p k g c o n f i g } $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / v e r s i o n . r c )
else ( )
add_library ( libzmq-static STATIC $< TARGET_OBJECTS:objects > ${ public_headers }
$ { h t m l - d o c s } $ { r e a d m e - d o c s } $ { z m q - p k g c o n f i g } $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / v e r s i o n . r c )
endif ( )
2019-04-18 13:23:36 +02:00
if ( CMAKE_SYSTEM_NAME MATCHES "QNX" )
target_link_libraries ( libzmq-static m )
endif ( )
2018-09-10 00:12:07 +02:00
set_target_properties ( libzmq-static PROPERTIES
P U B L I C _ H E A D E R " $ { p u b l i c _ h e a d e r s } "
2019-11-13 12:00:47 +01:00
O U T P U T _ N A M E " $ { Z M Q _ O U T P U T _ B A S E N A M E } "
2018-09-10 00:12:07 +02:00
P R E F I X " l i b " )
endif ( )
endif ( )
2018-03-12 20:20:02 +11:00
2018-09-10 00:12:07 +02:00
if ( BUILD_STATIC )
2018-03-12 20:20:02 +11:00
target_compile_definitions ( libzmq-static
2018-09-10 00:12:07 +02:00
P U B L I C Z M Q _ S T A T I C )
endif ( )
2012-12-31 17:52:32 -05:00
2018-09-10 00:12:07 +02:00
foreach ( target ${ target_outputs } )
target_include_directories ( ${ target }
2017-04-04 10:34:28 +02:00
P U B L I C
$ < B U I L D _ I N T E R F A C E : $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / i n c l u d e >
$ < B U I L D _ I N T E R F A C E : $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } >
2018-09-10 00:12:07 +02:00
$ < I N S T A L L _ I N T E R F A C E : i n c l u d e > )
2017-04-04 10:34:28 +02:00
endforeach ( )
2018-09-10 00:12:07 +02:00
if ( BUILD_SHARED )
target_link_libraries ( libzmq ${ OPTIONAL_LIBRARIES } ${ CMAKE_THREAD_LIBS_INIT } )
2019-09-11 13:09:22 +03:00
if ( NSS3_FOUND )
target_link_libraries ( libzmq ${ NSS3_LIBRARIES } )
endif ( )
2018-09-10 00:12:07 +02:00
if ( SODIUM_FOUND )
target_link_libraries ( libzmq ${ SODIUM_LIBRARIES } )
# On Solaris, libsodium depends on libssp
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "SunOS" )
target_link_libraries ( libzmq ssp )
endif ( )
endif ( )
if ( HAVE_WS2_32 )
target_link_libraries ( libzmq ws2_32 )
elseif ( HAVE_WS2 )
target_link_libraries ( libzmq ws2 )
endif ( )
if ( HAVE_RPCRT4 )
target_link_libraries ( libzmq rpcrt4 )
endif ( )
if ( HAVE_IPHLAPI )
target_link_libraries ( libzmq iphlpapi )
endif ( )
if ( RT_LIBRARY )
target_link_libraries ( libzmq -lrt )
endif ( )
endif ( )
if ( BUILD_STATIC )
target_link_libraries ( libzmq-static ${ OPTIONAL_LIBRARIES } ${ CMAKE_THREAD_LIBS_INIT } )
2019-09-11 13:09:22 +03:00
if ( NSS3_FOUND )
target_link_libraries ( libzmq-static ${ NSS3_LIBRARIES } )
endif ( )
2018-09-10 00:12:07 +02:00
if ( SODIUM_FOUND )
target_link_libraries ( libzmq-static ${ SODIUM_LIBRARIES } )
2018-01-15 00:36:02 +01:00
# On Solaris, libsodium depends on libssp
2018-09-10 00:12:07 +02:00
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "SunOS" )
target_link_libraries ( libzmq-static ssp )
endif ( )
endif ( )
if ( HAVE_WS2_32 )
target_link_libraries ( libzmq-static ws2_32 )
elseif ( HAVE_WS2 )
target_link_libraries ( libzmq-static ws2 )
endif ( )
if ( HAVE_RPCRT4 )
target_link_libraries ( libzmq-static rpcrt4 )
endif ( )
if ( HAVE_IPHLAPI )
target_link_libraries ( libzmq-static iphlpapi )
endif ( )
if ( RT_LIBRARY )
target_link_libraries ( libzmq-static -lrt )
endif ( )
2019-04-18 13:23:36 +02:00
if ( CMAKE_SYSTEM_NAME MATCHES "QNX" )
add_definitions ( -DUNITY_EXCLUDE_MATH_H )
endif ( )
2018-09-10 00:12:07 +02:00
endif ( )
if ( BUILD_SHARED )
set ( perf-tools
l o c a l _ l a t
r e m o t e _ l a t
l o c a l _ t h r
r e m o t e _ t h r
i n p r o c _ l a t
2019-03-07 14:49:25 +01:00
i n p r o c _ t h r
p r o x y _ t h r )
2018-09-10 00:12:07 +02:00
if ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" ) # Why?
option ( WITH_PERF_TOOL "Build with perf-tools" ON )
else ( )
option ( WITH_PERF_TOOL "Build with perf-tools" OFF )
endif ( )
if ( WITH_PERF_TOOL )
foreach ( perf-tool ${ perf-tools } )
add_executable ( ${ perf-tool } perf/ ${ perf-tool } .cpp )
target_link_libraries ( ${ perf-tool } libzmq )
if ( ZMQ_BUILD_FRAMEWORK )
2017-04-17 18:26:04 -04:00
# Copy perf-tools binaries into Framework
2018-09-10 00:12:07 +02:00
add_custom_command (
2017-04-24 15:57:14 +02:00
T A R G E T l i b z m q $ { p e r f - t o o l }
2017-04-17 18:26:04 -04:00
P O S T _ B U I L D
C O M M A N D $ { C M A K E _ C O M M A N D }
A R G S - E c o p y " $ < T A R G E T _ F I L E : $ { p e r f - t o o l } > " " $ { L I B R A R Y _ O U T P U T _ P A T H } / Z e r o M Q . f r a m e w o r k / V e r s i o n s / $ { Z M Q _ V E R S I O N _ S T R I N G } / M a c O S / $ { p e r f - t o o l } "
V E R B A T I M
C O M M E N T " P e r f t o o l s " )
2018-09-10 00:12:07 +02:00
else ( )
install ( TARGETS ${ perf-tool }
R U N T I M E D E S T I N A T I O N b i n
C O M P O N E N T P e r f T o o l s )
endif ( )
2019-12-06 14:27:24 +01:00
if ( ZMQ_HAVE_WINDOWS_UWP )
set_target_properties ( ${ perf-tool } PROPERTIES LINK_FLAGS_DEBUG "/OPT:NOICF /OPT:NOREF" )
endif ( )
2018-09-10 00:12:07 +02:00
endforeach ( )
2018-11-09 05:49:40 -05:00
if ( BUILD_STATIC )
add_executable ( benchmark_radix_tree perf/benchmark_radix_tree.cpp )
target_link_libraries ( benchmark_radix_tree libzmq-static )
target_include_directories ( benchmark_radix_tree
P U B L I C
2019-04-14 16:51:59 +09:00
" $ { C M A K E _ C U R R E N T _ L I S T _ D I R } / s r c " )
2019-12-06 14:27:24 +01:00
if ( ZMQ_HAVE_WINDOWS_UWP )
set_target_properties ( benchmark_radix_tree PROPERTIES LINK_FLAGS_DEBUG "/OPT:NOICF /OPT:NOREF" )
endif ( )
2018-11-09 05:49:40 -05:00
endif ( )
2018-09-10 00:12:07 +02:00
endif ( )
elseif ( WITH_PERF_TOOL )
2017-04-17 18:26:04 -04:00
message ( FATAL_ERROR "Shared library disabled - perf-tools unavailable." )
2018-09-10 00:12:07 +02:00
endif ( )
2012-12-31 17:52:32 -05:00
2014-02-07 17:50:45 +01:00
#-----------------------------------------------------------------------------
# tests
2018-02-14 14:58:58 +02:00
option ( BUILD_TESTS "Whether or not to build the tests" ON )
2018-09-10 00:12:07 +02:00
set ( ZMQ_BUILD_TESTS ${ BUILD_TESTS } CACHE BOOL "Build the tests for ZeroMQ" )
2014-02-07 17:50:45 +01:00
2018-09-10 00:12:07 +02:00
if ( ZMQ_BUILD_TESTS )
enable_testing ( ) # Enable testing only works in root scope
add_subdirectory ( tests )
if ( BUILD_STATIC )
add_subdirectory ( unittests )
else ( )
message ( WARNING "Not building unit tests, since BUILD_STATIC is not enabled" )
endif ( )
endif ( )
2013-12-06 14:28:44 -08:00
2012-11-09 08:48:59 -05:00
#-----------------------------------------------------------------------------
# installer
2012-10-11 19:31:30 +09:00
2018-09-10 00:12:07 +02:00
if ( MSVC AND(BUILD_SHARED OR BUILD_STATIC ) )
install ( TARGETS ${ target_outputs }
E X P O R T $ { P R O J E C T _ N A M E } - t a r g e t s
A R C H I V E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R }
L I B R A R Y D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R }
R U N T I M E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ B I N D I R }
P U B L I C _ H E A D E R D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ I N C L U D E D I R }
C O M P O N E N T S D K )
if ( MSVC_IDE )
install ( FILES ${ PDB_OUTPUT_DIRECTORY } /\ ${ CMAKE_INSTALL_CONFIG_NAME } / ${ PDB_NAME } .pdb DESTINATION ${ CMAKE_INSTALL_BINDIR } COMPONENT SDK OPTIONAL )
2018-04-04 11:48:36 +02:00
else ( )
2018-09-10 00:12:07 +02:00
install ( FILES ${ PDB_OUTPUT_DIRECTORY } / ${ PDB_NAME } .pdb DESTINATION ${ CMAKE_INSTALL_BINDIR } COMPONENT SDK OPTIONAL )
endif ( )
if ( BUILD_SHARED )
install ( TARGETS libzmq
R U N T I M E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ B I N D I R }
P U B L I C _ H E A D E R D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ I N C L U D E D I R }
C O M P O N E N T R u n t i m e )
2018-04-04 11:48:36 +02:00
endif ( )
2018-09-10 00:12:07 +02:00
elseif ( BUILD_SHARED OR BUILD_STATIC )
install ( TARGETS ${ target_outputs }
E X P O R T $ { P R O J E C T _ N A M E } - t a r g e t s
R U N T I M E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ B I N D I R }
A R C H I V E D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R }
L I B R A R Y D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ L I B D I R }
F R A M E W O R K D E S T I N A T I O N " L i b r a r y / F r a m e w o r k s "
P U B L I C _ H E A D E R D E S T I N A T I O N $ { C M A K E _ I N S T A L L _ I N C L U D E D I R } )
endif ( )
# install(FILES ${public_headers}
# DESTINATION include
# COMPONENT SDK)
#if(NOT ZMQ_BUILD_FRAMEWORK)
# file(GLOB private_headers "${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp")
# install(FILES ${sources} ${private_headers} DESTINATION src/zmq
# COMPONENT SourceCode)
#endif()
foreach ( readme ${ readme-docs } )
configure_file ( ${ CMAKE_CURRENT_SOURCE_DIR } / ${ readme } ${ CMAKE_CURRENT_BINARY_DIR } / ${ readme } .txt )
if ( NOT ZMQ_BUILD_FRAMEWORK )
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } / ${ readme } .txt DESTINATION share/zmq )
endif ( )
endforeach ( )
if ( WITH_DOC )
if ( NOT ZMQ_BUILD_FRAMEWORK )
install ( FILES ${ html-docs } DESTINATION doc/zmq COMPONENT RefGuide )
endif ( )
endif ( )
2015-02-12 21:29:09 +02:00
2018-09-10 00:12:07 +02:00
if ( WIN32 )
2017-12-06 12:41:55 -08:00
set ( ZEROMQ_CMAKECONFIG_INSTALL_DIR "CMake" CACHE STRING "install path for ZeroMQConfig.cmake" )
else ( )
# GNUInstallDirs "DATADIR" wrong here; CMake search path wants "share".
set ( ZEROMQ_CMAKECONFIG_INSTALL_DIR "share/cmake/${PROJECT_NAME}" CACHE STRING "install path for ZeroMQConfig.cmake" )
endif ( )
2017-01-06 22:41:29 +01:00
2018-09-10 00:12:07 +02:00
if ( ( NOT CMAKE_VERSION VERSION_LESS 3.0 ) AND ( BUILD_SHARED OR BUILD_STATIC ) )
2017-04-04 10:34:28 +02:00
export ( EXPORT ${ PROJECT_NAME } -targets
2018-09-10 00:12:07 +02:00
F I L E " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { P R O J E C T _ N A M E } T a r g e t s . c m a k e " )
2017-04-04 10:34:28 +02:00
endif ( )
2018-01-12 14:17:15 -08:00
configure_package_config_file ( builds/cmake/ ${ PROJECT_NAME } Config.cmake.in
2018-09-10 00:12:07 +02:00
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { P R O J E C T _ N A M E } C o n f i g . c m a k e "
I N S T A L L _ D E S T I N A T I O N $ { Z E R O M Q _ C M A K E C O N F I G _ I N S T A L L _ D I R } )
2017-01-06 22:41:29 +01:00
write_basic_package_version_file ( ${ CMAKE_CURRENT_BINARY_DIR } / ${ PROJECT_NAME } ConfigVersion.cmake
2018-09-10 00:12:07 +02:00
V E R S I O N $ { Z M Q _ V E R S I O N _ M A J O R } . $ { Z M Q _ V E R S I O N _ M I N O R } . $ { Z M Q _ V E R S I O N _ P A T C H }
C O M P A T I B I L I T Y A n y N e w e r V e r s i o n )
if ( BUILD_SHARED OR BUILD_STATIC )
2018-07-26 17:03:54 -05:00
install ( EXPORT ${ PROJECT_NAME } -targets
2018-09-10 00:12:07 +02:00
F I L E $ { P R O J E C T _ N A M E } T a r g e t s . c m a k e
D E S T I N A T I O N $ { Z E R O M Q _ C M A K E C O N F I G _ I N S T A L L _ D I R } )
2018-07-26 17:03:54 -05:00
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } / ${ PROJECT_NAME } Config.cmake
2018-09-10 00:12:07 +02:00
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { P R O J E C T _ N A M E } C o n f i g V e r s i o n . c m a k e
D E S T I N A T I O N $ { Z E R O M Q _ C M A K E C O N F I G _ I N S T A L L _ D I R } )
2018-07-26 17:03:54 -05:00
endif ( )
2017-01-06 22:41:29 +01:00
2017-01-06 14:29:56 +01:00
option ( ENABLE_CPACK "Enables cpack rules" ON )
2018-09-10 00:12:07 +02:00
if ( MSVC AND ENABLE_CPACK )
2019-07-18 10:01:07 -04:00
if ( ${ CMAKE_BUILD_TYPE } MATCHES "Debug" )
set ( CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY TRUE )
set ( CMAKE_INSTALL_DEBUG_LIBRARIES TRUE )
set ( CMAKE_INSTALL_UCRT_LIBRARIES TRUE )
endif ( )
2018-09-10 00:12:07 +02:00
include ( InstallRequiredSystemLibraries )
2015-02-12 21:29:09 +02:00
2018-09-10 00:12:07 +02:00
if ( CMAKE_CL_64 )
set ( arch_name "x64" )
else ( )
set ( arch_name "x86" )
endif ( )
2015-02-12 21:29:09 +02:00
2018-09-10 00:12:07 +02:00
set ( CPACK_NSIS_DISPLAY_NAME "ZeroMQ ${ZMQ_VERSION_MAJOR}.${ZMQ_VERSION_MINOR}.${ZMQ_VERSION_PATCH}(${arch_name})" )
set ( CPACK_PACKAGE_FILE_NAME "ZeroMQ-${ZMQ_VERSION_MAJOR}.${ZMQ_VERSION_MINOR}.${ZMQ_VERSION_PATCH}-${arch_name}" )
2015-02-12 21:29:09 +02:00
# TODO: I think this part was intended to be used when running cpack
# separately from cmake but I don't know how that works.
#
2018-09-10 00:12:07 +02:00
# macro(add_crt_version version)
# set(rel_dir "${CMAKE_CURRENT_BINARY_DIR}/build/${arch_name}/${version};ZeroMQ;ALL;/")
# set(debug_dir "${CMAKE_CURRENT_BINARY_DIR}/debug/${arch_name}/${version};ZeroMQ;ALL;/")
# if(EXISTS ${rel_dir})
# list(APPEND CPACK_INSTALL_CMAKE_PROJECTS ${rel_dir})
# endif()
# if(EXISTS ${debug_dir})
# list(APPEND CPACK_INSTALL_CMAKE_PROJECTS ${rel_dir})
# endmacro()
# endmacro()
# add_crt_version(v110)
# add_crt_version(v100)
# add_crt_version(v90)
list ( APPEND CMAKE_MODULE_PATH ${ CMAKE_CURRENT_BINARY_DIR } )
set ( CPACK_GENERATOR "NSIS" )
set ( CPACK_PACKAGE_NAME "ZeroMQ" )
set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "ZeroMQ lightweight messaging kernel" )
set ( CPACK_PACKAGE_VENDOR "Miru" )
set ( CPACK_NSIS_CONTACT "Steven McCoy <Steven.McCoy@miru.hk>" )
set ( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_BINARY_DIR}\\\\COPYING.txt" )
# set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_BINARY_DIR}\\\\README.txt")
# set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_CURRENT_BINARY_DIR}\\\\WELCOME.txt")
2015-02-12 21:29:09 +02:00
# There is a bug in NSI that does not handle full unix paths properly. Make
2018-09-10 00:12:07 +02:00
# sure there is at least one set of four(4) backslashes.
set ( CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\installer.ico" )
set ( CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\installer.ico" )
set ( CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\branding.bmp" )
set ( CPACK_NSIS_COMPRESSOR "/SOLID lzma" )
set ( CPACK_PACKAGE_VERSION ${ ZMQ_VERSION } )
set ( CPACK_PACKAGE_VERSION_MAJOR ${ ZMQ_VERSION_MAJOR } )
set ( CPACK_PACKAGE_VERSION_MINOR ${ ZMQ_VERSION_MINOR } )
set ( CPACK_PACKAGE_VERSION_PATCH ${ ZMQ_VERSION_PATCH } )
# set(CPACK_PACKAGE_INSTALL_DIRECTORY "ZMQ Install Directory")
# set(CPACK_TEMPORARY_DIRECTORY "ZMQ Temporary CPack Directory")
include ( CPack )
cpack_add_component_group ( Development
2015-02-12 21:29:09 +02:00
D I S P L A Y _ N A M E " Z e r o M Q s o f t w a r e d e v e l o p m e n t k i t "
E X P A N D E D )
2018-09-10 00:12:07 +02:00
cpack_add_component ( PerfTools
2015-02-12 21:29:09 +02:00
D I S P L A Y _ N A M E " Z e r o M Q p e r f o r m a n c e t o o l s "
I N S T A L L _ T Y P E S F u l l I n s t a l l D e v I n s t a l l )
2018-09-10 00:12:07 +02:00
cpack_add_component ( SourceCode
2015-02-12 21:29:09 +02:00
D I S P L A Y _ N A M E " Z e r o M Q s o u r c e c o d e "
D I S A B L E D
I N S T A L L _ T Y P E S F u l l I n s t a l l )
2018-09-10 00:12:07 +02:00
cpack_add_component ( SDK
2015-02-12 21:29:09 +02:00
D I S P L A Y _ N A M E " Z e r o M Q h e a d e r s a n d l i b r a r i e s "
I N S T A L L _ T Y P E S F u l l I n s t a l l D e v I n s t a l l
G R O U P D e v e l o p m e n t )
2018-09-10 00:12:07 +02:00
if ( WITH_DOC )
cpack_add_component ( RefGuide
2015-02-12 21:29:09 +02:00
D I S P L A Y _ N A M E " Z e r o M Q r e f e r e n c e g u i d e "
I N S T A L L _ T Y P E S F u l l I n s t a l l D e v I n s t a l l
G R O U P D e v e l o p m e n t )
2018-09-10 00:12:07 +02:00
endif ( )
cpack_add_component ( Runtime
2015-02-12 21:29:09 +02:00
D I S P L A Y _ N A M E " Z e r o M Q r u n t i m e f i l e s "
R E Q U I R E D
I N S T A L L _ T Y P E S F u l l I n s t a l l D e v I n s t a l l M i n I n s t a l l )
2018-09-10 00:12:07 +02:00
cpack_add_install_type ( FullInstall
2015-02-12 21:29:09 +02:00
D I S P L A Y _ N A M E " F u l l i n s t a l l , i n c l u d i n g s o u r c e c o d e " )
2018-09-10 00:12:07 +02:00
cpack_add_install_type ( DevInstall
2015-02-12 21:29:09 +02:00
D I S P L A Y _ N A M E " D e v e l o p e r i n s t a l l , h e a d e r s a n d l i b r a r i e s " )
2018-09-10 00:12:07 +02:00
cpack_add_install_type ( MinInstall
2015-02-12 21:29:09 +02:00
D I S P L A Y _ N A M E " M i n i m a l i n s t a l l , r u n t i m e o n l y " )
2018-09-10 00:12:07 +02:00
endif ( )
2015-02-12 21:29:09 +02:00
# Export this for library to help build this as a sub-project
2018-09-10 00:12:07 +02:00
set ( ZEROMQ_LIBRARY libzmq CACHE STRING "ZeroMQ library" )
2015-02-12 21:29:09 +02:00
# Workaround for MSVS10 to avoid the Dialog Hell
# FIXME: This could be removed with future version of CMake.
2018-09-10 00:12:07 +02:00
if ( MSVC_VERSION EQUAL 1600 )
set ( ZMQ_SLN_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/ZeroMQ.sln" )
if ( EXISTS "${ZMQ_SLN_FILENAME}" )
file ( APPEND "${ZMQ_SLN_FILENAME}" "\n# This should be regenerated!\n" )
endif ( )
endif ( )
2018-02-01 14:18:02 +01:00
2019-04-23 08:54:40 -04:00
# this cannot be moved, as it does not only contain function/macro definitions
2018-02-01 14:18:02 +01:00
include ( ClangFormat )