From fdc145a09e15aea93736b5a4e1bca3803e12dc48 Mon Sep 17 00:00:00 2001 From: Pawel Kurdybacha <kurdybacha@users.noreply.github.com> Date: Tue, 17 Apr 2018 09:29:47 +0100 Subject: [PATCH] Problem: Windows build broken because of multiple issues (#204) * Problem: Windows build broken because of multiple issues Windows issues: * missing includes files Solution: added missing <memory> and <unordered_map> Here <map> was replaced with <unordered_map> as there is no need for sorted map. * googletest fails because deprecation warning causing errors. Solution: D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING option added. * googletest fails because by default, new Visual Studio projects link the C runtimes dynamically but Google Test links them statically. Solution: gtest_force_shared_crt=ON option added. Besides that adding appveyor.yml configuration to add Windows build to CI in order to prevent accidental Windows build breakage. For now only Debug configuration as Release requires more time to figure out. * Problem: Windows build takes too long Solution: disabling tests and perf tools * Problem: Windows unit_tests executable not finding lizmq dll. Solution: copy libzmq dll to build bin directory. * Problem: Windows build fails because wrong test path provided --- appveyor.yml | 35 +++++++++++++++++++++++++++++++++++ tests/cmake/googletest.cmake | 5 +++++ tests/poller.cpp | 1 + zmq.hpp | 3 ++- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..1c817d8 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,35 @@ +version: build-{build} + +os: + - Visual Studio 2017 + - Visual Studio 2015 + +init: + - cmake --version + - msbuild /version + +platform: + - Win32 + - x64 + +configuration: + - Debug + +environment: + ZMQ_VERSION: 4.2.5 + +before_build: + - appveyor DownloadFile https://github.com/zeromq/libzmq/archive/v%ZMQ_VERSION%.zip + - 7z x v%ZMQ_VERSION%.zip >NUL + - cmake -H./libzmq-%ZMQ_VERSION% -BBuild-libzmq -DENABLE_DRAFTS=ON -DWITH_PERF_TOOL=OFF -DZMQ_BUILD_TESTS=OFF -DENABLE_CPACK=OFF -A%PLATFORM% + - cmake --build Build-libzmq + - cmake -H. -BBuild -DCMAKE_PREFIX_PATH=./Build-libzmq -A%PLATFORM% + +build: + project: Build/cppzmq.sln + verbosity: normal + +test_script: + - cp Build-libzmq/bin/%configuration%/libzmq*.dll Build/bin/%configuration%/ + - cd Build + - ctest -V -C %configuration% diff --git a/tests/cmake/googletest.cmake b/tests/cmake/googletest.cmake index 5ca7090..8a052c8 100644 --- a/tests/cmake/googletest.cmake +++ b/tests/cmake/googletest.cmake @@ -24,6 +24,11 @@ macro(fetch_googletest _download_module_path _download_root) ${_download_root} ) +if (MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING") + set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +endif() + # adds the targers: gtest, gtest_main, gmock, gmock_main add_subdirectory( ${_download_root}/googletest-src diff --git a/tests/poller.cpp b/tests/poller.cpp index 1b7c183..1010546 100644 --- a/tests/poller.cpp +++ b/tests/poller.cpp @@ -4,6 +4,7 @@ #if defined(ZMQ_CPP11) && defined(ZMQ_BUILD_DRAFT_API) #include <array> +#include <memory> TEST(poller, create_destroy) { diff --git a/zmq.hpp b/zmq.hpp index 3c7312a..a5b1c5d 100644 --- a/zmq.hpp +++ b/zmq.hpp @@ -73,6 +73,7 @@ #include <chrono> #include <tuple> #include <functional> + #include <unordered_map> #endif // Detect whether the compiler supports C++11 rvalue references. @@ -1107,7 +1108,7 @@ namespace zmq private: void *poller_ptr; std::vector<zmq_poller_event_t> poller_events; - std::map<socket_t*, handler_t> handlers; + std::unordered_map<socket_t*, handler_t> handlers; }; // class poller_t #endif // defined(ZMQ_BUILD_DRAFT_API) && defined(ZMQ_CPP11) && defined(ZMQ_HAVE_POLLER)