59 lines
2.4 KiB
CMake
59 lines
2.4 KiB
CMake
# Paho.cmake - provide Eclipse Paho MQTT C and C++ via FetchContent.
|
|
#
|
|
# Rationale (security): we build Paho from its OFFICIAL upstream Git repos
|
|
# rather than from the AUR. This removes the anonymous AUR packager from the
|
|
# trust chain - you trust only the Eclipse project source.
|
|
#
|
|
# HARDENING (recommended): the tags below are mutable refs. For maximum
|
|
# integrity, pin PAHO_C_TAG / PAHO_CPP_TAG to a full commit SHA (immutable),
|
|
# or switch to URL + URL_HASH (SHA256) of the signed release tarballs and
|
|
# verify the hash out-of-band. Bump the versions deliberately, not silently.
|
|
#
|
|
# NOTE: these exact tag strings and the cross-build wiring below must be
|
|
# verified on a machine with network access + cmake; they could not be built
|
|
# offline in the environment where this file was authored.
|
|
|
|
include(FetchContent)
|
|
|
|
set(PAHO_C_TAG "v1.3.14" CACHE STRING "Eclipse paho.mqtt.c git tag/commit")
|
|
set(PAHO_CPP_TAG "v1.4.1" CACHE STRING "Eclipse paho.mqtt.cpp git tag/commit")
|
|
|
|
# ---- Paho MQTT C (dependency of the C++ wrapper) ----
|
|
set(PAHO_BUILD_SHARED OFF CACHE BOOL "" FORCE)
|
|
set(PAHO_BUILD_STATIC ON CACHE BOOL "" FORCE)
|
|
set(PAHO_WITH_SSL OFF CACHE BOOL "" FORCE) # current code uses plain tcp://
|
|
set(PAHO_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
|
|
set(PAHO_BUILD_SAMPLES OFF CACHE BOOL "" FORCE)
|
|
set(PAHO_BUILD_DOCUMENTATION OFF CACHE BOOL "" FORCE)
|
|
|
|
FetchContent_Declare(paho_mqtt_c
|
|
GIT_REPOSITORY https://github.com/eclipse-paho/paho.mqtt.c.git
|
|
GIT_TAG ${PAHO_C_TAG}
|
|
GIT_SHALLOW TRUE
|
|
)
|
|
|
|
# ---- Paho MQTT C++ ----
|
|
set(PAHO_BUILD_CPP_SHARED OFF CACHE BOOL "" FORCE)
|
|
set(PAHO_BUILD_CPP_STATIC ON CACHE BOOL "" FORCE)
|
|
|
|
FetchContent_Declare(paho_mqtt_cpp
|
|
GIT_REPOSITORY https://github.com/eclipse-paho/paho.mqtt.cpp.git
|
|
GIT_TAG ${PAHO_CPP_TAG}
|
|
GIT_SHALLOW TRUE
|
|
)
|
|
|
|
FetchContent_MakeAvailable(paho_mqtt_c paho_mqtt_cpp)
|
|
|
|
# Provide a stable alias the top-level CMakeLists links against, regardless of
|
|
# the exact target name the upstream version exports.
|
|
if(NOT TARGET PahoMqttCpp::paho-mqttpp3-static)
|
|
if(TARGET paho-mqttpp3-static)
|
|
add_library(PahoMqttCpp::paho-mqttpp3-static ALIAS paho-mqttpp3-static)
|
|
elseif(TARGET paho-mqttpp3)
|
|
add_library(PahoMqttCpp::paho-mqttpp3-static ALIAS paho-mqttpp3)
|
|
else()
|
|
message(FATAL_ERROR "Paho C++ static target not found after FetchContent; "
|
|
"check PAHO_CPP_TAG and upstream target names.")
|
|
endif()
|
|
endif()
|