-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: adapt cmake to find mosquitto on windows
- Loading branch information
1 parent
0986ae1
commit d7d6082
Showing
5 changed files
with
116 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# FindMosquitto.cmake - Locate the Mosquitto library and headers | ||
# This module defines the following variables: | ||
# Mosquitto_FOUND - Set to TRUE if the library and headers are found | ||
# Mosquitto_INCLUDE_DIRS - Path to the Mosquitto headers | ||
# Mosquitto_LIBRARIES - Path to the Mosquitto library | ||
# It also defines an imported target `Mosquitto::Mosquitto` if found | ||
|
||
# Check for platform-specific library name | ||
if (WIN32) | ||
set(MOSQUITTO_LIB_NAMES mosquitto) # On Windows, the library is usually named `mosquitto.lib` | ||
else () | ||
set(MOSQUITTO_LIB_NAMES mosquitto) # On Linux, it is usually named `libmosquitto.so` or `libmosquitto.a` | ||
endif () | ||
|
||
# Locate the Mosquitto include directory | ||
find_path(Mosquitto_INCLUDE_DIR | ||
NAMES mosquitto.h | ||
HINTS | ||
# Custom hint paths for common installation locations on Linux | ||
/usr/include | ||
/usr/local/include | ||
# Custom hint paths for Windows (assuming installation under Program Files or a common directory) | ||
$ENV{PROGRAMFILES}/mosquitto/devel | ||
#$ENV{PROGRAMFILES(X86)}/mosquitto/devel | ||
PATH_SUFFIXES include | ||
DOC "Path to the Mosquitto include directory" | ||
) | ||
|
||
# Locate the Mosquitto library | ||
find_library(Mosquitto_LIBRARY | ||
NAMES ${MOSQUITTO_LIB_NAMES} | ||
HINTS | ||
# Custom hint paths for common library locations on Linux | ||
/usr/lib | ||
/usr/local/lib | ||
# Custom hint paths for Windows | ||
$ENV{PROGRAMFILES}/mosquitto/devel | ||
#$ENV{PROGRAMFILES(X86)}/mosquitto/devel | ||
PATH_SUFFIXES lib | ||
DOC "Path to the Mosquitto library" | ||
) | ||
|
||
# Use standard package handling to verify both library and include paths were found | ||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(Mosquitto | ||
REQUIRED_VARS Mosquitto_LIBRARY Mosquitto_INCLUDE_DIR | ||
VERSION_VAR Mosquitto_VERSION | ||
) | ||
|
||
# Define convenient variables for include directories and library paths | ||
set(Mosquitto_INCLUDE_DIRS ${Mosquitto_INCLUDE_DIR}) | ||
set(Mosquitto_LIBRARIES ${Mosquitto_LIBRARY}) | ||
|
||
# If Mosquitto is found, define an imported target for linking | ||
if (Mosquitto_FOUND) | ||
add_library(Mosquitto::Mosquitto UNKNOWN IMPORTED) | ||
set_target_properties(Mosquitto::Mosquitto PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES "${Mosquitto_INCLUDE_DIRS}" | ||
IMPORTED_LOCATION "${Mosquitto_LIBRARIES}" | ||
) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters