Skip to content

Commit 650665b

Browse files
drdanziamsergio
authored andcommitted
Fix build with external graphviz
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'
1 parent 38f71bb commit 650665b

File tree

2 files changed

+104
-3
lines changed

2 files changed

+104
-3
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
2+
#
3+
# SPDX-License-Identifier: LGPL-2.1-only OR LicenseRef-KDAB-KDStateMachineEditor
4+
5+
name: CI with external graphviz
6+
7+
on:
8+
push:
9+
branches:
10+
- master
11+
pull_request:
12+
branches:
13+
- master
14+
15+
jobs:
16+
build:
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
os:
22+
- ubuntu-latest
23+
- macos-latest
24+
build_type:
25+
- Debug
26+
config:
27+
- qt_version: 6.6.2
28+
qt_modules: qtscxml
29+
30+
steps:
31+
- name: Install Dependencies on Linux
32+
if: ${{ runner.os == 'Linux' }}
33+
run: |
34+
sudo apt update -qq
35+
sudo apt install -y doxygen libgraphviz-dev
36+
37+
- name: Install Dependencies on macOS
38+
if: ${{ runner.os == 'macOS' }}
39+
run: brew install bison graphviz
40+
41+
- name: Install Qt ${{ matrix.config.qt_version }} with options and default aqtversion
42+
uses: jurplel/install-qt-action@v3
43+
with:
44+
aqtversion: null # use whatever the default is
45+
modules: ${{ matrix.config.qt_modules }}
46+
version: ${{ matrix.config.qt_version }}
47+
cache: true
48+
49+
- name: Install ninja-build tool (must be after Qt due PATH changes)
50+
uses: turtlesec-no/get-ninja@main
51+
52+
- name: Add Bison to PATH (must be after Qt due PATH changes)
53+
if: ${{ runner.os == 'macOS' }}
54+
run: echo "/opt/homebrew/opt/bison/bin" >> $GITHUB_PATH
55+
56+
- name: Checkout sources
57+
uses: actions/checkout@v4
58+
with:
59+
submodules: recursive
60+
61+
- name: Configure project
62+
run: >
63+
cmake -S . -B ./build -G Ninja
64+
--warn-uninitialized -Werror=dev
65+
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
66+
-DCMAKE_OSX_ARCHITECTURES="arm64"
67+
-DBUILD_QT6=ON
68+
-DBUILD_TESTS=${{ matrix.build_type == 'Debug' }}
69+
-DBUILD_EXAMPLES=ON
70+
-DBUILD_DOCS=${{ matrix.build_type == 'Debug' && runner.os == 'Linux' }}
71+
-DWITH_INTERNAL_GRAPHVIZ=OFF
72+
73+
- name: Build Project
74+
run: cmake --build ./build
75+
76+
- name: Run tests on Linux (offscreen)
77+
if: ${{ matrix.build_type == 'Debug' && runner.os == 'Linux' }}
78+
run: ctest --test-dir ./build -C ${{ matrix.build_type }} --output-on-failure
79+
env:
80+
QT_QPA_PLATFORM: offscreen
81+
82+
- name: Run tests on macOS
83+
if: ${{ matrix.build_type == 'Debug' && runner.os != 'Linux' }}
84+
run: ctest --test-dir ./build -C ${{ matrix.build_type }} --output-on-failure
85+
86+
- name: Read tests log when it fails
87+
uses: andstor/file-reader-action@v1
88+
if: ${{ failure() && matrix.build_type == 'Debug' }}
89+
with:
90+
path: "./build/Testing/Temporary/LastTest.log"

src/core/CMakeLists.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ if(BUILD_QT6)
8989
target_link_libraries(kdstatemachineeditor_core PRIVATE Qt6::StateMachine)
9090
endif()
9191

92+
if(NOT WITH_INTERNAL_GRAPHVIZ)
93+
target_include_directories(kdstatemachineeditor_core PRIVATE ${GRAPHVIZ_INCLUDE_DIR})
94+
endif()
95+
9296
set_target_properties(
9397
kdstatemachineeditor_core
9498
PROPERTIES SOVERSION ${KDSME_SOVERSION}
@@ -110,12 +114,19 @@ endif()
110114

111115
generate_export_header(kdstatemachineeditor_core EXPORT_FILE_NAME kdsme_core_export.h BASE_NAME KDSME_CORE)
112116

113-
if(NOT GRAPHVIZ_PLUGIN_DOT_LAYOUT_LIBRARY)
114-
set(GRAPHVIZ_PLUGIN_DOT_LAYOUT_LIBRARY gvplugin_dot_layout)
117+
if(WITH_INTERNAL_GRAPHVIZ)
118+
set(GRAPHVIZ_GVC_LIBRARY gvc)
119+
set(GRAPHVIZ_CGRAPH_LIBRARY cgraph)
120+
if(NOT GRAPHVIZ_PLUGIN_DOT_LAYOUT_LIBRARY)
121+
set(GRAPHVIZ_PLUGIN_DOT_LAYOUT_LIBRARY gvplugin_dot_layout)
122+
endif()
115123
endif()
116124

117125
if(GRAPHVIZ_FOUND)
118-
target_link_libraries(kdstatemachineeditor_core PRIVATE cgraph gvc ${GRAPHVIZ_PLUGIN_DOT_LAYOUT_LIBRARY})
126+
target_link_libraries(
127+
kdstatemachineeditor_core PRIVATE ${GRAPHVIZ_CGRAPH_LIBRARY} ${GRAPHVIZ_GVC_LIBRARY}
128+
${GRAPHVIZ_PLUGIN_DOT_LAYOUT_LIBRARY}
129+
)
119130
endif()
120131

121132
set(build_iface_dirs

0 commit comments

Comments
 (0)