From 9533991e1f71f4d69a7021e47d0731c873d12e48 Mon Sep 17 00:00:00 2001 From: Tinson Lai Date: Sun, 31 Dec 2023 14:47:06 +0800 Subject: [PATCH] Fix Paho C build --- .gitmodules | 2 +- CMakeLists.txt | 29 +++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.gitmodules b/.gitmodules index e328902a..4e6ae515 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "src/externals/paho-mqtt-c"] path = src/externals/paho-mqtt-c - url = https://github.com/eclipse/paho.mqtt.c.git + url = ../paho.mqtt.c.git diff --git a/CMakeLists.txt b/CMakeLists.txt index fbcee9ed..b9589f78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,12 +11,12 @@ # All rights reserved. This program and the accompanying materials # are made available under the terms of the Eclipse Public License v2.0 # and Eclipse Distribution License v1.0 which accompany this distribution. -# +# # The Eclipse Public License is available at # http://www.eclipse.org/legal/epl-v20.html # and the Eclipse Distribution License is available at # http://www.eclipse.org/org/documents/edl-v10.php. -# +# # Contributors: # Guilherme Maciel Ferreira - initial version # Frank Pagliughi @@ -50,6 +50,17 @@ endif() ## --- Find Paho C or build it, if reqested --- +if(PAHO_WITH_SSL) + find_package(OpenSSL REQUIRED) + set(PAHO_MQTT_C_LIB paho-mqtt3as) +else() + set(PAHO_MQTT_C_LIB paho-mqtt3a) +endif() + +if(PAHO_BUILD_STATIC AND NOT PAHO_BUILD_SHARED) + set(PAHO_MQTT_C_LIB ${PAHO_MQTT_C_LIB}-static) +endif() + if(PAHO_WITH_MQTT_C) message(STATUS "Paho C: Bundled") @@ -57,7 +68,7 @@ if(PAHO_WITH_MQTT_C) set(PAHO_ENABLE_TESTING FALSE CACHE BOOL "No Paho C tests") set(PAHO_HIGH_PERFORMANCE TRUE CACHE BOOL "Paho C high performance") - add_subdirectory(${PROJECT_SOURCE_DIR}/externals/paho-mqtt-c) + add_subdirectory(${PROJECT_SOURCE_DIR}/src/externals/paho-mqtt-c EXCLUDE_FROM_ALL) ## Alias namespace so that the full names can be used with the subdir. if(PAHO_BUILD_SHARED) @@ -83,16 +94,7 @@ else() find_package(eclipse-paho-mqtt-c REQUIRED) endif() -if(PAHO_WITH_SSL) - find_package(OpenSSL REQUIRED) - set(PAHO_MQTT_C_LIB eclipse-paho-mqtt-c::paho-mqtt3as) -else() - set(PAHO_MQTT_C_LIB eclipse-paho-mqtt-c::paho-mqtt3a) -endif() - -if(PAHO_BUILD_STATIC AND NOT PAHO_BUILD_SHARED) - set(PAHO_MQTT_C_LIB ${PAHO_MQTT_C_LIB}-static) -endif() +set(PAHO_MQTT_C_LIB "eclipse-paho-mqtt-c::${PAHO_MQTT_C_LIB}") ## --- C++11 build flags --- @@ -161,4 +163,3 @@ endif() include(CPack) add_subdirectory(cmake) -