2018-02-08 17:48:15 +01:00
|
|
|
# CMake build script for ZeroMQ unit tests
|
|
|
|
cmake_minimum_required(VERSION "2.8.1")
|
|
|
|
|
|
|
|
set(unittests
|
2020-04-14 00:03:19 +02:00
|
|
|
unittest_ypipe
|
|
|
|
unittest_poller
|
|
|
|
unittest_mtrie
|
|
|
|
unittest_ip_resolver
|
|
|
|
unittest_udp_address
|
|
|
|
unittest_radix_tree
|
|
|
|
unittest_curve_encoding)
|
2018-02-08 17:48:15 +01:00
|
|
|
|
2020-04-14 00:03:19 +02:00
|
|
|
# if(ENABLE_DRAFTS) list(APPEND tests ) endif(ENABLE_DRAFTS)
|
2018-02-08 17:48:15 +01:00
|
|
|
|
|
|
|
# add location of platform.hpp for Windows builds
|
|
|
|
if(WIN32)
|
2018-09-10 00:12:07 +02:00
|
|
|
add_definitions(-DZMQ_CUSTOM_PLATFORM_HPP)
|
|
|
|
add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS)
|
|
|
|
# Same name on 64bit systems
|
|
|
|
link_libraries(ws2_32.lib)
|
2018-02-08 17:48:15 +01:00
|
|
|
endif()
|
|
|
|
|
2018-08-15 10:11:49 +08:00
|
|
|
include_directories("${ZeroMQ_SOURCE_DIR}/include" "${ZeroMQ_SOURCE_DIR}/src" "${ZeroMQ_BINARY_DIR}")
|
|
|
|
include_directories("${ZeroMQ_SOURCE_DIR}/external/unity")
|
2018-02-08 17:48:15 +01:00
|
|
|
|
|
|
|
foreach(test ${unittests})
|
|
|
|
# target_sources not supported before CMake 3.1
|
2018-05-05 00:44:13 +02:00
|
|
|
add_executable(${test} ${test}.cpp "unittest_resolver_common.hpp")
|
2018-02-08 17:48:15 +01:00
|
|
|
|
|
|
|
# per-test directories not generated on OS X / Darwin
|
2018-09-10 00:12:07 +02:00
|
|
|
if(NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang.*")
|
|
|
|
link_directories(${test} PRIVATE "${ZeroMQ_SOURCE_DIR}/../lib")
|
2018-02-08 17:48:15 +01:00
|
|
|
endif()
|
2018-09-10 00:12:07 +02:00
|
|
|
|
2019-03-23 06:27:12 -04:00
|
|
|
target_link_libraries(${test} testutil-static)
|
2018-09-10 00:12:07 +02:00
|
|
|
|
2018-02-08 17:48:15 +01:00
|
|
|
if(RT_LIBRARY)
|
|
|
|
target_link_libraries(${test} ${RT_LIBRARY})
|
|
|
|
endif()
|
2018-09-10 00:12:07 +02:00
|
|
|
|
2019-04-18 13:23:36 +02:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "QNX")
|
|
|
|
target_link_libraries(${test} socket)
|
|
|
|
target_link_libraries(${test} m)
|
|
|
|
endif()
|
2024-05-07 15:59:09 -05:00
|
|
|
|
|
|
|
if (WITH_GSSAPI_KRB5)
|
2024-05-08 08:13:25 -05:00
|
|
|
target_link_libraries(${test} ${GSSAPI_KRB5_LIBRARIES})
|
2024-05-07 15:59:09 -05:00
|
|
|
endif()
|
2019-04-18 13:23:36 +02:00
|
|
|
|
2018-02-08 17:48:15 +01:00
|
|
|
if(WIN32)
|
2020-04-14 00:03:19 +02:00
|
|
|
add_test(
|
|
|
|
NAME ${test}
|
|
|
|
WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH}
|
|
|
|
COMMAND ${test})
|
2018-02-08 17:48:15 +01:00
|
|
|
else()
|
|
|
|
add_test(NAME ${test} COMMAND ${test})
|
|
|
|
endif()
|
2018-09-10 00:12:07 +02:00
|
|
|
|
2018-02-08 17:48:15 +01:00
|
|
|
set_tests_properties(${test} PROPERTIES TIMEOUT 10)
|
2018-09-10 00:12:07 +02:00
|
|
|
|
2018-02-08 17:48:15 +01:00
|
|
|
# TODO prevent libzmq (non-static) being in the list of link libraries at all
|
|
|
|
get_target_property(LIBS ${test} LINK_LIBRARIES)
|
|
|
|
list(REMOVE_ITEM LIBS libzmq)
|
|
|
|
set_target_properties(${test} PROPERTIES LINK_LIBRARIES "${LIBS}")
|
|
|
|
endforeach()
|
|
|
|
|
2020-04-14 00:03:19 +02:00
|
|
|
# Check whether all tests in the current folder are present TODO duplicated with tests/CMakeLists.txt, define as a
|
|
|
|
# function?
|
2018-02-08 17:48:15 +01:00
|
|
|
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}")
|
2018-09-10 00:12:07 +02:00
|
|
|
if(NOT MATCH_TESTNAME)
|
2018-02-08 17:48:15 +01:00
|
|
|
message(AUTHOR_WARNING "Test '${TESTNAME}' is not known to CTest.")
|
|
|
|
endif()
|
|
|
|
endforeach()
|