diff --git a/.github/workflows/macos.yaml b/.github/workflows/macos.yaml index 62e79945e..b3d7eef72 100644 --- a/.github/workflows/macos.yaml +++ b/.github/workflows/macos.yaml @@ -1,38 +1,41 @@ name: macos -on: [push, pull_request] +on: + push: + branches: + - 'main' + pull_request: + branches: + - '*' jobs: - macos-build: - runs-on: ${{ matrix.macos-version }} + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - macos-version: - - 'macos-latest' + os: + - macos-13 + - macos-latest steps: - name: Sync repository uses: actions/checkout@v2 - - name: Cache Qt - id: cache-qt - uses: actions/cache@v1 # not v2! - with: - path: '${{ github.workspace }}/qt_installation/' - key: ${{ runner.os }}-QtCache + - name: Prepare Homebrew and Install Dependencies + run: | + rm -rf /usr/local/var/homebrew/locks + brew cleanup -s + brew update + brew install mosquitto zeromq qt@5 - - name: Install Qt - uses: jurplel/install-qt-action@v2.13.0 - with: - version: '5.15.2' - host: 'mac' - dir: '${{ github.workspace }}/qt_installation/' - cached: ${{ steps.cache-qt.outputs.cache-hit }} + - name: Build PlotJuggler + run: | + export CMAKE_PREFIX_PATH=$(brew --prefix qt@5):$(brew --prefix zeromq) + export LDFLAGS="-L/usr/local/opt/zeromq/lib" + export CPPFLAGS="-I/usr/local/opt/zeromq/include" + export LIBRARY_PATH=/usr/local/opt/zeromq/lib + export CPATH=/usr/local/opt/zeromq/include - - name: Build Plotjuggler - shell: pwsh - run: > - cmake -B build -DCMAKE_INSTALL_PREFIX=install PlotJuggler; + cmake -B build -DCMAKE_INSTALL_PREFIX=install PlotJuggler cmake --build build --target install diff --git a/COMPILE.md b/COMPILE.md index fbae2d4e0..2d6dca5eb 100644 --- a/COMPILE.md +++ b/COMPILE.md @@ -90,11 +90,13 @@ 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 +If you have multiple versions of Qt installed (e.g., `qt` and `qt@5`), you may need to explicitly link `qt@5` to ensure it is found by CMake. Use the following commands: ```shell -brew link qt@5 --override -# brew link qt --override # Run once you are done building to restore the original linking +brew link qt@5 --overwrite +#In case needed and still qt@5 was not found by cmake you can do: +brew unlink qt@5 && brew link --force qt@5 +# brew link qt --overwrite # Run once you are done building to restore the original linking ``` Add CMake into your env-vars to be detected by cmake diff --git a/cmake/FindZeroMQ.cmake b/cmake/FindZeroMQ.cmake index b4a9da124..f4acf7da5 100644 --- a/cmake/FindZeroMQ.cmake +++ b/cmake/FindZeroMQ.cmake @@ -5,13 +5,9 @@ # ZeroMQ_LIBRARIES - The libraries needed to use ZeroMQ # ZeroMQ_DEFINITIONS - Compiler switches required for using ZeroMQ -find_path ( ZeroMQ_INCLUDE_DIR zmq.h ) -find_library ( ZeroMQ_LIBRARY NAMES zmq ) +find_package(PkgConfig REQUIRED) +pkg_check_modules(ZMQ REQUIRED libzmq) -set ( ZeroMQ_LIBRARIES ${ZeroMQ_LIBRARY} ) -set ( ZeroMQ_INCLUDE_DIRS ${ZeroMQ_INCLUDE_DIR} ) - -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 ) +set(ZeroMQ_FOUND TRUE) +set(ZeroMQ_INCLUDE_DIRS ${ZMQ_INCLUDE_DIRS}) +set(ZeroMQ_LIBRARIES ${ZMQ_LIBRARIES}) diff --git a/plotjuggler_plugins/DataStreamZMQ/CMakeLists.txt b/plotjuggler_plugins/DataStreamZMQ/CMakeLists.txt index d7622ea98..37a48c941 100644 --- a/plotjuggler_plugins/DataStreamZMQ/CMakeLists.txt +++ b/plotjuggler_plugins/DataStreamZMQ/CMakeLists.txt @@ -1,33 +1,54 @@ +# 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") - set(ZeroMQ_LIBS ${ZeroMQ_LIBRARIES}) + + # 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 endif() +# Find ZeroMQ library find_package(ZeroMQ QUIET) +# Check if ZeroMQ was found if(ZeroMQ_FOUND) message(STATUS "[ZeroMQ] found") + # Add QT definitions if needed add_definitions(${QT_DEFINITIONS}) add_definitions(-DQT_PLUGIN) - QT5_WRAP_UI ( UI_SRC datastream_zmq.ui ) + # Wrap the UI file for Qt + QT5_WRAP_UI(UI_SRC datastream_zmq.ui) - add_library(DataStreamZMQ SHARED datastream_zmq.cpp ${UI_SRC} ) + # Add the DataStreamZMQ library + 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) + # 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_link_libraries(DataStreamZMQ ${ZeroMQ_LIBRARIES}) + target_include_directories(DataStreamZMQ PRIVATE ${ZeroMQ_INCLUDE_DIRS}) + target_link_libraries(DataStreamZMQ zmq) # Changed this to just 'zmq' endif() - install(TARGETS DataStreamZMQ DESTINATION ${PJ_PLUGIN_INSTALL_DIRECTORY} ) + # Install the plugin + install(TARGETS DataStreamZMQ DESTINATION ${PJ_PLUGIN_INSTALL_DIRECTORY}) else() - message("[ZeroMQ] not found. Skipping plugin DataStreamZMQ.") + message(STATUS "[ZeroMQ] not found. Skipping plugin DataStreamZMQ.") endif() diff --git a/plotjuggler_plugins/ParserProtobuf/error_collectors.cpp b/plotjuggler_plugins/ParserProtobuf/error_collectors.cpp index 761e0b739..cc253393b 100644 --- a/plotjuggler_plugins/ParserProtobuf/error_collectors.cpp +++ b/plotjuggler_plugins/ParserProtobuf/error_collectors.cpp @@ -23,6 +23,16 @@ void FileErrorCollector::AddWarning(const std::string& filename, int line, int, qDebug() << msg; } +void FileErrorCollector::RecordError(absl::string_view filename, int line, int column, + absl::string_view message) +{ + QString errorMessage = QString("Error in file: %1 at line: %2, column: %3: %4") + .arg(QString::fromStdString(std::string(filename))) + .arg(line) + .arg(column) + .arg(QString::fromStdString(std::string(message))); + _errors << errorMessage; +} void IoErrorCollector::AddError(int line, google::protobuf::io::ColumnNumber, const std::string& message) { diff --git a/plotjuggler_plugins/ParserProtobuf/error_collectors.h b/plotjuggler_plugins/ParserProtobuf/error_collectors.h index f70a881f5..bdd55ab12 100644 --- a/plotjuggler_plugins/ParserProtobuf/error_collectors.h +++ b/plotjuggler_plugins/ParserProtobuf/error_collectors.h @@ -3,17 +3,16 @@ #include #include - #include class IoErrorCollector : public google::protobuf::io::ErrorCollector { public: void AddError(int line, google::protobuf::io::ColumnNumber column, - const std::string& message) override; + const std::string& message); void AddWarning(int line, google::protobuf::io::ColumnNumber column, - const std::string& message) override; + const std::string& message); const QStringList& errors() { @@ -27,19 +26,29 @@ class IoErrorCollector : public google::protobuf::io::ErrorCollector class FileErrorCollector : public google::protobuf::compiler::MultiFileErrorCollector { public: - void AddError(const std::string& filename, int line, int, - const std::string& message) override; + void AddError(const std::string& filename, int line, int column, + const std::string& message); - void AddWarning(const std::string& filename, int line, int, - const std::string& message) override; + void AddWarning(const std::string& filename, int line, int column, + const std::string& message); - const QStringList& errors() + void RecordError(absl::string_view filename, int line, int column, + absl::string_view message) override; + + const QStringList& errors() const { return _errors; } + // Accessor for the collected warnings + const QStringList& warnings() const + { + return _warnings; + } + private: QStringList _errors; + QStringList _warnings; }; #endif // ERROR_COLLECTORS_H