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

# name of Windows project will tests.sln
PROJECT(tests)
6 7 8 9 10 11 12 13

set(tests
        test_system
        test_pair_inproc
        test_pair_tcp
        test_reqrep_inproc
        test_reqrep_tcp
        test_hwm
14
        test_hwm_pubsub
15 16 17 18
        test_reqrep_device
        test_sub_forward
        test_invalid_rep
        test_msg_flags
19
        test_msg_ffn
20 21 22 23 24 25 26 27 28 29
        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
30 31
        test_unbind_inproc
        test_unbind_wildcard
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
        test_ctx_options
        test_ctx_destroy
        test_security_null
        test_security_plain
        test_security_curve
        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
53
        test_xpub_nodrop
54
        test_pub_invert_matching
55 56
        test_thread_safe
        test_client_server
57
        test_setsockopt
58
        test_sockopt_hwm
Jonathan Reams's avatar
Jonathan Reams committed
59
        test_heartbeats
60
        test_poller
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
        test_atomics
        test_bind_src_address
        test_capabilities
        test_ipc_wildcard
        test_metadata
        test_pair_tipc
        test_reqrep_device_tipc
        test_reqrep_tipc
        test_router_handover
        test_router_mandatory_tipc
        test_srcfd
        test_stream_timeout
        test_sub_forward_tipc
        test_xpub_manual
        test_xpub_welcome_msg
somdoron's avatar
somdoron committed
76
        test_timers
somdoron's avatar
somdoron committed
77
        test_radio_dish
78
        test_udp
79 80 81 82 83 84 85 86
)
if(NOT WIN32)
  list(APPEND tests
          test_monitor
          test_pair_ipc
          test_reqrep_ipc
          test_abstract_ipc
          test_proxy
87
          test_proxy_single_socket
88
          test_proxy_terminate
89
          test_getsockopt_memset
90
          test_filter_ipc
91 92 93 94 95
          test_connect_delay_tipc
          test_shutdown_stress_tipc
          test_stream_exceeds_buffer
          test_router_mandatory_hwm
          test_term_endpoint_tipc
96 97
          test_use_fd_ipc
          test_use_fd_tcp
98 99 100 101 102
  )
  if(HAVE_FORK)
    list(APPEND tests test_fork)
  endif()
endif()
Ilya Kulakov's avatar
Ilya Kulakov committed
103 104 105 106 107 108 109

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

111 112 113
# add location of platform.hpp for Windows builds
if(WIN32)
    add_definitions(-DZMQ_CUSTOM_PLATFORM_HPP)
114
    add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS)
115 116 117 118 119 120 121 122 123
    include_directories(../builds/msvc)
    link_libraries(Ws2_32.lib)
endif()

# add library and include dirs for all targets
link_libraries(libzmq)
include_directories("${CMAKE_SOURCE_DIR}/../include")
include_directories("${CMAKE_SOURCE_DIR}/src")

124
foreach(test ${tests})
Doron Somech's avatar
Doron Somech committed
125
  add_executable(${test} ${test}.cpp)
126 127 128 129 130 131
  if(WIN32)
    # it will only link correctly for DEBUG builds in Windows (I don't know how to specify the target and target library in CMake)
    SET_TARGET_PROPERTIES( ${test} PROPERTIES LINK_FLAGS "/LIBPATH:../bin/Win32/Debug/v120/dynamic" )
  else()
    link_directories(${test} PRIVATE "${CMAKE_SOURCE_DIR}/../lib")
  endif()
132 133

  if(RT_LIBRARY)
Doron Somech's avatar
Doron Somech committed
134
    target_link_libraries(${test} ${RT_LIBRARY} )
135 136
  endif()
  if(WIN32)
Doron Somech's avatar
Doron Somech committed
137
    add_test(NAME ${test} WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH} COMMAND ${test})
138
  else()
Doron Somech's avatar
Doron Somech committed
139
    add_test(NAME ${test} COMMAND ${test})
140
  endif()
141
  set_tests_properties(${test} PROPERTIES TIMEOUT 10)
142 143 144 145 146 147 148 149
endforeach()

if(NOT WIN32)
  if(NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
    set_tests_properties(test_abstract_ipc PROPERTIES WILL_FAIL true)
  endif()
endif()

150 151 152 153 154 155 156 157 158 159
#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()
160