Commit 83087449 authored by Ian Craggs's avatar Ian Craggs

Build TLS libraries on Windows

parent 5db08261
......@@ -63,7 +63,7 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
ENDIF()
IF(WIN32)
ADD_DEFINITIONS(-DWIN32 -D_WINDOWS -D_CRT_SECURE_NO_DEPRECATE)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -DWIN32_LEAN_AND_MEAN -MD)
ELSEIF(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
ADD_DEFINITIONS(-DOSX)
ENDIF()
......
......@@ -2,7 +2,11 @@ version: 1.0.{build}
image: Visual Studio 2015
configuration: Debug
install:
- cmd: cinst openssl.light
- ps: cinst openssl.light -y
- ps: (new-object net.webclient).DownloadFile('https://eclipse.org/downloads/download.php?file=/mosquitto/binary/win32/mosquitto-1.4.11-install-win32.exe', 'mosquitto-1.4.11-install-win32.exe')
- ps: mosquitto-1.4.11-install-win32.exe /S
- ps: taskkill
- ps: (new-object net.webclient).DownloadFile('ftp://sources.redhat.com/pub/pthreads-win32/dll-latest/dll/x86/pthreadVC2.dll', "C:\Program Files (x86)\mosquitto\pthreadVC2.dll")
build_script:
- cmd: >-
mkdir build.paho
......@@ -15,6 +19,8 @@ build_script:
nmake
python ..\test\mqttsas2.py mqtt.iotree.co.uk
ctest -T test -VV
cd ..
......
setlocal
rmdir /s /q build.paho
mkdir build.paho
cd build.paho
call "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 ..
cmake -G "NMake Makefiles" -DPAHO_WITH_SSL=TRUE -DPAHO_BUILD_DOCUMENTATION=FALSE -DPAHO_BUILD_SAMPLES=TRUE -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=TRUE ..
nmake
......
......@@ -36,14 +36,18 @@ IF (PAHO_WITH_SSL)
SET(OPENSSL_BREW_PATH "/usr/local/opt/openssl")
ENDIF (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
IF (WIN32)
SET(OPENSSL_DIR $ENV{OPENSSL_DIR})
ENDIF ()
FIND_PATH(OPENSSL_INCLUDE_DIR openssl/ssl.h
HINTS ${OPENSSL_INC_SEARCH_PATH}/include ${OPENSSL_BREW_PATH}/include/)
FIND_LIBRARY(OPENSSL_LIB NAMES ssl libssl
HINTS ${OPENSSL_INC_SEARCH_PATH}/include ${OPENSSL_DIR}/include ${OPENSSL_BREW_PATH}/include/)
FIND_LIBRARY(OPENSSL_LIB NAMES ssl libssl ssleay32
HINTS ${OPENSSL_BREW_PATH}/lib ${OPENSSL_DIR}/lib ${OPENSSL_DIR}/lib64)
FIND_LIBRARY(OPENSSLCRYPTO_LIB NAMES crypto libcrypto
FIND_LIBRARY(OPENSSLCRYPTO_LIB NAMES crypto libcrypto libeay32
HINTS ${OPENSSL_BREW_PATH}/lib ${OPENSSL_DIR}/lib ${OPENSSL_DIR}/lib64)
MESSAGE(STATUS "OpenSSL hint ${PENSSL_INC_SEARCH_PATH} (includes) / ")
MESSAGE(STATUS "OpenSSL hint ${OPENSSL_INC_SEARCH_PATH} (includes) / ")
MESSAGE(STATUS "OpenSSL headers found at ${OPENSSL_INCLUDE_DIR}")
MESSAGE(STATUS "OpenSSL library found at ${OPENSSL_LIB}")
MESSAGE(STATUS "OpenSSL Crypto library found at ${OPENSSLCRYPTO_LIB}")
......
......@@ -42,15 +42,13 @@
#include <stdio.h>
#include <signal.h>
#include <memory.h>
#include <stdlib.h>
#if defined(WIN32)
#include <Windows.h>
#define sleep Sleep
#else
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
#include <unistd.h>
#endif
......
......@@ -3,11 +3,11 @@
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
......@@ -17,15 +17,15 @@
*******************************************************************************/
/*
stdout subscriber for the asynchronous client
compulsory parameters:
--topic topic to subscribe to
defaulted parameters:
--host localhost
--port 1883
--qos 2
......@@ -33,10 +33,10 @@
--clientid stdout-subscriber-async
--showtopics off
--keepalive 10
--userid none
--password none
*/
#include "MQTTAsync.h"
......@@ -45,14 +45,13 @@
#include <stdio.h>
#include <signal.h>
#include <memory.h>
#include <stdlib.h>
#if defined(WIN32)
#include <windows.h>
#define sleep Sleep
#else
#include <sys/time.h>
#include <stdlib.h>
#include <unistd.h>
#endif
......@@ -108,7 +107,7 @@ void usage(void)
void getopts(int argc, char** argv)
{
int count = 2;
while (count < argc)
{
if (strcmp(argv[count], "--qos") == 0)
......@@ -198,7 +197,7 @@ void getopts(int argc, char** argv)
}
count++;
}
}
......@@ -287,10 +286,10 @@ int main(int argc, char** argv)
MQTTAsync_disconnectOptions disc_opts = MQTTAsync_disconnectOptions_initializer;
int rc = 0;
char url[100];
if (argc < 2)
usage();
topic = argv[1];
if (strchr(topic, '#') || strchr(topic, '+'))
......@@ -298,7 +297,7 @@ int main(int argc, char** argv)
if (opts.showtopics)
printf("topic is %s\n", topic);
getopts(argc, argv);
getopts(argc, argv);
sprintf(url, "%s:%s", opts.host, opts.port);
rc = MQTTAsync_create(&client, url, opts.clientid, MQTTCLIENT_PERSISTENCE_NONE, NULL);
......@@ -357,5 +356,3 @@ exit:
return EXIT_SUCCESS;
}
......@@ -41,14 +41,12 @@
#include <stdio.h>
#include <signal.h>
#include <memory.h>
#include <stdlib.h>
#if defined(WIN32)
#include <Windows.h>
#define sleep Sleep
#else
#include <sys/time.h>
#include <stdlib.h>
#endif
......
......@@ -3,11 +3,11 @@
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
......@@ -17,15 +17,15 @@
*******************************************************************************/
/*
stdout subscriber
compulsory parameters:
--topic topic to subscribe to
defaulted parameters:
--host localhost
--port 1883
--qos 2
......@@ -33,10 +33,10 @@
--clientid stdout-subscriber
--showtopics off
--keepalive 10
--userid none
--password none
*/
#include "MQTTClient.h"
#include "MQTTClientPersistence.h"
......@@ -44,14 +44,13 @@
#include <stdio.h>
#include <signal.h>
#include <memory.h>
#include <stdlib.h>
#if defined(WIN32)
#include <windows.h>
#define sleep Sleep
#else
#include <sys/time.h>
#include <stdlib.h>
#endif
......@@ -119,10 +118,10 @@ int main(int argc, char** argv)
char* topic = NULL;
int rc = 0;
char url[100];
if (argc < 2)
usage();
topic = argv[1];
if (strchr(topic, '#') || strchr(topic, '+'))
......@@ -130,7 +129,7 @@ int main(int argc, char** argv)
if (opts.showtopics)
printf("topic is %s\n", topic);
getopts(argc, argv);
getopts(argc, argv);
sprintf(url, "%s:%s", opts.host, opts.port);
rc = MQTTClient_create(&client, url, opts.clientid, MQTTCLIENT_PERSISTENCE_NONE, NULL);
......@@ -143,9 +142,9 @@ int main(int argc, char** argv)
conn_opts.cleansession = 1;
conn_opts.username = opts.username;
conn_opts.password = opts.password;
myconnect(&client, &conn_opts);
rc = MQTTClient_subscribe(client, topic, opts.qos);
while (!toStop)
......@@ -153,7 +152,7 @@ int main(int argc, char** argv)
char* topicName = NULL;
int topicLen;
MQTTClient_message* message = NULL;
rc = MQTTClient_receive(client, &topicName, &topicLen, &message, 1000);
if (message)
{
......@@ -170,7 +169,7 @@ int main(int argc, char** argv)
if (rc != 0)
myconnect(&client, &conn_opts);
}
printf("Stopping\n");
MQTTClient_disconnect(client, 0);
......@@ -183,7 +182,7 @@ int main(int argc, char** argv)
void getopts(int argc, char** argv)
{
int count = 2;
while (count < argc)
{
if (strcmp(argv[count], "--qos") == 0)
......@@ -267,5 +266,5 @@ void getopts(int argc, char** argv)
}
count++;
}
}
PROJECT(mqtt-tests)
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_SSL_HOSTNAME "localhost" CACHE STRING "Hostname of a test SSL MQTT broker to use")
IF (WIN32)
SET(MQTT_TEST_BROKER "tcp://mqtt.iotree.co.uk:1883" CACHE STRING "Hostname of a test MQTT broker to use")
SET(MQTT_TEST_PROXY "tcp://localhost:1883" CACHE STRING "Hostname of the test proxy to use")
SET(MQTT_SSL_HOSTNAME "mqtt.iotree.co.uk" CACHE STRING "Hostname of a test SSL MQTT broker to use")
ELSE ()
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_SSL_HOSTNAME "localhost" CACHE STRING "Hostname of a test SSL MQTT broker to use")
ENDIF ()
SET(CERTDIR $ENV{TRAVIS_BUILD_DIR}/test/ssl )
ADD_EXECUTABLE(
......
......@@ -31,6 +31,7 @@
#include <errno.h>
#else
#include <windows.h>
#include <applink.c>
#define MAXHOSTNAMELEN 256
#define snprintf _snprintf
#define setenv(a, b, c) _putenv_s(a, b)
......
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