mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-12 18:40:27 +01:00
Problem: Tests do no build in Windows environment
Solution: Modified CMakelist.txt to build correctly for Windows
This commit is contained in:
parent
0916c17b3a
commit
a911fa41b8
@ -1,4 +1,8 @@
|
|||||||
# CMake build script for ZeroMQ tests
|
# CMake build script for ZeroMQ tests
|
||||||
|
cmake_minimum_required(VERSION "3.0")
|
||||||
|
|
||||||
|
# name of Windows project will tests.sln
|
||||||
|
PROJECT(tests)
|
||||||
|
|
||||||
set(tests
|
set(tests
|
||||||
test_system
|
test_system
|
||||||
@ -105,10 +109,26 @@ if(WITH_VMCI)
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# add location of platform.hpp for Windows builds
|
||||||
|
if(WIN32)
|
||||||
|
add_definitions(-DZMQ_CUSTOM_PLATFORM_HPP)
|
||||||
|
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")
|
||||||
|
|
||||||
foreach(test ${tests})
|
foreach(test ${tests})
|
||||||
add_executable(${test} ${test}.cpp)
|
add_executable(${test} ${test}.cpp)
|
||||||
target_include_directories(${test} PRIVATE "${CMAKE_SOURCE_DIR}/src")
|
if(WIN32)
|
||||||
target_link_libraries(${test} libzmq)
|
# 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()
|
||||||
|
|
||||||
if(RT_LIBRARY)
|
if(RT_LIBRARY)
|
||||||
target_link_libraries(${test} ${RT_LIBRARY} )
|
target_link_libraries(${test} ${RT_LIBRARY} )
|
||||||
@ -137,3 +157,4 @@ foreach(TEST_SOURCE ${ALL_TEST_SOURCES})
|
|||||||
message(AUTHOR_WARNING "Test '${TESTNAME}' is not known to CTest.")
|
message(AUTHOR_WARNING "Test '${TESTNAME}' is not known to CTest.")
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
@ -15,4 +15,12 @@ Please use only ANSI C99 in test cases, no C++. This is to make the code more re
|
|||||||
On many slower environments, like embedded systems, VMs or CI systems, test might
|
On many slower environments, like embedded systems, VMs or CI systems, test might
|
||||||
fail because it takes time for sockets to settle after a connect. If you need
|
fail because it takes time for sockets to settle after a connect. If you need
|
||||||
to add a sleep, please be consistent with all the other tests and use:
|
to add a sleep, please be consistent with all the other tests and use:
|
||||||
msleep (SETTLE_TIME);
|
msleep (SETTLE_TIME);
|
||||||
|
|
||||||
|
# Building tests in Windows
|
||||||
|
|
||||||
|
Install CMAKE
|
||||||
|
CMD> CMAKE libzmq/tests
|
||||||
|
CMD> tests.sln
|
||||||
|
CMD> # build all projects in the solution
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user