Commit e9b89be4 authored by Ian Craggs's avatar Ian Craggs

Merge branch 'cmake-tests-appveyor' of https://github.com/orpiske/paho.mqtt.c into fixes

parents 19d0c91d 71d7b4f5
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
# Note: on OS X you should install XCode and the associated command-line tools # Note: on OS X you should install XCode and the associated command-line tools
PROJECT("paho" C) PROJECT("paho" C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
MESSAGE(STATUS "CMake version: " ${CMAKE_VERSION}) MESSAGE(STATUS "CMake version: " ${CMAKE_VERSION})
## build settings ## build settings
...@@ -26,12 +26,30 @@ SET(PAHO_VERSION_MINOR 1) ...@@ -26,12 +26,30 @@ SET(PAHO_VERSION_MINOR 1)
SET(PAHO_VERSION_PATCH 0) SET(PAHO_VERSION_PATCH 0)
SET(CLIENT_VERSION ${PAHO_VERSION_MAJOR}.${PAHO_VERSION_MINOR}.${PAHO_VERSION_PATCH}) SET(CLIENT_VERSION ${PAHO_VERSION_MAJOR}.${PAHO_VERSION_MINOR}.${PAHO_VERSION_PATCH})
IF(WIN32)
EXECUTE_PROCESS(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE BUILD_TIMESTAMP) EXECUTE_PROCESS(COMMAND date -u OUTPUT_VARIABLE BUILD_TIMESTAMP)
ELSE()
EXECUTE_PROCESS(COMMAND date -u OUTPUT_VARIABLE BUILD_TIMESTAMP) IF (BUILD_TIMESTAMP STREQUAL "")
MESSAGE(WARNING "Unable to determine build timestamp via default mechanism.")
IF (WIN32)
EXECUTE_PROCESS(COMMAND "cmd.exe" "/c" echo %DATE% %TIME% OUTPUT_VARIABLE BUILD_TIMESTAMP)
ENDIF()
ENDIF() ENDIF()
STRING(STRIP ${BUILD_TIMESTAMP} BUILD_TIMESTAMP) STRING(STRIP ${BUILD_TIMESTAMP} BUILD_TIMESTAMP)
MESSAGE(STATUS "Timestamp is ${BUILD_TIMESTAMP}")
# Uses the correct directory for libraries on Red Hat-based distributions.
SET(PAHO_LIBRARY_DIR_NAME "lib")
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
IF(EXISTS "/etc/redhat-release")
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(PAHO_LIBRARY_DIR_NAME "lib64")
ENDIF()
ENDIF()
ENDIF()
# Uses the correct directory for libraries on Red Hat-based distributions. # Uses the correct directory for libraries on Red Hat-based distributions.
SET(PAHO_LIBRARY_DIR_NAME "lib") SET(PAHO_LIBRARY_DIR_NAME "lib")
...@@ -74,4 +92,3 @@ ENABLE_TESTING() ...@@ -74,4 +92,3 @@ ENABLE_TESTING()
INCLUDE_DIRECTORIES(test src) INCLUDE_DIRECTORIES(test src)
ADD_SUBDIRECTORY(test) ADD_SUBDIRECTORY(test)
version: 1.0.{build}
image: Visual Studio 2015
configuration: Debug
install:
- cmd: cinst openssl.light
build_script:
- cmd: >-
mkdir build.paho
cd build.paho
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
cmake -G "NMake Makefiles" -DPAHO_WITH_SSL=FALSE -DPAHO_BUILD_DOCUMENTATION=FALSE -DPAHO_BUILD_SAMPLES=TRUE -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=TRUE ..
nmake
cd ..
\ No newline at end of file
...@@ -136,7 +136,6 @@ INSTALL(FILES MQTTAsync.h MQTTClient.h MQTTClientPersistence.h ...@@ -136,7 +136,6 @@ INSTALL(FILES MQTTAsync.h MQTTClient.h MQTTClientPersistence.h
DESTINATION include) DESTINATION include)
IF (PAHO_WITH_SSL) IF (PAHO_WITH_SSL)
SET(OPENSSL_LIB_SEARCH_PATH "" CACHE PATH "Directory containing OpenSSL libraries")
SET(OPENSSL_INC_SEARCH_PATH "" CACHE PATH "Directory containing OpenSSL includes") SET(OPENSSL_INC_SEARCH_PATH "" CACHE PATH "Directory containing OpenSSL includes")
IF (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") IF (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
...@@ -200,5 +199,4 @@ SET(OPENSSL_LIB_SEARCH_PATH "" CACHE PATH "Directory containing OpenSSL librarie ...@@ -200,5 +199,4 @@ SET(OPENSSL_LIB_SEARCH_PATH "" CACHE PATH "Directory containing OpenSSL librarie
ARCHIVE DESTINATION lib ARCHIVE DESTINATION lib
LIBRARY DESTINATION ${PAHO_LIBRARY_DIR_NAME}) LIBRARY DESTINATION ${PAHO_LIBRARY_DIR_NAME})
ENDIF() ENDIF()
ENDIF() ENDIF()
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
* Ian Craggs - fix for bug #420851 * Ian Craggs - fix for bug #420851
* Ian Craggs - change MacOS semaphore implementation * Ian Craggs - change MacOS semaphore implementation
*******************************************************************************/ *******************************************************************************/
#include "MQTTClient.h"
#if !defined(THREAD_H) #if !defined(THREAD_H)
#define THREAD_H #define THREAD_H
...@@ -53,14 +54,14 @@ ...@@ -53,14 +54,14 @@
int Thread_destroy_cond(cond_type); int Thread_destroy_cond(cond_type);
#endif #endif
thread_type Thread_start(thread_fn, void*); DLLExport thread_type Thread_start(thread_fn, void*);
mutex_type Thread_create_mutex(void); DLLExport mutex_type Thread_create_mutex();
int Thread_lock_mutex(mutex_type); DLLExport int Thread_lock_mutex(mutex_type);
int Thread_unlock_mutex(mutex_type); DLLExport int Thread_unlock_mutex(mutex_type);
void Thread_destroy_mutex(mutex_type); void Thread_destroy_mutex(mutex_type);
thread_id_type Thread_getid(void); DLLExport thread_id_type Thread_getid();
sem_type Thread_create_sem(void); sem_type Thread_create_sem(void);
int Thread_wait_sem(sem_type sem, int timeout); int Thread_wait_sem(sem_type sem, int timeout);
......
PROJECT(mqtt-tests)
SET(MQTT_TEST_BROKER "tcp://localhost:1883" CACHE STRING "Hostname of a test MQTT broker to use") SET(MQTT_TEST_BROKER "tcp://localhost:1883" CACHE STRING "Hostname of a test MQTT broker to use")
SET(MQTT_TEST_PROXY "tcp://localhost:1884" CACHE STRING "Hostname of the test proxy to use") SET(MQTT_TEST_PROXY "tcp://localhost:1884" CACHE STRING "Hostname of the test proxy to use")
SET(MQTT_SSL_HOSTNAME "localhost" CACHE STRING "Hostname of a test SSL MQTT broker to use") SET(MQTT_SSL_HOSTNAME "localhost" CACHE STRING "Hostname of a test SSL MQTT broker to use")
SET(CERTDIR $ENV{TRAVIS_BUILD_DIR}/test/ssl ) SET(CERTDIR $ENV{TRAVIS_BUILD_DIR}/test/ssl )
IF (WIN32)
ADD_DEFINITIONS(/DCMAKE_BUILD)
ENDIF()
ADD_EXECUTABLE( ADD_EXECUTABLE(
test1 test1
...@@ -15,6 +20,14 @@ TARGET_LINK_LIBRARIES( ...@@ -15,6 +20,14 @@ TARGET_LINK_LIBRARIES(
paho-mqtt3c paho-mqtt3c
) )
IF (WIN32)
ADD_CUSTOM_COMMAND(
TARGET test1 PRE_BUILD
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/dll-copy.cmake
COMMENT "Copying DLLs to test directory"
)
ENDIF()
ADD_TEST( ADD_TEST(
NAME test1-1-single-thread-client NAME test1-1-single-thread-client
COMMAND "test1" "--test_no" "1" "--connection" ${MQTT_TEST_BROKER} COMMAND "test1" "--test_no" "1" "--connection" ${MQTT_TEST_BROKER}
...@@ -221,7 +234,6 @@ ADD_TEST( ...@@ -221,7 +234,6 @@ ADD_TEST(
ENDIF() ENDIF()
ADD_EXECUTABLE( ADD_EXECUTABLE(
test6 test6
test6.c test6.c
...@@ -302,3 +314,4 @@ ADD_TEST( ...@@ -302,3 +314,4 @@ ADD_TEST(
COMMAND test9 "--test_no" "5" "--connection" ${MQTT_TEST_BROKER} "--proxy_connection" ${MQTT_TEST_PROXY} COMMAND test9 "--test_no" "5" "--connection" ${MQTT_TEST_BROKER} "--proxy_connection" ${MQTT_TEST_PROXY}
) )
FILE(GLOB dlls ${CMAKE_BINARY_DIR}/../src/*.dll)
MESSAGE(STATUS "Files to copy: ${dlls}. From: ${CMAKE_BINARY_DIR}")
FOREACH(dll ${dlls})
MESSAGE(STATUS "Copying dll runtime file ${dll} to runtime dir ${CMAKE_BINARY_DIR}")
FILE(COPY ${dll} DESTINATION ${CMAKE_BINARY_DIR})
ENDFOREACH(dll)
\ No newline at end of file
...@@ -32,8 +32,15 @@ ...@@ -32,8 +32,15 @@
#include <errno.h> #include <errno.h>
#define WINAPI #define WINAPI
#else #else
#include <winsock2.h> #define WIN32_LEAN_AND_MEAN
#include <ws2tcpip.h> #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 <winsock2.h>
#include <ws2tcpip.h>
#endif // CMAKE_BUILD
#define MAXHOSTNAMELEN 256 #define MAXHOSTNAMELEN 256
#define EAGAIN WSAEWOULDBLOCK #define EAGAIN WSAEWOULDBLOCK
#define EINTR WSAEINTR #define EINTR WSAEINTR
...@@ -42,6 +49,7 @@ ...@@ -42,6 +49,7 @@
#define ENOTCONN WSAENOTCONN #define ENOTCONN WSAENOTCONN
#define ECONNRESET WSAECONNRESET #define ECONNRESET WSAECONNRESET
#define setenv(a, b, c) _putenv_s(a, b) #define setenv(a, b, c) _putenv_s(a, b)
#endif #endif
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment