mirror of
https://github.com/boostorg/mqtt5.git
synced 2025-07-31 21:14:49 +02:00
Add CMake build and client support
This commit is contained in:
committed by
Ivica Siladić
parent
bf81ab5ee7
commit
6abe93fcc9
4
cmake/dev-mode.cmake
Normal file
4
cmake/dev-mode.cmake
Normal file
@@ -0,0 +1,4 @@
|
||||
include(CTest)
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(test/unit)
|
||||
endif()
|
4
cmake/install-config.cmake
Normal file
4
cmake/install-config.cmake
Normal file
@@ -0,0 +1,4 @@
|
||||
include(CMakeFindDependencyMacro)
|
||||
find_dependency(Boost 1.82)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/async-mqtt5Targets.cmake")
|
66
cmake/install-rules.cmake
Normal file
66
cmake/install-rules.cmake
Normal file
@@ -0,0 +1,66 @@
|
||||
if(PROJECT_IS_TOP_LEVEL)
|
||||
set(
|
||||
CMAKE_INSTALL_INCLUDEDIR "include/async-mqtt5-${PROJECT_VERSION}"
|
||||
CACHE STRING ""
|
||||
)
|
||||
set_property(CACHE CMAKE_INSTALL_INCLUDEDIR PROPERTY TYPE PATH)
|
||||
endif()
|
||||
|
||||
# Project is configured with no languages, so tell GNUInstallDirs the lib dir
|
||||
set(CMAKE_INSTALL_LIBDIR lib CACHE PATH "")
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# find_package(<package>) call for consumers to find this project
|
||||
set(package async-mqtt5)
|
||||
|
||||
install(
|
||||
DIRECTORY include/
|
||||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
COMPONENT async-mqtt5_Development
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS async_mqtt5
|
||||
EXPORT async-mqtt5Targets
|
||||
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
)
|
||||
|
||||
write_basic_package_version_file(
|
||||
"${package}ConfigVersion.cmake"
|
||||
COMPATIBILITY SameMajorVersion
|
||||
ARCH_INDEPENDENT
|
||||
)
|
||||
|
||||
# Allow package maintainers to freely override the path for the configs
|
||||
set(
|
||||
async-mqtt5_INSTALL_CMAKEDIR "${CMAKE_INSTALL_DATADIR}/${package}"
|
||||
CACHE STRING "CMake package config location relative to the install prefix"
|
||||
)
|
||||
set_property(CACHE async-mqtt5_INSTALL_CMAKEDIR PROPERTY TYPE PATH)
|
||||
mark_as_advanced(async-mqtt5_INSTALL_CMAKEDIR)
|
||||
|
||||
install(
|
||||
FILES cmake/install-config.cmake
|
||||
DESTINATION "${async-mqtt5_INSTALL_CMAKEDIR}"
|
||||
RENAME "${package}Config.cmake"
|
||||
COMPONENT async-mqtt5_Development
|
||||
)
|
||||
|
||||
install(
|
||||
FILES "${PROJECT_BINARY_DIR}/${package}ConfigVersion.cmake"
|
||||
DESTINATION "${async-mqtt5_INSTALL_CMAKEDIR}"
|
||||
COMPONENT async-mqtt5_Development
|
||||
)
|
||||
|
||||
install(
|
||||
EXPORT async-mqtt5Targets
|
||||
NAMESPACE Async::
|
||||
DESTINATION "${async-mqtt5_INSTALL_CMAKEDIR}"
|
||||
COMPONENT async-mqtt5_Development
|
||||
)
|
||||
|
||||
if(PROJECT_IS_TOP_LEVEL)
|
||||
include(CPack)
|
||||
endif()
|
6
cmake/project-is-top-level.cmake
Normal file
6
cmake/project-is-top-level.cmake
Normal file
@@ -0,0 +1,6 @@
|
||||
# This variable is set by project() in CMake 3.21+
|
||||
string(
|
||||
COMPARE EQUAL
|
||||
"${CMAKE_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}"
|
||||
PROJECT_IS_TOP_LEVEL
|
||||
)
|
28
cmake/variables.cmake
Normal file
28
cmake/variables.cmake
Normal file
@@ -0,0 +1,28 @@
|
||||
# ---- Developer mode ----
|
||||
|
||||
# Developer mode enables targets and code paths in the CMake scripts that are
|
||||
# only relevant for the developer(s) of async-mqtt5
|
||||
# Targets necessary to build the project must be provided unconditionally, so
|
||||
# consumers can trivially build and package the project
|
||||
if(PROJECT_IS_TOP_LEVEL)
|
||||
option(async-mqtt5_DEVELOPER_MODE "Enable developer mode" OFF)
|
||||
endif()
|
||||
|
||||
# ---- Warning guard ----
|
||||
|
||||
# target_include_directories with the SYSTEM modifier will request the compiler
|
||||
# to omit warnings from the provided paths, if the compiler supports that
|
||||
# This is to provide a user experience similar to find_package when
|
||||
# add_subdirectory or FetchContent is used to consume this project
|
||||
set(warning_guard "")
|
||||
if(NOT PROJECT_IS_TOP_LEVEL)
|
||||
option(
|
||||
async-mqtt5_INCLUDES_WITH_SYSTEM
|
||||
"Use SYSTEM modifier for async-mqtt5's includes, disabling warnings"
|
||||
ON
|
||||
)
|
||||
mark_as_advanced(async-mqtt5_INCLUDES_WITH_SYSTEM)
|
||||
if(async-mqtt5_INCLUDES_WITH_SYSTEM)
|
||||
set(warning_guard SYSTEM)
|
||||
endif()
|
||||
endif()
|
Reference in New Issue
Block a user