2012-12-31 23:52:32 +01:00
# CMake build script for ZeroMQ
2016-02-11 13:32:01 +01:00
cmake_minimum_required ( VERSION 2.8.12 )
project ( ZeroMQ )
2017-04-04 10:28:38 +02:00
list ( INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}" )
2018-01-13 01:27:24 +01:00
set ( ZMQ_CMAKE_MODULES_DIR ${ CMAKE_CURRENT_SOURCE_DIR } /builds/cmake/Modules )
list ( APPEND CMAKE_MODULE_PATH ${ ZMQ_CMAKE_MODULES_DIR } )
2016-02-11 13:32:01 +01:00
2018-04-25 19:06:21 +02:00
# Apply CMP0042: MACOSX_RPATH is enabled by default
cmake_policy ( SET CMP0042 NEW )
include ( GNUInstallDirs )
if ( ${ CMAKE_SYSTEM_NAME } STREQUAL Darwin )
# Find more information: https://cmake.org/Wiki/CMake_RPATH_handling
# 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 )
if ( "${isSystemDir}" STREQUAL "-1" )
set ( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" )
endif ( )
# Add linker search paths pointing to external dependencies
set ( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
endif ( )
2016-02-19 22:48:43 +01:00
include ( CheckCXXCompilerFlag )
CHECK_CXX_COMPILER_FLAG ( "-std=gnu++11" COMPILER_SUPPORTS_CXX11 )
if ( COMPILER_SUPPORTS_CXX11 )
2016-03-06 13:23:26 +01:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11" )
2016-02-19 22:48:43 +01:00
endif ( )
include ( CheckCCompilerFlag )
CHECK_C_COMPILER_FLAG ( "-std=gnu11" COMPILER_SUPPORTS_C11 )
if ( COMPILER_SUPPORTS_C11 )
2016-03-06 13:23:26 +01:00
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11" )
2016-02-19 22:48:43 +01:00
endif ( )
2018-05-26 21:05:14 +02:00
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 )
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 ( )
endif ( )
2016-09-27 19:39:07 +02:00
# Will be used to add flags to pkg-config useful when apps want to statically link
set ( pkg_config_libs_private "" )
2016-02-11 13:32:01 +01:00
option ( WITH_OPENPGM "Build with support for OpenPGM" OFF )
option ( WITH_VMCI "Build with support for VMware VMCI socket" OFF )
if ( APPLE )
2017-01-27 19:30:18 +01:00
option ( ZMQ_BUILD_FRAMEWORK "Build as OS X framework" OFF )
2016-02-11 13:32:01 +01:00
endif ( )
# Select curve encryption library, defaults to tweetnacl
# To use libsodium instead, use --with-libsodium (must be installed)
# To disable curve, use --disable-curve
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" )
2016-02-11 21:40:34 +01:00
elseif ( WITH_LIBSODIUM )
2016-02-11 13:32:01 +01:00
find_package ( Sodium )
if ( SODIUM_FOUND )
message ( STATUS "Using libsodium for CURVE security" )
include_directories ( ${ SODIUM_INCLUDE_DIRS } )
2016-03-12 15:25:41 +01:00
set ( ZMQ_USE_LIBSODIUM 1 )
2016-02-11 18:06:07 +01:00
set ( ZMQ_HAVE_CURVE 1 )
2016-09-28 00:08:40 +02:00
set ( pkg_config_libs_private "${pkg_config_libs_private} -lsodium" )
2016-02-11 13:32:01 +01:00
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" )
2016-02-11 18:06:07 +01:00
list ( APPEND sources ${ CMAKE_CURRENT_SOURCE_DIR } /src/tweetnacl.c )
set ( ZMQ_USE_TWEETNACL 1 )
set ( ZMQ_HAVE_CURVE 1 )
2016-02-11 13:32:01 +01:00
endif ( )
2016-05-02 20:44:35 +02:00
set ( SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" )
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 )
ADD_DEFINITIONS ( -DZMQ_BUILD_DRAFT_API )
set ( pkg_config_defines "-DZMQ_BUILD_DRAFT_API=1" )
ELSE ( ENABLE_DRAFTS )
set ( pkg_config_defines "" )
ENDIF ( ENABLE_DRAFTS )
2016-05-06 21:50:56 +02:00
option ( WITH_MILITANT "Enable militant assertions" OFF )
if ( WITH_MILITANT )
add_definitions ( -DZMQ_ACT_MILITANT )
endif ( )
2018-05-22 15:57:20 +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
2016-09-21 05:24:26 +02:00
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 ] " )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
include ( CheckFunctionExists )
include ( CheckTypeSize )
2018-05-23 16:47:13 +02:00
if ( NOT MSVC )
if ( POLLER STREQUAL "" )
set ( CMAKE_REQUIRED_INCLUDES sys/event.h )
check_function_exists ( kqueue HAVE_KQUEUE )
set ( CMAKE_REQUIRED_INCLUDES )
if ( HAVE_KQUEUE )
set ( POLLER "kqueue" )
endif ( )
endif ( )
2016-02-11 13:32:01 +01:00
2018-05-23 16:47:13 +02:00
if ( POLLER STREQUAL "" )
set ( CMAKE_REQUIRED_INCLUDES sys/epoll.h )
check_function_exists ( epoll_create HAVE_EPOLL )
set ( CMAKE_REQUIRED_INCLUDES )
if ( HAVE_EPOLL )
set ( POLLER "epoll" )
check_function_exists ( epoll_create1 HAVE_EPOLL_CLOEXEC )
if ( HAVE_EPOLL_CLOEXEC )
set ( ZMQ_IOTHREAD_POLLER_USE_EPOLL_CLOEXEC 1 )
endif ( )
2016-12-26 18:01:36 +01:00
endif ( )
2016-02-11 13:32:01 +01:00
endif ( )
2018-05-23 16:47:13 +02:00
if ( POLLER STREQUAL "" )
set ( CMAKE_REQUIRED_INCLUDES sys/devpoll.h )
check_type_size ( "struct pollfd" DEVPOLL )
set ( CMAKE_REQUIRED_INCLUDES )
if ( HAVE_DEVPOLL )
set ( POLLER "devpoll" )
endif ( )
2016-02-11 13:32:01 +01:00
endif ( )
2018-05-23 16:47:13 +02:00
if ( POLLER STREQUAL "" )
set ( CMAKE_REQUIRED_INCLUDES sys/pollset.h )
check_function_exists ( pollset_create HAVE_POLLSET )
set ( CMAKE_REQUIRED_INCLUDES )
if ( HAVE_POLLSET )
set ( POLLER "pollset" )
endif ( )
endif ( )
2016-09-21 05:24:26 +02:00
2018-05-23 16:47:13 +02:00
if ( POLLER STREQUAL "" )
set ( CMAKE_REQUIRED_INCLUDES poll.h )
check_function_exists ( poll HAVE_POLL )
set ( CMAKE_REQUIRED_INCLUDES )
if ( HAVE_POLL )
set ( POLLER "poll" )
endif ( )
2016-02-11 13:32:01 +01:00
endif ( )
2018-05-23 16:47:13 +02:00
endif ( )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
if ( POLLER STREQUAL "" )
if ( WIN32 )
set ( CMAKE_REQUIRED_INCLUDES winsock2.h )
set ( HAVE_SELECT 1 )
else ( )
set ( CMAKE_REQUIRED_INCLUDES sys/select.h )
check_function_exists ( select HAVE_SELECT )
set ( CMAKE_REQUIRED_INCLUDES )
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 ( )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
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 "
2016-09-21 05:24:26 +02:00
O R P O L L E R S T R E Q U A L " p o l l s e t "
2016-02-11 13:32:01 +01:00
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 " )
2018-05-22 15:57:20 +02:00
message ( STATUS "Using polling method in I/O threads: ${POLLER}" )
2016-02-11 13:32:01 +01:00
string ( TOUPPER ${ POLLER } UPPER_POLLER )
2018-05-22 15:57:20 +02:00
set ( ZMQ_IOTHREAD_POLLER_USE_ ${ UPPER_POLLER } 1 )
2016-02-11 13:32:01 +01:00
else ( )
message ( FATAL_ERROR "Invalid polling method" )
endif ( )
2012-12-31 23:52:32 +01:00
2018-05-23 11:50:42 +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 ( )
2018-05-22 15:57:20 +02:00
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 )
2016-02-11 13:32:01 +01:00
include ( TestZMQVersion )
2017-04-04 10:32:29 +02:00
if ( NOT CMAKE_CROSSCOMPILING )
include ( ZMQSourceRunChecks )
endif ( )
2016-02-11 13:32:01 +01:00
include ( CheckIncludeFiles )
include ( CheckLibraryExists )
include ( CheckCCompilerFlag )
include ( CheckCXXCompilerFlag )
include ( CheckCSourceCompiles )
include ( CheckCSourceRuns )
include ( CMakeDependentOption )
include ( CheckCXXSymbolExists )
2018-01-09 18:15:24 +01:00
include ( CheckSymbolExists )
2015-02-06 16:42:23 +01:00
2018-05-24 15:12:57 +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 )
endif ( )
2017-06-14 15:55:29 +02:00
if ( CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" AND CMAKE_SYSTEM_VERSION STREQUAL "10.0" )
2017-04-04 10:50:33 +02:00
SET ( ZMQ_HAVE_WINDOWS_UWP ON )
ADD_DEFINITIONS ( -D_WIN32_WINNT=_WIN32_WINNT_WIN10 )
endif ( )
2018-05-23 16:47:13 +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 ( )
endif ( )
2013-12-06 19:55:44 +01:00
2018-01-09 18:15:24 +01:00
if ( ZMQ_HAVE_WINDOWS )
# Cannot use check_library_exists because the symbol is always declared as char(*)(void)
set ( CMAKE_REQUIRED_LIBRARIES "ws2_32.lib" )
2018-03-12 10:19:27 +01:00
check_symbol_exists ( WSAStartup "winsock2.h" HAVE_WS2_32 )
2018-01-09 18:15:24 +01:00
set ( CMAKE_REQUIRED_LIBRARIES "rpcrt4.lib" )
2018-03-12 10:19:27 +01:00
check_symbol_exists ( UuidCreateSequential "rpc.h" HAVE_RPCRT4 )
2018-01-09 18:15:24 +01:00
set ( CMAKE_REQUIRED_LIBRARIES "iphlpapi.lib" )
2018-03-12 10:19:27 +01:00
check_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?
check_library_exists ( ws2 fopen "" HAVE_WS2 )
else ( )
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 )
endif ( )
2013-01-23 20:31:02 +01:00
2016-02-11 13:32:01 +01:00
find_library ( RT_LIBRARY rt )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
find_package ( Threads )
2013-01-02 03:04:19 +01:00
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01: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 ( )
if ( NOT HAVE_RPCRT4 )
message ( FATAL_ERROR "Cannot link to rpcrt4" )
endif ( )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
if ( NOT HAVE_IPHLAPI )
message ( FATAL_ERROR "Cannot link to iphlapi" )
endif ( )
endif ( )
2012-12-31 23:52:32 +01:00
2018-05-23 16:47:13 +02:00
if ( NOT MSVC )
set ( CMAKE_REQUIRED_LIBRARIES rt )
check_function_exists ( clock_gettime HAVE_CLOCK_GETTIME )
set ( CMAKE_REQUIRED_LIBRARIES )
2012-12-31 23:52:32 +01:00
2018-05-23 16:47:13 +02:00
set ( CMAKE_REQUIRED_INCLUDES unistd.h )
check_function_exists ( fork HAVE_FORK )
set ( CMAKE_REQUIRED_INCLUDES )
2014-03-17 21:09:10 +01:00
2018-05-23 16:47:13 +02:00
set ( CMAKE_REQUIRED_INCLUDES sys/time.h )
check_function_exists ( gethrtime HAVE_GETHRTIME )
set ( CMAKE_REQUIRED_INCLUDES )
2012-12-31 23:52:32 +01:00
2018-05-23 16:47:13 +02:00
set ( CMAKE_REQUIRED_INCLUDES stdlib.h )
check_function_exists ( mkdtemp HAVE_MKDTEMP )
set ( CMAKE_REQUIRED_INCLUDES )
2016-04-10 23:45:35 +02:00
2018-05-23 16:47:13 +02:00
set ( CMAKE_REQUIRED_INCLUDES sys/socket.h )
check_function_exists ( accept4 HAVE_ACCEPT4 )
set ( CMAKE_REQUIRED_INCLUDES )
endif ( )
2017-11-17 19:40:53 +01:00
2016-02-11 13:32:01 +01:00
add_definitions ( -D_REENTRANT -D_THREAD_SAFE )
2016-02-12 11:31:38 +01:00
add_definitions ( -DZMQ_CUSTOM_PLATFORM_HPP )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
option ( ENABLE_EVENTFD "Enable/disable eventfd" ZMQ_HAVE_EVENTFD )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
macro ( zmq_check_cxx_flag_prepend flag )
check_cxx_compiler_flag ( "${flag}" HAVE_FLAG_ ${ flag } )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
if ( HAVE_FLAG_ ${ flag } )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}" )
endif ( )
endmacro ( )
2012-12-31 23:52:32 +01:00
2018-05-16 09:12:26 +02:00
OPTION ( ENABLE_ANALYSIS "Build with static analysis (make take very long)" OFF )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
if ( MSVC )
2018-05-16 09:12:26 +02:00
if ( ENABLE_ANALYSIS )
zmq_check_cxx_flag_prepend ( "/W4" )
zmq_check_cxx_flag_prepend ( "/analyze" )
# C++11/14/17-specific, but maybe possible via conditional defines
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
# Requires GSL
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)
else ( )
zmq_check_cxx_flag_prepend ( "/W3" )
endif ( )
2015-12-18 15:50:41 +01:00
2016-02-11 13:32:01 +01:00
if ( MSVC_IDE )
set ( MSVC_TOOLSET "-${CMAKE_VS_PLATFORM_TOOLSET}" )
else ( )
set ( MSVC_TOOLSET "" )
endif ( )
else ( )
zmq_check_cxx_flag_prepend ( "-Wall" )
endif ( )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
if ( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
zmq_check_cxx_flag_prepend ( "-Wextra" )
endif ( )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
option ( LIBZMQ_PEDANTIC "" ON )
option ( LIBZMQ_WERROR "" OFF )
2012-12-31 23:52:32 +01:00
2018-05-23 16:47:13 +02:00
# 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" )
2013-01-01 09:26:31 +01:00
2018-05-23 16:47:13 +02:00
if ( LIBZMQ_PEDANTIC )
zmq_check_cxx_flag_prepend ( "-pedantic" )
2013-01-01 09:26:31 +01:00
2018-05-23 16:47:13 +02:00
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" )
endif ( )
endif ( )
endif ( )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
if ( LIBZMQ_WERROR )
2018-05-23 16:47:13 +02:00
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 ( )
2016-02-11 13:32:01 +01:00
endif ( )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
if ( CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc" )
zmq_check_cxx_flag_prepend ( "-mcpu=v9" )
endif ( )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
if ( ${ CMAKE_CXX_COMPILER_ID } MATCHES "SunPro" )
zmq_check_cxx_flag_prepend ( "-features=zla" )
endif ( )
2013-01-01 11:22:05 +01:00
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
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 (
2012-12-31 23:52:32 +01:00
"
#include <atomic.h>
2016-02-11 13:32:01 +01:00
i n t main ( )
2012-12-31 23:52:32 +01:00
{
u i n t 3 2 _ t v a l u e ;
2016-02-11 13:32:01 +01:00
atomic_cas_32 ( &value, 0, 0 ) ;
2012-12-31 23:52:32 +01:00
r e t u r n 0 ;
}
"
H A V E _ A T O M I C _ H )
2016-02-11 13:32:01 +01:00
if ( NOT HAVE_ATOMIC_H )
set ( ZMQ_FORCE_MUTEXES 1 )
endif ( )
endif ( )
2012-12-31 23:52:32 +01:00
2018-05-30 22:03:19 +02:00
zmq_check_noexcept ( )
2012-12-31 23:52:32 +01:00
#-----------------------------------------------------------------------------
2018-05-23 16:47:13 +02:00
if ( NOT CMAKE_CROSSCOMPILING AND NOT MSVC )
2017-04-04 10:32:29 +02:00
zmq_check_sock_cloexec ( )
2017-07-28 00:29:33 +02:00
zmq_check_o_cloexec ( )
Add socket option BINDTODEVICE
Linux now supports Virtual Routing and Forwarding (VRF) as per:
https://www.kernel.org/doc/Documentation/networking/vrf.txt
In order for an application to bind or connect to a socket with an
address in a VRF, they need to first bind the socket to the VRF device:
setsockopt(sd, SOL_SOCKET, SO_BINDTODEVICE, dev, strlen(dev)+1);
Note "dev" is the VRF device, eg. VRF "blue", rather than an interface
enslaved to the VRF.
Add a new socket option, ZMQ_BINDTODEVICE, to bind a socket to a device.
In general, if a socket is bound to a device, eg. an interface, only
packets received from that particular device are processed by the socket.
If device is a VRF device, then subsequent binds/connects to that socket
use addresses in the VRF routing table.
2017-07-28 15:35:09 +02:00
zmq_check_so_bindtodevice ( )
2017-04-04 10:32:29 +02:00
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 ( )
2017-10-16 13:29:03 +02:00
zmq_check_pthread_setaffinity ( )
2017-07-27 22:37:12 +02:00
zmq_check_getrandom ( )
2017-04-04 10:32:29 +02:00
endif ( )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
if ( CMAKE_SYSTEM_NAME MATCHES "Linux"
2012-12-31 23:52:32 +01:00
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 )
2016-02-11 13:32:01 +01:00
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 ( )
set ( CMAKE_PYTHON_VERSION 2.7 2.6 2.5 2.4 )
find_package ( PythonInterp )
find_package ( AsciiDoc )
cmake_dependent_option ( WITH_DOC "Build Reference Guide documentation (requires DocBook)" ON
2016-08-28 12:57:28 +02:00
" P Y T H O N I N T E R P _ F O U N D ; A S C I I D O C _ F O U N D " O F F )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
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
2012-12-31 23:52:32 +01:00
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
2016-02-11 13:32:01 +01:00
)
message ( STATUS "OpenPGM x64 detected - ${OPENPGM_ROOT}" )
else ( )
find_path ( OPENPGM_ROOT include/pgm/pgm.h
2012-12-31 23:52:32 +01:00
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
2016-02-11 13:32:01 +01:00
)
message ( STATUS "OpenPGM x86 detected - ${OPENPGM_ROOT}" )
endif ( CMAKE_CL_64 )
set ( OPENPGM_INCLUDE_DIRS ${ OPENPGM_ROOT } /include )
set ( OPENPGM_LIBRARY_DIRS ${ OPENPGM_ROOT } /lib )
set ( OPENPGM_LIBRARIES
2015-12-18 15:50:41 +01: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 )
2016-02-11 13:32:01 +01:00
endif ( )
else ( )
if ( WITH_OPENPGM )
2016-11-01 12:31:40 +01:00
# message (FATAL_ERROR "WITH_OPENPGM not implemented")
2018-01-09 18:15:24 +01:00
2016-11-01 12:31:40 +01:00
if ( NOT OPENPGM_PKGCONFIG_NAME )
SET ( OPENPGM_PKGCONFIG_NAME "openpgm-5.2" )
endif ( NOT OPENPGM_PKGCONFIG_NAME )
2018-01-09 18:15:24 +01: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 "
F O R C E )
2018-01-09 18:15:24 +01:00
2016-11-01 12:31:40 +01:00
find_package ( PkgConfig )
pkg_check_modules ( OPENPGM ${ OPENPGM_PKGCONFIG_NAME } )
if ( OPENPGM_FOUND )
message ( STATUS ${ OPENPGM_PKGCONFIG_NAME } " found" )
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 ( )
2012-12-31 23:52:32 +01:00
# DSO symbol visibility for openpgm
2016-02-11 13:32:01 +01:00
if ( HAVE_FLAG_VISIBILITY_HIDDEN )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
elseif ( HAVE_FLAG_LDSCOPE_HIDDEN )
2018-01-09 18:15:24 +01:00
2016-02-11 13:32:01 +01:00
endif ( )
endif ( )
endif ( )
2012-12-31 23:52:32 +01:00
2012-10-11 12:31:30 +02:00
#-----------------------------------------------------------------------------
# force off-tree build
2016-02-11 13:32:01 +01:00
if ( ${ CMAKE_CURRENT_SOURCE_DIR } STREQUAL ${ CMAKE_CURRENT_BINARY_DIR } )
message ( FATAL_ERROR " CMake generation is not allowed within the source directory!
2012-10-11 12:31:30 +02:00
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 . :
2012-12-31 23:52:32 +01:00
r m C M a k e C a c h e . t x t
2012-10-11 12:31:30 +02:00
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 . .
" )
2016-02-11 13:32:01 +01:00
endif ( )
2012-10-11 12:31:30 +02:00
#-----------------------------------------------------------------------------
# default to Release build
2016-02-11 13:32:01 +01:00
if ( NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
2015-08-21 05:45:59 +02:00
# CMAKE_BUILD_TYPE is not used for multi-configuration generators like Visual Studio/XCode
# which instead use CMAKE_CONFIGURATION_TYPES
2016-02-11 13:32:01 +01:00
set ( CMAKE_BUILD_TYPE Release CACHE STRING
2012-10-11 12:31:30 +02:00
" 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 )
2016-02-11 13:32:01 +01:00
endif ( )
2012-10-11 12:31:30 +02:00
2016-02-11 13:32:01 +01:00
set ( EXECUTABLE_OUTPUT_PATH ${ CMAKE_CURRENT_BINARY_DIR } /bin )
set ( LIBRARY_OUTPUT_PATH ${ CMAKE_CURRENT_BINARY_DIR } /lib )
2015-02-12 20:29:09 +01:00
2012-10-11 12:31:30 +02:00
#-----------------------------------------------------------------------------
# platform specifics
2015-03-11 10:10:23 +01:00
if ( WIN32 )
2016-02-12 16:30:55 +01:00
# Socket limit is 16K (can be raised arbitrarily)
add_definitions ( -DFD_SETSIZE=16384 )
2016-02-11 13:32:01 +01:00
add_definitions ( -D_CRT_SECURE_NO_WARNINGS )
2016-03-06 13:23:26 +01:00
add_definitions ( -D_WINSOCK_DEPRECATED_NO_WARNINGS )
2015-03-11 10:10:23 +01:00
endif ( )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
if ( MSVC )
2012-12-31 23:52:32 +01:00
# Parallel make.
2016-02-11 13:32:01 +01:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP" )
2018-04-29 21:52:33 +02:00
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP" )
2012-10-11 12:31:30 +02:00
2018-04-04 11:48:36 +02:00
# Compile the static lib with debug information included
string ( REGEX REPLACE "/Z." "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" )
2012-12-31 23:52:32 +01:00
# Optimization flags.
# http://msdn.microsoft.com/en-us/magazine/cc301698.aspx
2016-02-11 13:32:01 +01: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 20:18:04 +02:00
2012-10-11 12:31:30 +02:00
#-----------------------------------------------------------------------------
# source files
2016-02-11 13:32:01 +01:00
set ( cxx-sources
2017-01-06 10:52:20 +01:00
p r e c o m p i l e d . c p p
2012-12-31 23:52:32 +01:00
a d d r e s s . c p p
2015-02-02 15:42:50 +01:00
c l i e n t . c p p
2012-12-31 23:52:32 +01:00
c l o c k . c p p
c t x . c p p
2017-08-18 11:34:22 +02:00
c u r v e _ m e c h a n i s m _ b a s e . c p p
2013-06-18 23:38:24 +02:00
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
2012-12-31 23:52:32 +01:00
d e a l e r . c p p
d e v p o l l . c p p
2016-05-13 04:06:45 +02:00
d g r a m . c p p
2012-12-31 23:52:32 +01:00
d i s t . c p p
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
2015-02-12 15:56:14 +01:00
m a i l b o x _ s a f e . c p p
2013-08-17 14:43:45 +02:00
m e c h a n i s m . c p p
2017-08-18 11:34:22 +02:00
m e c h a n i s m _ b a s e . c p p
2014-05-01 21:35:53 +02:00
m e t a d a t a . c p p
2012-12-31 23:52:32 +01:00
m s g . c p p
m t r i e . c p p
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
2013-08-17 14:43:45 +02:00
n u l l _ m e c h a n i s m . c p p
2012-12-31 23:52:32 +01:00
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
2014-05-12 09:51:13 +02:00
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
2012-12-31 23:52:32 +01:00
p o l l . c p p
p o l l e r _ b a s e . c p p
2018-06-01 16:10:19 +02:00
p o l l i n g _ u t i l . c p p
2016-09-21 05:28:32 +02:00
p o l l s e t . c p p
2012-12-31 23:52:32 +01:00
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
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
2015-02-02 15:42:50 +01:00
s e r v e r . c p p
2012-12-31 23:52:32 +01:00
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
2014-06-23 14:10:43 +02:00
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
2013-07-01 12:52:39 +02:00
s t r e a m . c p p
2012-12-31 23:52:32 +01:00
s t r e a m _ e n g i n e . c p p
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
v 1 _ d e c o d e r . c p p
v 1 _ e n c o d e r . c p p
2013-03-13 20:10:00 +01:00
v 2 _ d e c o d e r . c p p
v 2 _ e n c o d e r . c p p
2012-12-31 23:52:32 +01:00
x p u b . c p p
x s u b . c p p
z m q . c p p
2015-06-14 19:00:52 +02:00
z m q _ u t i l s . c p p
2015-08-21 05:45:59 +02:00
d e c o d e r _ a l l o c a t o r s . c p p
2015-10-18 20:07:23 +02:00
s o c k e t _ p o l l e r . c p p
2015-12-18 11:12:18 +01:00
t i m e r s . c p p
2016-01-27 17:19:14 +01:00
c o n f i g . h p p
r a d i o . c p p
2016-01-29 20:17:11 +01:00
d i s h . c p p
u d p _ e n g i n e . c p p
2016-04-21 12:23:44 +02:00
u d p _ a d d r e s s . c p p
s c a t t e r . c p p
2017-08-16 10:03:11 +02:00
g a t h e r . c p p
2018-04-30 16:56:17 +02:00
i p _ r e s o l v e r . c p p
2018-02-13 08:56:13 +01:00
z a p _ c l i e n t . c p p
# 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
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
2018-02-15 13:09:04 +01:00
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
2018-02-13 08:56:13 +01:00
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
2018-05-28 16:41:44 +02:00
p l a i n _ c o m m o n . h p p
2018-02-13 08:56:13 +01:00
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
2018-06-01 16:10:19 +02:00
p o l l i n g _ u t i l . h p p
2018-02-13 08:56:13 +01:00
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
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
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
s t r e a m _ e n g i n e . h p p
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
)
2013-01-02 03:04:19 +01:00
2016-02-11 13:32:01 +01:00
if ( MINGW )
2013-01-02 03:04:19 +01:00
# Generate the right type when using -m32 or -m64
2016-02-11 13:32:01 +01:00
macro ( set_rc_arch rc_target )
set ( CMAKE_RC_COMPILER_INIT windres )
enable_language ( RC )
set ( CMAKE_RC_COMPILE_OBJECT
2014-04-13 15:25:22 +02:00
" < 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 > " )
2016-02-11 13:32:01 +01:00
endmacro ( )
2013-01-02 03:04:19 +01:00
2016-02-11 13:32:01 +01:00
if ( NOT CMAKE_SYSTEM_PROCESSOR )
set ( CMAKE_SYSTEM_PROCESSOR ${ CMAKE_HOST_SYSTEM_PROCESSOR } )
2013-10-23 20:22:20 +02:00
endif ( )
2016-02-11 13:32:01 +01:00
if ( CMAKE_SYSTEM_PROCESSOR MATCHES "i386"
2013-10-23 20:22:20 +02:00
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 "
2013-01-02 03:04:19 +01:00
# This also happens on x86_64 systems...what a worthless variable
2013-10-23 20:22:20 +02:00
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 " )
2013-01-02 03:04:19 +01:00
2016-02-11 13:32:01 +01:00
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set_rc_arch ( "pe-x86-64" )
else ( )
set_rc_arch ( "pe-i386" )
endif ( )
endif ( )
endif ( )
2013-01-02 03:04:19 +01:00
2016-02-18 10:27:21 +01:00
set ( public_headers include/zmq.h
i n c l u d e / z m q _ u t i l s . h )
2013-01-02 03:04:19 +01:00
2016-02-11 13:32:01 +01:00
set ( readme-docs AUTHORS
2013-01-02 03:04:19 +01:00
C O P Y I N G
C O P Y I N G . L E S S E R
2013-07-14 19:26:55 +02:00
N E W S )
2012-10-11 12:31:30 +02:00
#-----------------------------------------------------------------------------
# optional modules
2016-02-11 13:32:01 +01: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 ( WITH_OPENPGM )
2012-10-11 12:31:30 +02:00
2016-02-11 13:32:01 +01: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 ( WITH_VMCI )
2015-12-07 13:19:45 +01:00
2016-04-21 12:33:20 +02:00
if ( ZMQ_HAVE_TIPC )
add_definitions ( -DZMQ_HAVE_TIPC )
2016-05-04 17:12:27 +02:00
list ( APPEND cxx-sources tipc_address.cpp tipc_connecter.cpp tipc_listener.cpp )
2016-04-21 12:33:20 +02:00
endif ( ZMQ_HAVE_TIPC )
2012-10-11 12:31:30 +02:00
#-----------------------------------------------------------------------------
# source generators
2016-02-11 13:32:01 +01:00
foreach ( source ${ cxx-sources } )
list ( APPEND sources ${ CMAKE_CURRENT_SOURCE_DIR } /src/ ${ source } )
endforeach ( )
2012-10-11 12:31:30 +02:00
2017-11-18 14:46:49 +01: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
file ( REMOVE ${ CMAKE_CURRENT_SOURCE_DIR } /src/platform.hpp )
2016-02-11 13:32:01 +01: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 08:25:15 +01:00
2016-02-11 13:32:01 +01:00
configure_file ( ${ CMAKE_CURRENT_SOURCE_DIR } /src/libzmq.pc.cmake.in ${ CMAKE_CURRENT_BINARY_DIR } /libzmq.pc @ONLY )
set ( zmq-pkgconfig ${ CMAKE_CURRENT_BINARY_DIR } /libzmq.pc )
2012-10-11 12:31:30 +02:00
2016-02-11 13:32:01 +01:00
if ( NOT ZMQ_BUILD_FRAMEWORK )
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } /libzmq.pc DESTINATION lib/pkgconfig )
endif ( )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01: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 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
add_custom_command (
2013-01-01 12:53:56 +01: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 } )
2016-02-11 13:32:01 +01:00
endif ( )
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 } )
2016-08-28 13:00:09 +02:00
string ( REGEX REPLACE ".*/(.*)\\.txt" "\\1.html" html ${ txt } )
2016-02-11 13:32:01 +01:00
set ( src ${ txt } )
set ( dst doc/ ${ html } )
if ( WITH_DOC )
2017-04-28 09:06:45 +02:00
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 } " )
2016-02-11 13:32:01 +01:00
list ( APPEND html-docs ${ CMAKE_CURRENT_BINARY_DIR } / ${ dst } )
endif ( )
endforeach ( )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
if ( ZMQ_BUILD_FRAMEWORK )
add_custom_command (
2017-04-24 15:57:14 +02:00
T A R G E T l i b z m q
2012-12-31 23:52:32 +01: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 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 " )
2016-02-11 13:32:01 +01:00
endif ( )
2012-12-31 23:52:32 +01:00
2016-03-06 13:23:26 +01:00
if ( MSVC )
# default for all sources is to use precompiled headers
2018-05-23 11:50:42 +02:00
foreach ( source ${ sources } )
# C and C++ can not use the same precompiled header
if ( ${ soruce } MATCHES ".cpp$" AND NOT ${ source } STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/src/precompiled.cpp" )
2017-05-17 18:50:01 +02:00
set_source_files_properties ( ${ source }
P R O P E R T I E S
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 ( )
2016-03-06 13:23:26 +01:00
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 "
2017-05-17 18:50:01 +02:00
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
2016-03-06 13:23:26 +01:00
)
endif ( )
2012-10-11 12:31:30 +02:00
#-----------------------------------------------------------------------------
# output
2017-04-18 00:26:04 +02: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 "" )
if ( BUILD_SHARED )
2017-04-24 15:57:14 +02:00
list ( APPEND target_outputs "libzmq" )
2017-04-18 00:26:04 +02:00
endif ( )
if ( BUILD_STATIC )
2017-04-24 15:57:14 +02:00
list ( APPEND target_outputs "libzmq-static" )
2017-04-18 00:26:04 +02:00
endif ( )
2012-10-11 12:31:30 +02:00
2016-02-11 13:32:01 +01:00
if ( MSVC )
2017-05-20 20:22:29 +02:00
# Suppress linker warnings caused by #ifdef omission
# of file content.
set ( CMAKE_STATIC_LINKER_FLAGS /ignore:4221 )
2018-04-04 11:48:36 +02:00
set ( PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin" )
set ( PDB_NAME "libzmq${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
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 )
endfunction ( )
2017-04-18 00:26:04 +02:00
if ( BUILD_SHARED )
2017-12-10 18:41:02 +01:00
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 )
enable_vs_guideline_checker ( libzmq )
endif ( )
2017-04-24 15:57:14 +02:00
set_target_properties ( libzmq PROPERTIES
2017-04-18 00:26:04 +02: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 16:28:18 +01: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-18 00:26:04 +02: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 } "
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 _ C U R R E N T _ B I N A R Y _ D I R } / b i n "
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 "
O U T P U T _ N A M E " l i b z m q " )
endif ( )
2018-01-09 18:15:24 +01:00
2017-04-18 00:26:04 +02:00
if ( BUILD_STATIC )
2017-12-10 18:41:02 +01:00
add_library ( libzmq-static STATIC ${ sources } ${ CMAKE_CURRENT_BINARY_DIR } /version.rc )
2017-04-24 15:57:14 +02:00
set_target_properties ( libzmq-static PROPERTIES
2017-04-18 00:26:04 +02: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 16:28:18 +01: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-18 00:26:04 +02: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 "
O U T P U T _ N A M E " l i b z m q " )
endif ( )
2016-02-11 13:32:01 +01:00
else ( )
2017-12-10 18:41:02 +01:00
# avoid building everything twice for shared + static
# only on *nix, as Windows needs different preprocessor defines in static builds
2018-03-12 10:20:02 +01:00
if ( NOT MINGW )
add_library ( objects OBJECT ${ sources } )
set_property ( TARGET objects PROPERTY POSITION_INDEPENDENT_CODE ON )
target_include_directories ( objects
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 } >
$ < I N S T A L L _ I N T E R F A C E : i n c l u d e >
)
endif ( )
2017-12-10 18:41:02 +01:00
2017-04-18 00:26:04 +02:00
if ( BUILD_SHARED )
2018-03-12 10:20:02 +01:00
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 ( )
2018-01-13 09:31:04 +01:00
# 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.
2017-04-24 15:57:14 +02:00
set_target_properties ( libzmq PROPERTIES
2015-03-11 10:15:40 +01: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 "
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 } "
2018-03-23 20:28:26 +01:00
V E R S I O N " 5 . 1 . 6 "
2018-01-13 09:31:04 +01:00
S O V E R S I O N " 5 "
2017-04-05 18:46:48 +02:00
O U T P U T _ N A M E " z m q "
P R E F I X " l i b " )
2016-02-11 13:32:01 +01:00
if ( ZMQ_BUILD_FRAMEWORK )
2017-04-24 15:57:14 +02:00
set_target_properties ( libzmq PROPERTIES
2015-02-12 20:29:09 +01:00
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 }
2015-03-11 10:15:40 +01:00
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 } )
2016-02-11 13:32:01 +01:00
set_source_files_properties ( ${ html-docs } PROPERTIES
2015-02-12 20:29:09 +01:00
M A C O S X _ P A C K A G E _ L O C A T I O N d o c )
2016-02-11 13:32:01 +01:00
set_source_files_properties ( ${ readme-docs } PROPERTIES
2015-02-12 20:29:09 +01:00
M A C O S X _ P A C K A G E _ L O C A T I O N e t c )
2016-02-11 13:32:01 +01:00
set_source_files_properties ( ${ zmq-pkgconfig } PROPERTIES
2015-02-12 20:29:09 +01:00
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 )
2016-02-11 13:32:01 +01:00
endif ( )
2017-04-18 00:26:04 +02:00
endif ( )
if ( BUILD_STATIC )
2018-03-12 10:20:02 +01:00
if ( MINGW )
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 )
endif ( )
2017-04-24 15:57:14 +02:00
set_target_properties ( libzmq-static PROPERTIES
2014-07-02 21:51:34 +02: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 } "
2017-04-05 18:46:48 +02:00
O U T P U T _ N A M E " z m q "
P R E F I X " l i b " )
2017-04-18 00:26:04 +02:00
endif ( )
2017-12-10 18:41:02 +01:00
2018-03-12 10:20:02 +01:00
endif ( )
if ( BUILD_STATIC )
target_compile_definitions ( libzmq-static
P U B L I C Z M Q _ S T A T I C
2017-12-10 18:41:02 +01:00
)
2016-02-11 13:32:01 +01:00
endif ( )
2012-12-31 23:52:32 +01:00
2017-12-10 18:41:02 +01:00
foreach ( target ${ target_outputs } )
2017-04-04 10:34:28 +02:00
target_include_directories ( ${ target }
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 } >
$ < I N S T A L L _ I N T E R F A C E : i n c l u d e >
)
endforeach ( )
2017-04-18 00:26:04 +02:00
if ( BUILD_SHARED )
2018-01-15 00:36:02 +01:00
target_link_libraries ( libzmq ${ OPTIONAL_LIBRARIES } ${ CMAKE_THREAD_LIBS_INIT } )
2018-04-04 11:48:36 +02:00
2017-04-18 00:26:04 +02:00
if ( SODIUM_FOUND )
2017-04-24 15:57:14 +02:00
target_link_libraries ( libzmq ${ SODIUM_LIBRARIES } )
2018-01-15 00:36:02 +01:00
# On Solaris, libsodium depends on libssp
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "SunOS" )
target_link_libraries ( libzmq ssp )
endif ( )
2017-04-18 00:26:04 +02:00
endif ( )
2018-04-04 11:48:36 +02:00
2017-04-18 00:26:04 +02:00
if ( HAVE_WS2_32 )
2017-04-24 15:57:14 +02:00
target_link_libraries ( libzmq ws2_32 )
2017-04-18 00:26:04 +02:00
elseif ( HAVE_WS2 )
2017-04-24 15:57:14 +02:00
target_link_libraries ( libzmq ws2 )
2017-04-18 00:26:04 +02:00
endif ( )
2012-12-31 23:52:32 +01:00
2017-04-18 00:26:04 +02:00
if ( HAVE_RPCRT4 )
2017-04-24 15:57:14 +02:00
target_link_libraries ( libzmq rpcrt4 )
2017-04-18 00:26:04 +02:00
endif ( )
2014-02-24 20:07:28 +01:00
2017-04-18 00:26:04 +02:00
if ( HAVE_IPHLAPI )
2017-04-24 15:57:14 +02:00
target_link_libraries ( libzmq iphlpapi )
2017-04-18 00:26:04 +02:00
endif ( )
2012-12-31 23:52:32 +01:00
2017-04-18 00:26:04 +02:00
if ( RT_LIBRARY )
2018-01-10 21:07:25 +01:00
target_link_libraries ( libzmq -lrt )
2017-04-18 00:26:04 +02:00
endif ( )
2016-02-11 13:32:01 +01:00
endif ( )
2015-05-06 17:25:26 +02:00
2018-01-15 00:36:02 +01:00
if ( BUILD_STATIC )
target_link_libraries ( libzmq-static ${ OPTIONAL_LIBRARIES } ${ CMAKE_THREAD_LIBS_INIT } )
2018-04-04 11:48:36 +02:00
2018-01-15 00:36:02 +01:00
if ( SODIUM_FOUND )
target_link_libraries ( libzmq-static ${ SODIUM_LIBRARIES } )
# On Solaris, libsodium depends on libssp
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "SunOS" )
target_link_libraries ( libzmq-static ssp )
endif ( )
endif ( )
2018-04-04 11:48:36 +02:00
2018-01-15 00:36:02 +01:00
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 ( )
endif ( )
2017-04-18 00:26:04 +02:00
if ( BUILD_SHARED )
set ( perf-tools local_lat
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
i n p r o c _ t h r )
2012-12-31 23:52:32 +01:00
2017-04-18 00:26:04 +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 ( )
2013-01-23 20:31:02 +01:00
2017-04-18 00:26:04 +02:00
if ( WITH_PERF_TOOL )
foreach ( perf-tool ${ perf-tools } )
add_executable ( ${ perf-tool } perf/ ${ perf-tool } .cpp )
2018-01-15 00:36:02 +01:00
target_link_libraries ( ${ perf-tool } libzmq )
2017-04-18 00:26:04 +02:00
if ( ZMQ_BUILD_FRAMEWORK )
# Copy perf-tools binaries into Framework
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-18 00:26:04 +02: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 " )
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 ( )
endforeach ( )
endif ( )
elseif ( WITH_PERF_TOOL )
message ( FATAL_ERROR "Shared library disabled - perf-tools unavailable." )
2016-02-11 13:32:01 +01:00
endif ( )
2012-12-31 23:52:32 +01:00
2014-02-07 17:50:45 +01:00
#-----------------------------------------------------------------------------
# tests
2018-02-14 13:58:58 +01:00
option ( BUILD_TESTS "Whether or not to build the tests" ON )
set ( ZMQ_BUILD_TESTS ${ BUILD_TESTS } CACHE BOOL "Build the tests for ZeroMQ" )
2014-02-07 17:50:45 +01:00
2016-02-11 13:32:01 +01:00
if ( ZMQ_BUILD_TESTS )
enable_testing ( ) # Enable testing only works in root scope
ADD_SUBDIRECTORY ( tests )
2018-02-08 17:48:15 +01:00
if ( BUILD_STATIC )
add_subdirectory ( unittests )
else ( )
message ( WARNING "Not building unit tests, since BUILD_STATIC is not enabled" )
endif ( )
2016-02-11 13:32:01 +01:00
endif ( )
2013-12-06 23:28:44 +01:00
2012-11-09 14:48:59 +01:00
#-----------------------------------------------------------------------------
# installer
2012-10-11 12:31:30 +02:00
2016-02-11 13:32:01 +01:00
if ( MSVC )
2017-04-18 00:26:04 +02:00
install ( TARGETS ${ target_outputs }
2017-04-04 10:34:28 +02:00
E X P O R T $ { P R O J E C T _ N A M E } - t a r g e t s
2017-01-06 22:41:29 +01:00
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 }
2018-03-12 13:38:46 +01:00
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 }
2017-01-06 22:41:29 +01:00
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 }
2015-02-12 20:29:09 +01:00
C O M P O N E N T S D K )
2018-04-04 11:48:36 +02:00
if ( MSVC_IDE )
install ( FILES ${ PDB_OUTPUT_DIRECTORY } /\ ${ CMAKE_INSTALL_CONFIG_NAME } / ${ PDB_NAME } .pdb DESTINATION ${ CMAKE_INSTALL_BINDIR } COMPONENT SDK OPTIONAL )
else ( )
install ( FILES ${ PDB_OUTPUT_DIRECTORY } / ${ PDB_NAME } .pdb DESTINATION ${ CMAKE_INSTALL_BINDIR } COMPONENT SDK OPTIONAL )
endif ( )
if ( BUILD_SHARED )
2017-04-24 15:57:14 +02:00
install ( TARGETS libzmq
2017-01-06 22:41:29 +01:00
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 }
2015-02-12 20:29:09 +01:00
C O M P O N E N T R u n t i m e )
2016-02-11 13:32:01 +01:00
endif ( )
else ( )
2017-04-18 00:26:04 +02:00
install ( TARGETS ${ target_outputs }
2017-04-04 10:34:28 +02:00
E X P O R T $ { P R O J E C T _ N A M E } - t a r g e t s
2017-01-06 22:41:29 +01:00
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 }
2015-02-12 20:29:09 +01:00
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 "
2017-01-06 22:41:29 +01:00
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 } )
2016-02-11 13:32:01 +01:00
endif ( )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
# install (FILES ${public_headers}
2015-02-12 20:29:09 +01:00
# DESTINATION include
# COMPONENT SDK)
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
#if (NOT ZMQ_BUILD_FRAMEWORK)
# file (GLOB private_headers "${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp")
# install (FILES ${sources} ${private_headers} DESTINATION src/zmq
2015-03-11 09:50:39 +01:00
# COMPONENT SourceCode)
2016-02-11 13:32:01 +01:00
#endif ()
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
foreach ( readme ${ readme-docs } )
configure_file ( ${ CMAKE_CURRENT_SOURCE_DIR } / ${ readme } ${ CMAKE_CURRENT_BINARY_DIR } / ${ readme } .txt )
2012-12-31 23:52:32 +01:00
2016-02-11 13:32:01 +01:00
if ( NOT ZMQ_BUILD_FRAMEWORK )
2017-01-06 14:29:56 +01:00
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } / ${ readme } .txt DESTINATION share/zmq )
2016-02-11 13:32:01 +01:00
endif ( )
endforeach ( )
2012-10-11 12:31:30 +02:00
2016-02-11 13:32:01 +01:00
if ( WITH_DOC )
if ( NOT ZMQ_BUILD_FRAMEWORK )
install ( FILES ${ html-docs } DESTINATION doc/zmq COMPONENT RefGuide )
endif ( )
endif ( )
2015-02-12 20:29:09 +01:00
2017-01-06 22:41:29 +01:00
include ( CMakePackageConfigHelpers )
2017-12-06 21:41:55 +01:00
if ( WIN32 )
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
2017-04-04 10:34:28 +02:00
if ( NOT CMAKE_VERSION VERSION_LESS 3.0 )
export ( EXPORT ${ PROJECT_NAME } -targets
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 " )
endif ( )
2018-01-12 23:17:15 +01:00
configure_package_config_file ( builds/cmake/ ${ PROJECT_NAME } Config.cmake.in
2017-01-06 22:41:29 +01: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 } )
write_basic_package_version_file ( ${ CMAKE_CURRENT_BINARY_DIR } / ${ PROJECT_NAME } ConfigVersion.cmake
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 )
2017-04-04 10:34:28 +02:00
install ( EXPORT ${ PROJECT_NAME } -targets
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 } )
2017-01-06 22:41:29 +01:00
install ( FILES ${ CMAKE_CURRENT_BINARY_DIR } / ${ PROJECT_NAME } Config.cmake
$ { 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 } )
2017-01-06 14:29:56 +01:00
option ( ENABLE_CPACK "Enables cpack rules" ON )
if ( MSVC AND ENABLE_CPACK )
2016-02-11 13:32:01 +01:00
include ( InstallRequiredSystemLibraries )
2015-02-12 20:29:09 +01:00
2016-02-11 13:32:01 +01:00
if ( CMAKE_CL_64 )
set ( arch_name "x64" )
else ( )
set ( arch_name "x86" )
endif ( )
2015-02-12 20:29:09 +01:00
2016-02-11 13:32:01 +01: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 20:29:09 +01: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.
#
2016-02-11 13:32:01 +01: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)
2018-02-02 13:52:51 +01:00
list ( APPEND CMAKE_MODULE_PATH ${ CMAKE_CURRENT_BINARY_DIR } )
2016-02-11 13:32:01 +01:00
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 20:29:09 +01:00
# There is a bug in NSI that does not handle full unix paths properly. Make
2016-02-11 13:32:01 +01: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 20:29:09 +01: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 )
2016-02-11 13:32:01 +01:00
cpack_add_component ( PerfTools
2015-02-12 20:29:09 +01: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 )
2016-02-11 13:32:01 +01:00
cpack_add_component ( SourceCode
2015-02-12 20:29:09 +01: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 )
2016-02-11 13:32:01 +01:00
cpack_add_component ( SDK
2015-02-12 20:29:09 +01: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 )
2016-02-11 13:32:01 +01:00
if ( WITH_DOC )
cpack_add_component ( RefGuide
2015-02-12 20:29:09 +01: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 )
2016-02-11 13:32:01 +01:00
endif ( )
cpack_add_component ( Runtime
2015-02-12 20:29:09 +01: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 )
2016-02-11 13:32:01 +01:00
cpack_add_install_type ( FullInstall
2015-02-12 20:29:09 +01: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 " )
2016-02-11 13:32:01 +01:00
cpack_add_install_type ( DevInstall
2015-02-12 20:29:09 +01: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 " )
2016-02-11 13:32:01 +01:00
cpack_add_install_type ( MinInstall
2015-02-12 20:29:09 +01: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 " )
2016-02-11 13:32:01 +01:00
endif ( )
2015-02-12 20:29:09 +01:00
# Export this for library to help build this as a sub-project
2016-02-11 13:32:01 +01:00
set ( ZEROMQ_LIBRARY libzmq CACHE STRING "ZeroMQ library" )
2015-02-12 20:29:09 +01:00
# Workaround for MSVS10 to avoid the Dialog Hell
# FIXME: This could be removed with future version of CMake.
2016-02-11 13:32:01 +01: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
include ( ClangFormat )