Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build with external graphviz #72

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
218 changes: 109 additions & 109 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,111 +1,111 @@
{
"version": 3,
"configurePresets": [
{
"name": "base",
"hidden": true,
"generator": "Ninja",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"BUILD_DOCS": "OFF"
}
},
{
"name": "dev-base",
"description": "dev-base",
"hidden": true,
"inherits": "base",
"binaryDir": "${sourceDir}/build-dev",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BUILD_TESTS": "ON"
}
},
{
"name": "dev5-external-graphviz",
"description": "Qt5 dev build with external graphviz",
"inherits": "dev-base",
"binaryDir": "${sourceDir}/build-dev5-external-graphviz",
"cacheVariables": {
"WITH_INTERNAL_GRAPHVIZ": "OFF"
}
},
{
"name": "dev5",
"description": "Qt5 dev build",
"inherits": "dev-base",
"binaryDir": "${sourceDir}/build-dev5",
"cacheVariables": {
"WITH_INTERNAL_GRAPHVIZ": "ON"
}
},
{
"name": "dev6-external-graphviz",
"description": "Qt6 dev build with external graphviz",
"inherits": "dev-base",
"binaryDir": "${sourceDir}/build-dev6-external-graphviz",
"cacheVariables": {
"BUILD_QT6": "ON",
"WITH_INTERNAL_GRAPHVIZ": "OFF"
}
},
{
"name": "dev6",
"description": "Qt6 dev build",
"inherits": "dev-base",
"binaryDir": "${sourceDir}/build-dev6",
"cacheVariables": {
"BUILD_QT6": "ON",
"WITH_INTERNAL_GRAPHVIZ": "ON"
}
},
{
"name": "rel-base",
"description": "rel-base",
"inherits": "base",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_TESTS": "OFF"
}
},
{
"name": "rel5-external-graphviz",
"description": "Qt5 release build with external graphviz",
"inherits": "rel-base",
"binaryDir": "${sourceDir}/build-rel5-external-graphviz",
"cacheVariables": {
"WITH_INTERNAL_GRAPHVIZ": "OFF"
}
},
{
"name": "rel5",
"description": "Qt5 release build",
"inherits": "rel-base",
"binaryDir": "${sourceDir}/build-rel5",
"cacheVariables": {
"WITH_INTERNAL_GRAPHVIZ": "ON"
}
},
{
"name": "rel6-external-graphviz",
"description": "Qt6 release build with external graphviz",
"inherits": "rel-base",
"binaryDir": "${sourceDir}/build-rel6-external-graphviz",
"cacheVariables": {
"BUILD_QT6": "ON",
"WITH_INTERNAL_GRAPHVIZ": "OFF"
}
},
{
"name": "rel6",
"description": "Qt6 release build",
"inherits": "rel-base",
"binaryDir": "${sourceDir}/build-rel6",
"cacheVariables": {
"BUILD_QT6": "ON",
"WITH_INTERNAL_GRAPHVIZ": "ON"
}
}
]
"version": 3,
"configurePresets": [
{
"name": "base",
"hidden": true,
"generator": "Ninja",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"BUILD_DOCS": "OFF"
}
},
{
"name": "dev-base",
"description": "dev-base",
"hidden": true,
"inherits": "base",
"binaryDir": "${sourceDir}/build-dev",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BUILD_TESTS": "ON"
}
},
{
"name": "dev5-external-graphviz",
"description": "Qt5 dev build with external graphviz",
"inherits": "dev-base",
"binaryDir": "${sourceDir}/build-dev5-external-graphviz",
"cacheVariables": {
"WITH_INTERNAL_GRAPHVIZ": "OFF"
}
},
{
"name": "dev5",
"description": "Qt5 dev build",
"inherits": "dev-base",
"binaryDir": "${sourceDir}/build-dev5",
"cacheVariables": {
"WITH_INTERNAL_GRAPHVIZ": "ON"
}
},
{
"name": "dev6-external-graphviz",
"description": "Qt6 dev build with external graphviz",
"inherits": "dev-base",
"binaryDir": "${sourceDir}/build-dev6-external-graphviz",
"cacheVariables": {
"BUILD_QT6": "ON",
"WITH_INTERNAL_GRAPHVIZ": "OFF"
}
},
{
"name": "dev6",
"description": "Qt6 dev build",
"inherits": "dev-base",
"binaryDir": "${sourceDir}/build-dev6",
"cacheVariables": {
"BUILD_QT6": "ON",
"WITH_INTERNAL_GRAPHVIZ": "ON"
}
},
{
"name": "rel-base",
"description": "rel-base",
"inherits": "base",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_TESTS": "OFF"
}
},
{
"name": "rel5-external-graphviz",
"description": "Qt5 release build with external graphviz",
"inherits": "rel-base",
"binaryDir": "${sourceDir}/build-rel5-external-graphviz",
"cacheVariables": {
"WITH_INTERNAL_GRAPHVIZ": "OFF"
}
},
{
"name": "rel5",
"description": "Qt5 release build",
"inherits": "rel-base",
"binaryDir": "${sourceDir}/build-rel5",
"cacheVariables": {
"WITH_INTERNAL_GRAPHVIZ": "ON"
}
},
{
"name": "rel6-external-graphviz",
"description": "Qt6 release build with external graphviz",
"inherits": "rel-base",
"binaryDir": "${sourceDir}/build-rel6-external-graphviz",
"cacheVariables": {
"BUILD_QT6": "ON",
"WITH_INTERNAL_GRAPHVIZ": "OFF"
}
},
{
"name": "rel6",
"description": "Qt6 release build",
"inherits": "rel-base",
"binaryDir": "${sourceDir}/build-rel6",
"cacheVariables": {
"BUILD_QT6": "ON",
"WITH_INTERNAL_GRAPHVIZ": "ON"
}
}
]
}
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
Loading