Skip to content

Commit

Permalink
revert zmq CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
farhangnaderi committed Nov 18, 2024
1 parent 29fcf18 commit d487a0a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 67 deletions.
40 changes: 8 additions & 32 deletions cmake/FindZeroMQ.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,14 @@
# set(ZeroMQ_FOUND TRUE)
# set(ZeroMQ_INCLUDE_DIRS ${ZMQ_INCLUDE_DIRS})
# set(ZeroMQ_LIBRARIES ${ZMQ_LIBRARIES})
# First, try to use PkgConfig to find ZeroMQ

find_package(PkgConfig QUIET)
if (PKG_CONFIG_FOUND)
pkg_check_modules(ZMQ libzmq)
find_path ( ZeroMQ_INCLUDE_DIR zmq.h )
find_library ( ZeroMQ_LIBRARY NAMES zmq )

if (ZMQ_FOUND)
message(STATUS "Found ZeroMQ using pkg-config")
set(ZeroMQ_FOUND TRUE)
set(ZeroMQ_INCLUDE_DIRS ${ZMQ_INCLUDE_DIRS})
set(ZeroMQ_LIBRARIES ${ZMQ_LIBRARIES})
else()
message(WARNING "PkgConfig could not find ZeroMQ, falling back to manual search")
endif()
endif()
set ( ZeroMQ_LIBRARIES ${ZeroMQ_LIBRARY} )
set ( ZeroMQ_INCLUDE_DIRS ${ZeroMQ_INCLUDE_DIR} )

# Fallback: if PkgConfig was not found or ZeroMQ was not found with pkg-config, use manual find
if (NOT ZeroMQ_FOUND)
message(STATUS "Attempting to find ZeroMQ using manual search")

find_path(ZeroMQ_INCLUDE_DIR zmq.h)
find_library(ZeroMQ_LIBRARY NAMES zmq)

set(ZeroMQ_LIBRARIES ${ZeroMQ_LIBRARY})
set(ZeroMQ_INCLUDE_DIRS ${ZeroMQ_INCLUDE_DIR})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ZeroMQ DEFAULT_MSG ZeroMQ_LIBRARY ZeroMQ_INCLUDE_DIR)

if (ZeroMQ_FOUND)
message(STATUS "Found ZeroMQ using manual search")
else()
message(WARNING "ZeroMQ not found. Some features may be disabled.")
endif()
endif()
include ( FindPackageHandleStandardArgs )
# handle the QUIETLY and REQUIRED arguments and set ZeroMQ_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args ( ZeroMQ DEFAULT_MSG ZeroMQ_LIBRARY ZeroMQ_INCLUDE_DIR )
49 changes: 14 additions & 35 deletions plotjuggler_plugins/DataStreamZMQ/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,54 +1,33 @@
# Check for vcpkg, conan, or manual build environments
if(BUILDING_WITH_VCPKG)
message(STATUS "Finding ZeroMQ with vcpkg")
elseif(BUILDING_WITH_CONAN)
message(STATUS "Finding ZeroMQ with conan")
else()
message(STATUS "Finding ZeroMQ without package managers")

# Find ZeroMQ using PkgConfig
find_package(PkgConfig REQUIRED)
pkg_check_modules(ZMQ REQUIRED libzmq)

# Set the ZeroMQ libraries and include directories for manual configuration
set(ZeroMQ_LIBRARIES ${ZMQ_LIBRARIES})
set(ZeroMQ_INCLUDE_DIRS ${ZMQ_INCLUDE_DIRS})
set(ZeroMQ_LIBRARY_DIRS /opt/homebrew/lib) # Add this line

# Add the library path explicitly
link_directories(${ZeroMQ_LIBRARY_DIRS}) # Add this line
set(ZeroMQ_LIBS ${ZeroMQ_LIBRARIES})
endif()

# Find ZeroMQ library
find_package(ZeroMQ QUIET)

# Check if ZeroMQ was found
if(ZeroMQ_FOUND)
message(STATUS "[ZeroMQ] found")
# message(STATUS "[ZeroMQ] found")

# Add QT definitions if needed
add_definitions(${QT_DEFINITIONS})
add_definitions(-DQT_PLUGIN)
# add_definitions(${QT_DEFINITIONS})
# add_definitions(-DQT_PLUGIN)

# Wrap the UI file for Qt
QT5_WRAP_UI(UI_SRC datastream_zmq.ui)
# QT5_WRAP_UI ( UI_SRC datastream_zmq.ui )

# Add the DataStreamZMQ library
add_library(DataStreamZMQ SHARED datastream_zmq.cpp ${UI_SRC})
# add_library(DataStreamZMQ SHARED datastream_zmq.cpp ${UI_SRC} )

# Link Qt5Widgets and the plotjuggler_base target to DataStreamZMQ
target_link_libraries(DataStreamZMQ ${Qt5Widgets_LIBRARIES} plotjuggler_base)
# target_link_libraries(DataStreamZMQ ${Qt5Widgets_LIBRARIES} plotjuggler_base)

# Handle different library linking for vcpkg, conan, or manual builds
if(BUILDING_WITH_VCPKG OR BUILDING_WITH_CONAN)
target_link_libraries(DataStreamZMQ libzmq-static)
else()
target_include_directories(DataStreamZMQ PRIVATE ${ZeroMQ_INCLUDE_DIRS})
target_link_libraries(DataStreamZMQ zmq) # Changed this to just 'zmq'
endif()
# if(BUILDING_WITH_VCPKG OR BUILDING_WITH_CONAN)
# target_link_libraries(DataStreamZMQ libzmq-static)
# else()
# target_link_libraries(DataStreamZMQ ${ZeroMQ_LIBRARIES})
# endif()

# Install the plugin
install(TARGETS DataStreamZMQ DESTINATION ${PJ_PLUGIN_INSTALL_DIRECTORY})
# install(TARGETS DataStreamZMQ DESTINATION ${PJ_PLUGIN_INSTALL_DIRECTORY} )
else()
message(STATUS "[ZeroMQ] not found. Skipping plugin DataStreamZMQ.")
message("[ZeroMQ] not found. Skipping plugin DataStreamZMQ.")
endif()

0 comments on commit d487a0a

Please sign in to comment.