Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 26, 2024
1 parent 196c31d commit 0940cf5
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 62 deletions.
75 changes: 34 additions & 41 deletions cmake/FindMosquitto.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,21 @@
# Contact KDAB at <[email protected]> for commercial licensing options.
#

find_file(MOSQUITTO_HEADER
NAMES
mosquitto.h
PATHS
/usr/include
/usr/local/include
/usr/local/opt/mosquitto/include
$ENV{PROGRAMFILES}/mosquitto/devel
$ENV{PROGRAMFILES\(X86\)}/mosquitto/devel
find_file(
MOSQUITTO_HEADER
NAMES mosquitto.h
PATHS /usr/include
/usr/local/include
/usr/local/opt/mosquitto/include
$ENV{PROGRAMFILES}/mosquitto/devel
$ENV{PROGRAMFILES\(X86\)}/mosquitto/devel
)

if(APPLE OR UNIX)
find_library(MOSQUITTO_LIBRARY
NAMES
mosquitto
PATHS
/usr/lib
/usr/local/lib
/usr/local/opt/mosquitto/lib
find_library(
MOSQUITTO_LIBRARY
NAMES mosquitto
PATHS /usr/lib /usr/local/lib /usr/local/opt/mosquitto/lib
)

if(MOSQUITTO_HEADER AND MOSQUITTO_LIBRARY)
Expand All @@ -35,28 +31,24 @@ if(APPLE OR UNIX)
endif()

if(WIN32)
find_file(MOSQUITTO_DLL
NAMES
mosquitto.dll
PATHS
$ENV{PROGRAMFILES}/mosquitto
$ENV{PROGRAMFILES\(X86\)}/mosquitto
find_file(
MOSQUITTO_DLL
NAMES mosquitto.dll
PATHS $ENV{PROGRAMFILES}/mosquitto $ENV{PROGRAMFILES\(X86\)}/mosquitto
)

find_library(MOSQUITTO_LIBRARY
NAMES
mosquitto
PATHS
$ENV{PROGRAMFILES}/mosquitto/devel
$ENV{PROGRAMFILES\(X86\)}/mosquitto/devel
find_library(
MOSQUITTO_LIBRARY
NAMES mosquitto
PATHS $ENV{PROGRAMFILES}/mosquitto/devel $ENV{PROGRAMFILES\(X86\)}/mosquitto/devel
)

file(GLOB MOSQUITTO_RUNTIME_DLLS
"$ENV{PROGRAMFILES}/mosquitto/*.dll"
"$ENV{PROGRAMFILES\(X86\)}/mosquitto/*.dll"
)
file(GLOB MOSQUITTO_RUNTIME_DLLS "$ENV{PROGRAMFILES}/mosquitto/*.dll" "$ENV{PROGRAMFILES\(X86\)}/mosquitto/*.dll")

if(MOSQUITTO_HEADER AND MOSQUITTO_DLL AND MOSQUITTO_LIBRARY)
if(MOSQUITTO_HEADER
AND MOSQUITTO_DLL
AND MOSQUITTO_LIBRARY
)
set(Mosquitto_FOUND TRUE)
endif()
endif()
Expand All @@ -67,18 +59,19 @@ if(Mosquitto_FOUND)
add_library(Mosquitto::Mosquitto SHARED IMPORTED)

if(APPLE OR UNIX)
set_target_properties(Mosquitto::Mosquitto PROPERTIES
IMPORTED_LOCATION "${MOSQUITTO_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${MOSQUITTO_INCLUDE_DIRECTORY}"
set_target_properties(
Mosquitto::Mosquitto PROPERTIES IMPORTED_LOCATION "${MOSQUITTO_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES
"${MOSQUITTO_INCLUDE_DIRECTORY}"
)
endif()

if(WIN32)
set_target_properties(Mosquitto::Mosquitto PROPERTIES
IMPORTED_IMPLIB "${MOSQUITTO_LIBRARY}"
IMPORTED_LOCATION "${MOSQUITTO_DLL}"
INTERFACE_INCLUDE_DIRECTORIES "${MOSQUITTO_INCLUDE_DIRECTORY}"
)
set_target_properties(
Mosquitto::Mosquitto
PROPERTIES IMPORTED_IMPLIB "${MOSQUITTO_LIBRARY}"
IMPORTED_LOCATION "${MOSQUITTO_DLL}"
INTERFACE_INCLUDE_DIRECTORIES "${MOSQUITTO_INCLUDE_DIRECTORY}"
)
endif()

endif()
16 changes: 8 additions & 8 deletions examples/mqtt_client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ add_executable(
)

target_link_libraries(
${PROJECT_NAME}
KDMqtt
${PROJECT_NAME} KDMqtt
)

if (WIN32)
if(WIN32)
# Deployment: On Windows, copy all DLLs from the mosquitto install directory next to the application binary so that they're found.
if (BUILD_INTEGRATION_MQTT AND MOSQUITTO_RUNTIME_DLLS)
if(BUILD_INTEGRATION_MQTT AND MOSQUITTO_RUNTIME_DLLS)
foreach(MOSQUITTO_RUNTIME_DLL ${MOSQUITTO_RUNTIME_DLLS})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${MOSQUITTO_RUNTIME_DLL}"
$<TARGET_FILE_DIR:${PROJECT_NAME}>
add_custom_command(
TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${MOSQUITTO_RUNTIME_DLL}"
$<TARGET_FILE_DIR:${PROJECT_NAME}>
)
endforeach()
endif()
Expand Down
13 changes: 3 additions & 10 deletions src/KDMqtt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,9 @@
# Contact KDAB at <[email protected]> for commercial licensing options.
#

set(SOURCES
mqtt.cpp
)
set(SOURCES mqtt.cpp)

set(HEADERS
mosquitto_wrapper.h
mqtt.h
)
set(HEADERS mosquitto_wrapper.h mqtt.h)

add_library(
KDMqtt
Expand Down Expand Up @@ -50,9 +45,7 @@ target_link_libraries(
)

generate_export_header(KDMqtt BASE_NAME kdmqtt)
configure_file(
${CMAKE_CURRENT_BINARY_DIR}/kdmqtt_export.h ${CMAKE_BINARY_DIR}/include/KDMqtt/kdmqtt_export.h
)
configure_file(${CMAKE_CURRENT_BINARY_DIR}/kdmqtt_export.h ${CMAKE_BINARY_DIR}/include/KDMqtt/kdmqtt_export.h)
# configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h ${CMAKE_BINARY_DIR}/include/KDMqtt/config.h)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/kdmqtt_export.h
Expand Down
2 changes: 1 addition & 1 deletion src/KDMqtt/mosquitto_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,4 @@ class MosquittoClient
struct mosquitto *m_clientInstance;
};

}
} // namespace KDMqtt
2 changes: 1 addition & 1 deletion src/KDMqtt/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,4 +520,4 @@ int MqttClient::SubscriptionsRegistry::grantedQosForTopic(const std::string &top
return qosByTopicOfActiveSubscriptions.at(topic);
}

}
} // namespace KDMqtt
2 changes: 1 addition & 1 deletion src/KDMqtt/mqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,4 @@ class KDMQTT_API MqttClient : public IMqttClient
SubscriptionsRegistry m_subscriptionsRegistry;
};

}
} // namespace KDMqtt

0 comments on commit 0940cf5

Please sign in to comment.