Commit fee1c80e authored by Ian Craggs's avatar Ian Craggs

Merge branch 'cmake-tests' of https://github.com/orpiske/paho.mqtt.c (#222) into fixes

parents 3ab7145a de85312f
......@@ -32,3 +32,4 @@ addons:
build_command_prepend: "make clean"
build_command: "make -j 4"
branch_pattern: coverity-.*
#*******************************************************************************
# Copyright (c) 2015 logi.cals GmbH
#
#
# 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.
#
# The Eclipse Public License is available at
# and Eclipse Distribution License v1.0 which accompany this distribution.
#
# 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:
# Rainer Poisel - initial version
#*******************************************************************************/
......@@ -17,7 +17,7 @@
# Note: on OS X you should install XCode and the associated command-line tools
PROJECT("paho" C)
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
## build settings
SET(PAHO_VERSION_MAJOR 1)
......@@ -32,6 +32,16 @@ ELSE()
ENDIF()
STRING(STRIP ${BUILD_TIMESTAMP} 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()
## build options
SET(PAHO_WITH_SSL FALSE CACHE BOOL "Flag that defines whether to build ssl-enabled binaries too. ")
SET(PAHO_BUILD_STATIC FALSE CACHE BOOL "Build static library")
......@@ -58,3 +68,8 @@ SET(CPACK_PACKAGE_VERSION_MAJOR ${PAHO_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${PAHO_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${PAHO_VERSION_PATCH})
INCLUDE(CPack)
ENABLE_TESTING()
INCLUDE_DIRECTORIES(test src)
ADD_SUBDIRECTORY(test)
\ No newline at end of file
......@@ -53,6 +53,8 @@ IF (WIN32)
ELSEIF (UNIX)
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
SET(LIBS_SYSTEM c dl pthread)
ELSEIF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
SET(LIBS_SYSTEM compat)
ELSE()
SET(LIBS_SYSTEM c pthread)
ENDIF()
......@@ -74,9 +76,10 @@ SET_TARGET_PROPERTIES(
paho-mqtt3c paho-mqtt3a PROPERTIES
VERSION ${CLIENT_VERSION}
SOVERSION ${PAHO_VERSION_MAJOR})
INSTALL(TARGETS paho-mqtt3c paho-mqtt3a
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
LIBRARY DESTINATION ${PAHO_LIBRARY_DIR_NAME})
INSTALL(TARGETS MQTTVersion
RUNTIME DESTINATION bin)
......@@ -113,7 +116,8 @@ SET(OPENSSL_LIB_SEARCH_PATH "" CACHE PATH "Directory containing OpenSSL librarie
FIND_LIBRARY(OPENSSLCRYPTO_LIB NAMES crypto libcrypto
HINTS ${OPENSSL_BREW_PATH}/lib ${OPENSSL_DIR}/lib ${OPENSSL_DIR}/lib64)
MESSAGE(STATUS "OpenSSL hint ${OPENSSL_INC_SEARCH_PATH} (includes) / ")
##MESSAGE(STATUS "OpenSSL hint ${OPENSSL_INC_SEARCH_PATH} (includes) / ")
MESSAGE(STATUS "OpenSSL hints: ${OPENSSL_INC_SEARCH_PATH},${OPENSSL_BREW_PATH}")
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}")
......@@ -138,10 +142,10 @@ SET(OPENSSL_LIB_SEARCH_PATH "" CACHE PATH "Directory containing OpenSSL librarie
COMPILE_DEFINITIONS "OPENSSL=1")
INSTALL(TARGETS paho-mqtt3cs
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
LIBRARY DESTINATION ${PAHO_LIBRARY_DIR_NAME})
INSTALL(TARGETS paho-mqtt3as
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
LIBRARY DESTINATION ${PAHO_LIBRARY_DIR_NAME})
IF (PAHO_BUILD_STATIC)
ADD_LIBRARY(paho-mqtt3cs-static STATIC $<TARGET_OBJECTS:common_ssl_obj> MQTTClient.c SSLSocket.c)
......@@ -152,10 +156,10 @@ SET(OPENSSL_LIB_SEARCH_PATH "" CACHE PATH "Directory containing OpenSSL librarie
INSTALL(TARGETS paho-mqtt3cs-static
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
LIBRARY DESTINATION ${PAHO_LIBRARY_DIR_NAME})
INSTALL(TARGETS paho-mqtt3as-static
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
LIBRARY DESTINATION ${PAHO_LIBRARY_DIR_NAME})
ENDIF()
ENDIF()
#*******************************************************************************
# Copyright (c) 2015, 2016 logi.cals GmbH
#
# Copyright (c) 2015, 2017 logi.cals GmbH and others
#
# 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.
#
# The Eclipse Public License is available at
# and Eclipse Distribution License v1.0 which accompany this distribution.
#
# 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:
# Rainer Poisel - initial version
# Ian Craggs - update sample names
......@@ -56,5 +56,6 @@ INSTALL(TARGETS paho_c_sub
MQTTClient_subscribe
MQTTClient_publish
MQTTClient_publish_async
RUNTIME DESTINATION bin)
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${PAHO_LIBRARY_DIR_NAME})
SET(MQTT_TEST_BROKER "tcp://localhost:1883" CACHE STRING "Hostname of a test MQTT broker to use")
SET(MQTT_SSL_HOSTNAME "localhost" CACHE STRING "Hostname of a test SSL MQTT broker to use")
ADD_EXECUTABLE(
test1
test1.c
)
TARGET_LINK_LIBRARIES(
test1
paho-mqtt3c
)
ADD_TEST(
NAME test1
COMMAND "test1" "--connection" ${MQTT_TEST_BROKER}
)
ADD_EXECUTABLE(
test2
test2.c
)
TARGET_LINK_LIBRARIES(
test2
paho-mqtt3c
)
ADD_TEST(
NAME test2
COMMAND test2 "--connection" ${MQTT_TEST_BROKER}
)
ADD_EXECUTABLE(
test3
test3.c
)
TARGET_LINK_LIBRARIES(
test3
paho-mqtt3cs
)
ADD_TEST(
NAME test3
COMMAND test3 "--connection" ${MQTT_TEST_BROKER}
)
ADD_EXECUTABLE(
test4
test4.c
)
TARGET_LINK_LIBRARIES(
test4
paho-mqtt3a
)
ADD_TEST(
NAME test4
COMMAND test4 "--connection" ${MQTT_TEST_BROKER}
)
ADD_EXECUTABLE(
test5
test5.c
)
TARGET_LINK_LIBRARIES(
test5
paho-mqtt3as
)
ADD_TEST(
NAME test5
COMMAND test5 "--hostname" ${MQTT_SSL_HOSTNAME}
)
ADD_EXECUTABLE(
test6
test6.c
)
TARGET_LINK_LIBRARIES(
test6
paho-mqtt3a
)
ADD_TEST(
NAME test6
COMMAND test6 "--connection" ${MQTT_TEST_BROKER}
)
ADD_EXECUTABLE(
test8
test8.c
)
TARGET_LINK_LIBRARIES(
test8
paho-mqtt3a
)
ADD_TEST(
NAME test8
COMMAND test8 "--connection" ${MQTT_TEST_BROKER}
)
ADD_EXECUTABLE(
test9
test9.c
)
TARGET_LINK_LIBRARIES(
test9
paho-mqtt3a
)
ADD_TEST(
NAME test9
COMMAND test9 "--connection" ${MQTT_TEST_BROKER}
)
\ No newline at end of file
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