From 7a66543ec28f435a4e5cc7184ea1d1e68ea284ed Mon Sep 17 00:00:00 2001 From: Otavio Rodolfo Piske Date: Fri, 3 Feb 2017 15:15:45 +0100 Subject: [PATCH] Fix compilation errors on test2 due to multiple symbol redefinitions Signed-off-by: Otavio Rodolfo Piske --- test/CMakeLists.txt | 4 ++++ test/test2.c | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a03e14bb..cf10c21e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,6 +4,10 @@ SET(MQTT_TEST_BROKER "tcp://localhost:1883" CACHE STRING "Hostname of a test MQT SET(MQTT_SSL_HOSTNAME "localhost" CACHE STRING "Hostname of a test SSL MQTT broker to use") +IF (WIN32) + ADD_DEFINITIONS(/DCMAKE_BUILD) +ENDIF() + ADD_EXECUTABLE( test1 test1.c diff --git a/test/test2.c b/test/test2.c index 71ce135a..35440fdf 100644 --- a/test/test2.c +++ b/test/test2.c @@ -32,8 +32,15 @@ #include #define WINAPI #else -#include -#include +#define WIN32_LEAN_AND_MEAN +#if !defined(CMAKE_BUILD) + /* + * These causes the cmake build to fail. In order to prevent affecting + * other builds, remove them only from CMAKE-related builds + */ + #include + #include +#endif // CMAKE_BUILD #define MAXHOSTNAMELEN 256 #define EAGAIN WSAEWOULDBLOCK #define EINTR WSAEINTR @@ -42,6 +49,7 @@ #define ENOTCONN WSAENOTCONN #define ECONNRESET WSAECONNRESET #define setenv(a, b, c) _putenv_s(a, b) + #endif #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))