diff --git a/.github/workflows/build-external-graphviz.yml b/.github/workflows/build-external-graphviz.yml new file mode 100644 index 00000000..ff104300 --- /dev/null +++ b/.github/workflows/build-external-graphviz.yml @@ -0,0 +1,90 @@ +# SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +# +# 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" diff --git a/CMakePresets.json b/CMakePresets.json index 753cc1ac..6c0cbdcb 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -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" + } + } + ] } diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index cfd65ab5..6cfee031 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -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} @@ -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