CMakeLists.txt 6.89 KB
Newer Older
1
# CMake build script for ZeroMQ tests
2
cmake_minimum_required(VERSION "2.8.1")
3

4
# On Windows: solution file will be called tests.sln
5
PROJECT(tests)
6 7

set(tests
8
        test_ancillaries
9 10 11 12 13 14
        test_system
        test_pair_inproc
        test_pair_tcp
        test_reqrep_inproc
        test_reqrep_tcp
        test_hwm
15
        test_hwm_pubsub
16 17 18 19
        test_reqrep_device
        test_sub_forward
        test_invalid_rep
        test_msg_flags
20
        test_msg_ffn
21 22 23 24 25 26 27 28 29 30
        test_connect_resolve
        test_immediate
        test_last_endpoint
        test_term_endpoint
        test_router_mandatory
        test_probe_router
        test_stream
        test_stream_empty
        test_stream_disconnect
        test_disconnect_inproc
Dylan Cali's avatar
Dylan Cali committed
31 32
        test_unbind_inproc
        test_unbind_wildcard
33 34 35 36
        test_ctx_options
        test_ctx_destroy
        test_security_null
        test_security_plain
37
        test_security_zap
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
        test_iov
        test_spec_req
        test_spec_rep
        test_spec_dealer
        test_spec_router
        test_spec_pushpull
        test_req_correlate
        test_req_relaxed
        test_conflate
        test_inproc_connect
        test_issue_566
        test_shutdown_stress
        test_timeo
        test_many_sockets
        test_diffserv
        test_connect_rid
54
        test_xpub_nodrop
55
        test_pub_invert_matching
56
        test_setsockopt
57
        test_sockopt_hwm
Jonathan Reams's avatar
Jonathan Reams committed
58
        test_heartbeats
59 60 61 62 63 64 65 66 67
        test_atomics
        test_bind_src_address
        test_capabilities
        test_metadata
        test_router_handover
        test_srcfd
        test_stream_timeout
        test_xpub_manual
        test_xpub_welcome_msg
68
        test_xpub_verbose
69
        test_base85
70
        test_bind_after_connect_tcp
71
        test_sodium
72
        test_monitor
73
		test_socket_null
74
	test_reconnect_ivl
75
)
76 77 78 79
if(ZMQ_HAVE_CURVE)
  list(APPEND tests 
          test_security_curve)
endif()
80 81
if(NOT WIN32)
  list(APPEND tests
82
          test_ipc_wildcard
83
          test_pair_ipc
84
          test_rebind_ipc
85 86
          test_reqrep_ipc
          test_proxy
87
          test_proxy_single_socket
88
          test_proxy_terminate
89
          test_getsockopt_memset
90
          test_filter_ipc
91 92
          test_stream_exceeds_buffer
          test_router_mandatory_hwm
93 94
          test_use_fd_ipc
          test_use_fd_tcp
95
          test_zmq_poll_fd
96 97 98 99
  )
  if(HAVE_FORK)
    list(APPEND tests test_fork)
  endif()
100 101 102 103
  if(CMAKE_SYSTEM_NAME MATCHES "Linux")
    list(APPEND tests
          test_abstract_ipc
    )
104 105
    if(ZMQ_HAVE_TIPC)
      list(APPEND tests
106
            test_address_tipc
107 108 109 110 111 112 113 114 115 116
            test_pair_tipc
            test_reqrep_device_tipc
            test_reqrep_tipc
            test_router_mandatory_tipc
            test_sub_forward_tipc
            test_connect_delay_tipc
            test_shutdown_stress_tipc
            test_term_endpoint_tipc
      )
    endif()
117
  endif()
118
endif()
Ilya Kulakov's avatar
Ilya Kulakov committed
119 120 121 122 123 124 125

if(WITH_VMCI)
  list(APPEND tests
          test_pair_vmci
          test_reqrep_vmci
  )
endif()
126

127 128 129

IF (ENABLE_DRAFTS)
    list(APPEND tests
130
        test_poller
131 132
        test_thread_safe
        test_client_server
133
        test_timers
134
        test_radio_dish
135
        test_scatter_gather
136
        test_dgram
137
        test_app_meta
138 139 140
    )
ENDIF (ENABLE_DRAFTS)

141 142 143
# add location of platform.hpp for Windows builds
if(WIN32)
    add_definitions(-DZMQ_CUSTOM_PLATFORM_HPP)
144
    add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS)
145
    # Same name on 64bit systems
146
    link_libraries(ws2_32.lib)
147 148
endif()

sigiesec's avatar
sigiesec committed
149 150 151 152 153 154 155
add_library (unity 
    STATIC 
    "${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.c" 
    "${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.h" 
    "${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity_internals.h")
set_target_properties (unity PROPERTIES
    PUBLIC_HEADER "${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.h")
156
target_compile_definitions (unity PUBLIC "UNITY_USE_COMMAND_LINE_ARGS" "UNITY_EXCLUDE_FLOAT")
sigiesec's avatar
sigiesec committed
157 158 159
target_include_directories (unity
    PUBLIC "${CMAKE_CURRENT_LIST_DIR}/../external/unity")

Kachanovskiy's avatar
Kachanovskiy committed
160 161 162 163
IF (MSVC_VERSION LESS 1700)
    SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_LIST_DIR}/../external/unity/unity.c" PROPERTIES LANGUAGE CXX)
ENDIF()

164
# add library and include dirs for all targets
165
if (BUILD_SHARED)
sigiesec's avatar
sigiesec committed
166
link_libraries(libzmq ${OPTIONAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} unity)
167
else ()
sigiesec's avatar
sigiesec committed
168
link_libraries(libzmq-static ${OPTIONAL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} unity)
169 170
endif ()
include_directories("${CMAKE_SOURCE_DIR}/../include" "${CMAKE_BINARY_DIR}")
171

172
foreach(test ${tests})
173 174 175 176 177 178 179 180 181 182 183 184
  # target_sources not supported before CMake 3.1
  if (ZMQ_HAVE_CURVE AND ${test} MATCHES test_security_curve)
    add_executable(${test} ${test}.cpp
        "../src/tweetnacl.c"
        "../src/err.cpp"
        "../src/random.cpp"
        "../src/clock.cpp"
        "testutil_security.hpp")
  elseif (${test} MATCHES test_security_zap)
    add_executable(${test} ${test}.cpp
        "testutil_security.hpp")
  else ()
185
    add_executable(${test} ${test}.cpp "testutil.hpp" "testutil_unity.hpp")
186
  endif ()
187
  if(WIN32)
188 189 190 191 192 193
    # This is the output for Debug dynamic builds on Visual Studio 6.0
    # You should provide the correct directory, don't know how to do it automatically
    find_path(LIBZMQ_PATH "libzmq.lib" PATHS "../bin/Win32/Debug/v120/dynamic")
    if(NOT ${LIBZMQ_PATH} STREQUAL "LIBZMQ_PATH-NOTFOUND")
        SET_TARGET_PROPERTIES( ${test} PROPERTIES LINK_FLAGS "/LIBPATH:${LIBZMQ_PATH}" )
    endif()
194
  else()
195
    # per-test directories not generated on OS X / Darwin
196
    if (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang.*")
197 198
        link_directories(${test} PRIVATE "${CMAKE_SOURCE_DIR}/../lib")
    endif()
199
  endif()
200

201

202
  if(RT_LIBRARY)
Doron Somech's avatar
Doron Somech committed
203
    target_link_libraries(${test} ${RT_LIBRARY} )
204 205
  endif()
  if(WIN32)
Doron Somech's avatar
Doron Somech committed
206
    add_test(NAME ${test} WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH} COMMAND ${test})
207
  else()
Doron Somech's avatar
Doron Somech committed
208
    add_test(NAME ${test} COMMAND ${test})
209
  endif()
210
  set_tests_properties(${test} PROPERTIES TIMEOUT 10)
211
  set_tests_properties(${test} PROPERTIES SKIP_RETURN_CODE 77)
212 213
endforeach()

214
#override timeout for these tests
215 216 217 218
if(ZMQ_HAVE_CURVE)
  set_tests_properties(test_security_curve PROPERTIES TIMEOUT 60)
endif()

219 220 221 222 223
if(WIN32 AND ${POLLER} MATCHES "poll")
  set_tests_properties(test_many_sockets PROPERTIES TIMEOUT 30)
  set_tests_properties(test_immediate PROPERTIES TIMEOUT 30)
endif()

224
#add additional required flags
225 226
#ZMQ_USE_TWEETNACL will already be defined when not using sodium
if(ZMQ_HAVE_CURVE AND NOT ZMQ_USE_TWEETNACL)
227 228
  target_compile_definitions(test_security_curve PRIVATE "-DZMQ_USE_TWEETNACL")
endif()
229

230 231
set_tests_properties(test_security_zap PROPERTIES TIMEOUT 60)

232 233 234 235 236 237 238 239 240 241
#Check whether all tests in the current folder are present
file(READ "${CMAKE_CURRENT_LIST_FILE}" CURRENT_LIST_FILE_CONTENT)
file(GLOB ALL_TEST_SOURCES "test_*.cpp")
foreach(TEST_SOURCE ${ALL_TEST_SOURCES})
  get_filename_component(TESTNAME "${TEST_SOURCE}" NAME_WE)
  string(REGEX MATCH "${TESTNAME}" MATCH_TESTNAME "${CURRENT_LIST_FILE_CONTENT}")
  if (NOT MATCH_TESTNAME)
    message(AUTHOR_WARNING "Test '${TESTNAME}' is not known to CTest.")
  endif()
endforeach()