зеркало из https://github.com/Azure/azure-umqtt-c.git
Makes umqtt installable and a find module in CMake. Builds with -fPIC always.
This commit is contained in:
Родитель
ea9860f447
Коммит
1893b5c606
|
@ -4,6 +4,7 @@
|
|||
|
||||
/build_all/windows/nuget.exe
|
||||
/cmake
|
||||
/build
|
||||
/devdoc/~$o_requirements.docm
|
||||
*.jar
|
||||
|
||||
|
|
|
@ -9,6 +9,9 @@ endif()
|
|||
|
||||
project(umqtt)
|
||||
|
||||
# Build with -fPIC always
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||
|
||||
#making a nice global variable to know if we are on linux or not.
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(LINUX TRUE)
|
||||
|
@ -30,6 +33,7 @@ include(ExternalProject)
|
|||
option(skip_unittests "set skip_unittests to ON to skip unittests (default is OFF)[if possible, they are always build]" OFF)
|
||||
option(compileOption_C "passes a string to the command line of the C compiler" OFF)
|
||||
option(compileOption_CXX "passes a string to the command line of the C++ compiler" OFF)
|
||||
option(use_installed_dependencies "set use_installed_dependencies to ON to use installed packages instead of building dependencies from submodules" OFF)
|
||||
|
||||
#Use solution folders.
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
@ -65,10 +69,7 @@ endif()
|
|||
|
||||
message(STATUS "MQTT Target architecture: ${ARCHITECTURE}")
|
||||
|
||||
# Start of variables used during install
|
||||
#set (INCLUDE_INSTALL_DIR include CACHE PATH "Include file directory")
|
||||
|
||||
add_subdirectory(c-utility)
|
||||
include("dependencies.cmake")
|
||||
|
||||
enable_testing()
|
||||
|
||||
|
@ -164,11 +165,50 @@ if (NOT ${ARCHITECTURE} STREQUAL "ARM")
|
|||
endif()
|
||||
|
||||
if (NOT ${skip_unittests})
|
||||
include("dependencies-test.cmake")
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
else()
|
||||
install (TARGETS umqtt DESTINATION lib)
|
||||
install (FILES ${source_h_files} DESTINATION include/azureiot/azure_umqtt_c)
|
||||
endif (WIN32)
|
||||
if(${use_installed_dependencies})
|
||||
# Set CMAKE_INSTALL_LIBDIR if not defined
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# Install umqtt
|
||||
set(package_location "cmake")
|
||||
|
||||
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
||||
set(CMAKE_INSTALL_LIBDIR "lib")
|
||||
endif()
|
||||
|
||||
install(TARGETS umqtt EXPORT umqttTargets
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/../bin
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/azureiot
|
||||
)
|
||||
install(FILES ${source_h_files} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/azureiot/azure_umqtt_c)
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
configure_file("configs/${PROJECT_NAME}Config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}Config.cmake"
|
||||
COPYONLY
|
||||
)
|
||||
|
||||
install(EXPORT umqttTargets
|
||||
FILE
|
||||
"${PROJECT_NAME}Targets.cmake"
|
||||
DESTINATION
|
||||
${package_location}
|
||||
)
|
||||
|
||||
install(
|
||||
FILES
|
||||
"configs/${PROJECT_NAME}Config.cmake"
|
||||
DESTINATION
|
||||
${package_location}
|
||||
)
|
||||
|
||||
else()
|
||||
message(WARNING "This package may only be installed when 'use_installed_dependencies' is ON")
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
#Copyright (c) Microsoft. All rights reserved.
|
||||
#Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/umqttTargets.cmake")
|
||||
|
||||
get_target_property(UMQTT_INCLUDES umqtt INTERFACE_INCLUDE_DIRECTORIES)
|
||||
|
||||
set(UMQTT_INCLUDES ${UMQTT_INCLUDES} CACHE INTERNAL "")
|
|
@ -0,0 +1,14 @@
|
|||
#Copyright (c) Microsoft. All rights reserved.
|
||||
#Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
if(${use_installed_dependencies})
|
||||
#These need to be set for the functions included by c-utility
|
||||
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/c-utility/src")
|
||||
message(FATAL_ERROR "c-utility directory is empty. Please pull in all submodules if building unit tests.")
|
||||
endif()
|
||||
set(SHARED_UTIL_SRC_FOLDER "${CMAKE_CURRENT_LIST_DIR}/c-utility/src")
|
||||
set(SHARED_UTIL_FOLDER "${CMAKE_CURRENT_LIST_DIR}/c-utility")
|
||||
set(SHARED_UTIL_ADAPTER_FOLDER "${CMAKE_CURRENT_LIST_DIR}/c-utility/adapters")
|
||||
set_platform_files("${CMAKE_CURRENT_LIST_DIR}/c-utility")
|
||||
find_package(umock_c REQUIRED CONFIG)
|
||||
endif()
|
|
@ -0,0 +1,8 @@
|
|||
#Copyright (c) Microsoft. All rights reserved.
|
||||
#Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
if(${use_installed_dependencies})
|
||||
find_package(azure_c_shared_utility REQUIRED CONFIG)
|
||||
else()
|
||||
add_subdirectory(c-utility)
|
||||
endif()
|
43
readme.md
43
readme.md
|
@ -9,3 +9,46 @@ azure-mqtt is a general purpose library build for MQTT protocol
|
|||
azure-mqtt client use the azure-c-shared-utility, which is a C library provisioning common functionality for basic tasks (like string, list manipulation, IO, etc.).
|
||||
azure-c-shared-utility is available here: https://github.com/Azure/azure-c-shared-utility.
|
||||
azure-c-shared-utility needs to be built before building azure-mqtt-c.
|
||||
|
||||
## Setup
|
||||
|
||||
- Clone azure-umqtt-c by:
|
||||
```
|
||||
git clone --recursive https://github.com/Azure/azure-umqtt-c.git
|
||||
```
|
||||
- Create a folder build under azure-umqtt-c
|
||||
- Switch to the build folder and run
|
||||
cmake ..
|
||||
|
||||
### Installation and Use
|
||||
Optionally, you may choose to install azure-umqtt-c on your machine:
|
||||
|
||||
1. Switch to the *cmake* folder and run
|
||||
```
|
||||
cmake -Duse_installed=ON ../
|
||||
```
|
||||
```
|
||||
cmake --build . --target install
|
||||
```
|
||||
|
||||
or install using the follow commands for each platform:
|
||||
|
||||
On Linux:
|
||||
```
|
||||
sudo make install
|
||||
```
|
||||
|
||||
On Windows:
|
||||
```
|
||||
msbuild /m INSTALL.vcxproj
|
||||
```
|
||||
|
||||
2. Use it in your project (if installed)
|
||||
```
|
||||
find_package(umqtt REQUIRED CONFIG)
|
||||
target_link_library(yourlib umqtt)
|
||||
```
|
||||
|
||||
_This requires that azure-c-shared-utility is installed (through CMake) on your machine._
|
||||
|
||||
_If running tests, this requires that umock-c, azure-ctest, and azure-c-testrunnerswitcher are installed (through CMake) on your machine._
|
||||
|
|
Загрузка…
Ссылка в новой задаче