From 958f3a6dd3ac541b93d4568cd0fc1d49831d08d1 Mon Sep 17 00:00:00 2001 From: Will MacCormack Date: Fri, 26 Jan 2024 05:53:39 -0500 Subject: [PATCH] Link against Abseil for macOS builds & improve macOS compile docs #845 (#905) * Link against Abseil for macOS builds & improve macOS compile docs #845 * Update plotjuggler_plugins/ParserProtobuf/CMakeLists.txt --------- Co-authored-by: Davide Faconti --- COMPILE.md | 21 +++++++++++++------ .../ParserProtobuf/CMakeLists.txt | 6 ++++++ 2 files changed, 21 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..740d796a6 100644 --- a/plotjuggler_plugins/ParserProtobuf/CMakeLists.txt +++ b/plotjuggler_plugins/ParserProtobuf/CMakeLists.txt @@ -21,6 +21,12 @@ 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}