diff --git a/shadow/CMakeLists.txt b/shadow/CMakeLists.txt index 565a611c3..dc3d3de9f 100644 --- a/shadow/CMakeLists.txt +++ b/shadow/CMakeLists.txt @@ -1,10 +1,7 @@ -cmake_minimum_required(VERSION 3.1) +# This file is generated -project(IotShadow-cpp LANGUAGES CXX) -if (DEFINED SIMPLE_VERSION) - message("Shadow version is ${SIMPLE_VERSION}") - set(PROJECT_VERSION ${SIMPLE_VERSION}) -endif() +cmake_minimum_required(VERSION 3.1) +project(IotShadow-cpp CXX) set(RUNTIME_DIRECTORY bin) @@ -57,7 +54,9 @@ else () target_compile_options(IotShadow-cpp PRIVATE -Wall -Wno-long-long -pedantic -Werror) endif () -target_compile_definitions(IotShadow-cpp PRIVATE $<$:DEBUG_BUILD>) +if (CMAKE_BUILD_TYPE STREQUAL "" OR CMAKE_BUILD_TYPE MATCHES Debug) + target_compile_definitions(IotShadow-cpp PRIVATE "-DDEBUG_BUILD") +endif () if (BUILD_SHARED_LIBS) target_compile_definitions(IotShadow-cpp PUBLIC "-DAWS_IOTSHADOW_USE_IMPORT_EXPORT") @@ -109,14 +108,6 @@ else() set(TARGET_DIR "static") endif() -include(CMakePackageConfigHelpers) -if (DEFINED SIMPLE_VERSION) - write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/iotshadow-cpp-config-version.cmake" - COMPATIBILITY SameMajorVersion - ) -endif() - install(EXPORT "IotShadow-cpp-targets" DESTINATION "${CMAKE_INSTALL_LIBDIR}/IotShadow-cpp/cmake/${TARGET_DIR}" NAMESPACE AWS:: diff --git a/shadow/cmake/iotshadow-cpp-config.cmake b/shadow/cmake/iotshadow-cpp-config.cmake index 67aff5946..e46a3ee38 100644 --- a/shadow/cmake/iotshadow-cpp-config.cmake +++ b/shadow/cmake/iotshadow-cpp-config.cmake @@ -1,3 +1,5 @@ +# This file is generated + include(CMakeFindDependencyMacro) find_dependency(aws-crt-cpp) diff --git a/shadow/include/aws/iotshadow/IotShadowClient.h b/shadow/include/aws/iotshadow/IotShadowClient.h index 6479aa223..500bf5d4b 100644 --- a/shadow/include/aws/iotshadow/IotShadowClient.h +++ b/shadow/include/aws/iotshadow/IotShadowClient.h @@ -11,6 +11,7 @@ #include #include +#include #include namespace Aws @@ -103,6 +104,7 @@ namespace Aws { public: IotShadowClient(const std::shared_ptr &connection); + IotShadowClient(const std::shared_ptr &mqtt5Client); operator bool() const noexcept; int GetLastError() const noexcept; diff --git a/shadow/source/IotShadowClient.cpp b/shadow/source/IotShadowClient.cpp index c265e691e..25ba00ebf 100644 --- a/shadow/source/IotShadowClient.cpp +++ b/shadow/source/IotShadowClient.cpp @@ -38,6 +38,11 @@ namespace Aws { } + IotShadowClient::IotShadowClient(const std::shared_ptr &mqtt5Client) + { + m_connection = Aws::Crt::Mqtt::MqttConnection::NewConnectionFromMqtt5Client(mqtt5Client); + } + IotShadowClient::operator bool() const noexcept { return m_connection && *m_connection; } int IotShadowClient::GetLastError() const noexcept { return aws_last_error(); }