Skip to content

Commit 8355da7

Browse files
committed
Fix Paho C build
1 parent 2bb54f0 commit 8355da7

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "src/externals/paho-mqtt-c"]
22
path = src/externals/paho-mqtt-c
3-
url = https://github.com/eclipse/paho.mqtt.c.git
3+
url = ../../eclipse/paho.mqtt.c.git

CMakeLists.txt

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
# All rights reserved. This program and the accompanying materials
1212
# are made available under the terms of the Eclipse Public License v2.0
1313
# and Eclipse Distribution License v1.0 which accompany this distribution.
14-
#
14+
#
1515
# The Eclipse Public License is available at
1616
# http://www.eclipse.org/legal/epl-v20.html
1717
# and the Eclipse Distribution License is available at
1818
# http://www.eclipse.org/org/documents/edl-v10.php.
19-
#
19+
#
2020
# Contributors:
2121
# Guilherme Maciel Ferreira - initial version
2222
# Frank Pagliughi
@@ -50,14 +50,25 @@ endif()
5050

5151
## --- Find Paho C or build it, if reqested ---
5252

53+
if(PAHO_WITH_SSL)
54+
find_package(OpenSSL REQUIRED)
55+
set(PAHO_MQTT_C_LIB paho-mqtt3as)
56+
else()
57+
set(PAHO_MQTT_C_LIB paho-mqtt3a)
58+
endif()
59+
60+
if(PAHO_BUILD_STATIC AND NOT PAHO_BUILD_SHARED)
61+
set(PAHO_MQTT_C_LIB ${PAHO_MQTT_C_LIB}-static)
62+
endif()
63+
5364
if(PAHO_WITH_MQTT_C)
5465
message(STATUS "Paho C: Bundled")
5566

5667
## Build the Paho C library from the submodule
5768
set(PAHO_ENABLE_TESTING FALSE CACHE BOOL "No Paho C tests")
5869
set(PAHO_HIGH_PERFORMANCE TRUE CACHE BOOL "Paho C high performance")
5970

60-
add_subdirectory(${PROJECT_SOURCE_DIR}/externals/paho-mqtt-c)
71+
add_subdirectory(${PROJECT_SOURCE_DIR}/src/externals/paho-mqtt-c EXCLUDE_FROM_ALL)
6172

6273
## Alias namespace so that the full names can be used with the subdir.
6374
if(PAHO_BUILD_SHARED)
@@ -83,16 +94,7 @@ else()
8394
find_package(eclipse-paho-mqtt-c REQUIRED)
8495
endif()
8596

86-
if(PAHO_WITH_SSL)
87-
find_package(OpenSSL REQUIRED)
88-
set(PAHO_MQTT_C_LIB eclipse-paho-mqtt-c::paho-mqtt3as)
89-
else()
90-
set(PAHO_MQTT_C_LIB eclipse-paho-mqtt-c::paho-mqtt3a)
91-
endif()
92-
93-
if(PAHO_BUILD_STATIC AND NOT PAHO_BUILD_SHARED)
94-
set(PAHO_MQTT_C_LIB ${PAHO_MQTT_C_LIB}-static)
95-
endif()
97+
set(PAHO_MQTT_C_LIB "eclipse-paho-mqtt-c::${PAHO_MQTT_C_LIB}")
9698

9799
## --- C++11 build flags ---
98100

@@ -161,4 +163,3 @@ endif()
161163
include(CPack)
162164

163165
add_subdirectory(cmake)
164-

src/CMakeLists.txt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
#
1212
# All rights reserved. This program and the accompanying materials
1313
# are made available under the terms of the Eclipse Public License v2.0
14-
# and Eclipse Distribution License v1.0 which accompany this distribution.
15-
#
16-
# The Eclipse Public License is available at
14+
# and Eclipse Distribution License v1.0 which accompany this distribution.
15+
#
16+
# The Eclipse Public License is available at
1717
# http://www.eclipse.org/legal/epl-v20.html
18-
# and the Eclipse Distribution License is available at
18+
# and the Eclipse Distribution License is available at
1919
# http://www.eclipse.org/org/documents/edl-v10.php.
20-
#
20+
#
2121
# Contributors:
2222
# Guilherme Maciel Ferreira - initial version
2323
# Frank Pagliughi - made the shared library optional
@@ -38,7 +38,7 @@ set(COMMON_SRC
3838
async_client.cpp
3939
client.cpp
4040
connect_options.cpp
41-
create_options.cpp
41+
create_options.cpp
4242
disconnect_options.cpp
4343
iclient_persistence.cpp
4444
message.cpp
@@ -61,7 +61,6 @@ if(PAHO_BUILD_SHARED)
6161

6262
## Add dependencies to the shared library
6363
target_link_libraries(paho-mqttpp3 PUBLIC
64-
eclipse-paho-mqtt-c::paho-mqtt3as
6564
${PAHO_MQTT_C_LIB}
6665
Threads::Threads
6766
)
@@ -81,7 +80,7 @@ if(PAHO_BUILD_STATIC)
8180
list(APPEND PAHO_CPP_TARGETS paho-mqttpp3-static)
8281

8382
## add dependencies to the shared library
84-
target_link_libraries(paho-mqttpp3-static PUBLIC
83+
target_link_libraries(paho-mqttpp3-static PUBLIC
8584
${PAHO_MQTT_C_LIB}
8685
Threads::Threads
8786
)

0 commit comments

Comments
 (0)