Skip to content

Commit

Permalink
Fix build with external graphviz
Browse files Browse the repository at this point in the history
Added a minimal workflow to test against external graphviz. Workflow
is separate, the main one was getting too convoluted, as macOS doesn't
have graphviz for x86_64. Rather have a few lines of copy-paste over
a big workflow full of 'ifs'
  • Loading branch information
drdanz authored and iamsergio committed Dec 10, 2024
1 parent 38f71bb commit 650665b
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 3 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/build-external-graphviz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
#
# SPDX-License-Identifier: LGPL-2.1-only OR LicenseRef-KDAB-KDStateMachineEditor

name: CI with external graphviz

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
build_type:
- Debug
config:
- qt_version: 6.6.2
qt_modules: qtscxml

steps:
- name: Install Dependencies on Linux
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt update -qq
sudo apt install -y doxygen libgraphviz-dev
- name: Install Dependencies on macOS
if: ${{ runner.os == 'macOS' }}
run: brew install bison graphviz

- name: Install Qt ${{ matrix.config.qt_version }} with options and default aqtversion
uses: jurplel/install-qt-action@v3
with:
aqtversion: null # use whatever the default is
modules: ${{ matrix.config.qt_modules }}
version: ${{ matrix.config.qt_version }}
cache: true

- name: Install ninja-build tool (must be after Qt due PATH changes)
uses: turtlesec-no/get-ninja@main

- name: Add Bison to PATH (must be after Qt due PATH changes)
if: ${{ runner.os == 'macOS' }}
run: echo "/opt/homebrew/opt/bison/bin" >> $GITHUB_PATH

- name: Checkout sources
uses: actions/checkout@v4
with:
submodules: recursive

- name: Configure project
run: >
cmake -S . -B ./build -G Ninja
--warn-uninitialized -Werror=dev
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_OSX_ARCHITECTURES="arm64"
-DBUILD_QT6=ON
-DBUILD_TESTS=${{ matrix.build_type == 'Debug' }}
-DBUILD_EXAMPLES=ON
-DBUILD_DOCS=${{ matrix.build_type == 'Debug' && runner.os == 'Linux' }}
-DWITH_INTERNAL_GRAPHVIZ=OFF
- name: Build Project
run: cmake --build ./build

- name: Run tests on Linux (offscreen)
if: ${{ matrix.build_type == 'Debug' && runner.os == 'Linux' }}
run: ctest --test-dir ./build -C ${{ matrix.build_type }} --output-on-failure
env:
QT_QPA_PLATFORM: offscreen

- name: Run tests on macOS
if: ${{ matrix.build_type == 'Debug' && runner.os != 'Linux' }}
run: ctest --test-dir ./build -C ${{ matrix.build_type }} --output-on-failure

- name: Read tests log when it fails
uses: andstor/file-reader-action@v1
if: ${{ failure() && matrix.build_type == 'Debug' }}
with:
path: "./build/Testing/Temporary/LastTest.log"
17 changes: 14 additions & 3 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ if(BUILD_QT6)
target_link_libraries(kdstatemachineeditor_core PRIVATE Qt6::StateMachine)
endif()

if(NOT WITH_INTERNAL_GRAPHVIZ)
target_include_directories(kdstatemachineeditor_core PRIVATE ${GRAPHVIZ_INCLUDE_DIR})
endif()

set_target_properties(
kdstatemachineeditor_core
PROPERTIES SOVERSION ${KDSME_SOVERSION}
Expand All @@ -110,12 +114,19 @@ endif()

generate_export_header(kdstatemachineeditor_core EXPORT_FILE_NAME kdsme_core_export.h BASE_NAME KDSME_CORE)

if(NOT GRAPHVIZ_PLUGIN_DOT_LAYOUT_LIBRARY)
set(GRAPHVIZ_PLUGIN_DOT_LAYOUT_LIBRARY gvplugin_dot_layout)
if(WITH_INTERNAL_GRAPHVIZ)
set(GRAPHVIZ_GVC_LIBRARY gvc)
set(GRAPHVIZ_CGRAPH_LIBRARY cgraph)
if(NOT GRAPHVIZ_PLUGIN_DOT_LAYOUT_LIBRARY)
set(GRAPHVIZ_PLUGIN_DOT_LAYOUT_LIBRARY gvplugin_dot_layout)
endif()
endif()

if(GRAPHVIZ_FOUND)
target_link_libraries(kdstatemachineeditor_core PRIVATE cgraph gvc ${GRAPHVIZ_PLUGIN_DOT_LAYOUT_LIBRARY})
target_link_libraries(
kdstatemachineeditor_core PRIVATE ${GRAPHVIZ_CGRAPH_LIBRARY} ${GRAPHVIZ_GVC_LIBRARY}
${GRAPHVIZ_PLUGIN_DOT_LAYOUT_LIBRARY}
)
endif()

set(build_iface_dirs
Expand Down

0 comments on commit 650665b

Please sign in to comment.