From 2c85050fb039114fc3b912feb2e0ad582d02d25f Mon Sep 17 00:00:00 2001 From: Will MacCormack Date: Thu, 4 Jan 2024 21:00:39 -0800 Subject: [PATCH] Link against Abseil for macOS builds & improve macOS compile docs #845 --- COMPILE.md | 21 +++++++++++++------ .../ParserProtobuf/CMakeLists.txt | 8 +++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/COMPILE.md b/COMPILE.md index 9fb63b17b..8529876b6 100644 --- a/COMPILE.md +++ b/COMPILE.md @@ -90,20 +90,29 @@ On Mac, the dependencies can be installed using [brew](https://brew.sh/) with th brew install cmake qt@5 protobuf mosquitto zeromq zstd ``` +If a newer version of qt is installed, you may need to temporarily link to qt5 + +```shell +brew link qt@5 --override +# brew link qt --override # Run once you are done building to restore the original linking +``` + Add CMake into your env-vars to be detected by cmake ```shell -echo "export CPPFLAGS=\"-I/opt/homebrew/opt/qt@5/include\"" >> $HOME/.zshrc -echo "export PKG_CONFIG_PATH=\"/opt/homebrew/opt/qt@5/lib/pkgconfig\"" >> $HOME/.zshrc -echo "export LDFLAGS=\"/opt/homebrew/opt/qt@5/lib\"" >> $HOME/.zshrc +echo 'QT_HOME=$(brew --prefix qt@5) \ +export CPPFLAGS="-I $QT_HOME/include" \ +export PKG_CONFIG_PATH="$QT_HOME/lib/pkgconfig" \ +export LDFLAGS="$QT_HOME/lib"' >> $HOME/.zshrc ``` If you don't want to permanently add them into your main file, you can try by just exporting locally in the current terminal with: ```shell -export CPPFLAGS="-I/opt/homebrew/opt/qt@5/include" -export PKG_CONFIG_PATH="/opt/homebrew/opt/qt@5/lib/pkgconfig" -export LDFLAGS="/opt/homebrew/opt/qt@5/lib" +QT_HOME=$(brew --prefix qt@5) +export CPPFLAGS="-I $QT_HOME/include" +export PKG_CONFIG_PATH="$QT_HOME/lib/pkgconfig" +export LDFLAGS="$QT_HOME/lib" ``` Clone the repository into **~/plotjuggler_ws**: diff --git a/plotjuggler_plugins/ParserProtobuf/CMakeLists.txt b/plotjuggler_plugins/ParserProtobuf/CMakeLists.txt index 084c93cb2..084246a60 100644 --- a/plotjuggler_plugins/ParserProtobuf/CMakeLists.txt +++ b/plotjuggler_plugins/ParserProtobuf/CMakeLists.txt @@ -21,6 +21,14 @@ if( Protobuf_FOUND) protobuf_parser.h ${UI_SRC} ) + if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + find_library(ABSL_SPINLOCK_WAIT_LIB absl_spinlock_wait) + + target_link_libraries(ProtobufParser + ${ABSL_SPINLOCK_WAIT_LIB} + ) + endif() + target_link_libraries(ProtobufParser ${Qt5Widgets_LIBRARIES} ${Qt5Xml_LIBRARIES}