diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 76b2cf35..cbb46429 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,21 +16,29 @@ jobs: build: runs-on: ${{ matrix.os }} strategy: - fail-fast: true + fail-fast: false matrix: os: - ubuntu-latest - - windows-latest - - macos-latest + #- windows-latest + #- macos-latest build_type: - Debug - - Release + #- Release config: - qt_version: "5.15" qt_arch: win64_mingw81 - - qt_version: "6.4.*" - qt_modules: qtscxml - qt_arch: win64_mingw + #- qt_version: "6.4.*" + #qt_modules: qtscxml + #qt_arch: win64_mingw + include: + - os: ubuntu-latest + build_type: + Debug + config: + qt_version: "6.6.*" + qt_modules: qtscxml + cmake_arg: "-DWITH_INTERNAL_GRAPHVIZ=ON" steps: - name: Install Dependencies on Linux @@ -47,7 +55,7 @@ jobs: if: ${{ runner.os == 'macOS' }} run: brew install graphviz - - name: Install Qt with options and default aqtversion (Linux/macOS) + - name: Install Qt ${{ matrix.config.qt_version }} with options and default aqtversion (Linux/macOS) if: ${{ runner.os != 'Windows' }} uses: jurplel/install-qt-action@v3 with: @@ -76,6 +84,8 @@ jobs: - name: Checkout sources uses: actions/checkout@v4 + with: + submodules: recursive - name: Fetch Git submodule run: git submodule update --init --recursive @@ -83,13 +93,13 @@ jobs: - name: Configure project run: > cmake -S . -B ./build -G Ninja - --warn-uninitialized -Werror=dev -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_PREFIX_PATH='C:\Program Files\Graphviz' -DBUILD_QT6=${{ startsWith(matrix.config.qt_version, '6.') }} -DBUILD_TESTS=${{ matrix.build_type == 'Debug' }} -DBUILD_EXAMPLES=ON -DBUILD_DOCS=${{ matrix.build_type == 'Debug' && runner.os == 'Linux' }} + ${{ matrix.config.cmake_arg }} - name: Build Project run: cmake --build ./build diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..1c89b3b4 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "3rdparty/graphviz"] + path = 3rdparty/graphviz + url = https://gitlab.com/graphviz/graphviz.git diff --git a/.reuse/dep5 b/.reuse/dep5 index 0b893d39..151699ca 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -14,7 +14,7 @@ Copyright: Klarälvdalens Datakonsult AB, a KDAB Group company License: LGPL-2.1-only OR LicenseRef-KDAB-KDStateMachineEditor #misc config files -Files: .pre-commit-config.yaml .codespellrc .krazy .clang-tidy .gitignore appveyor.yml distro/* .clang-format .cmake-format.py .mdlrc .mdlrc.rb +Files: .pre-commit-config.yaml .codespellrc .krazy .clang-tidy .gitignore .gitmodules appveyor.yml distro/* .clang-format .cmake-format.py .mdlrc .mdlrc.rb Copyright: Klarälvdalens Datakonsult AB, a KDAB Group company License: BSD-3-Clause diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt new file mode 100644 index 00000000..4eea2fca --- /dev/null +++ b/3rdparty/CMakeLists.txt @@ -0,0 +1,32 @@ +# +# This file is part of the KDAB State Machine Editor Library. +# +# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company +# Author: Daniel Nicoletti +# +# SPDX-License-Identifier: LGPL-2.1-only OR LicenseRef-KDAB-KDStateMachineEditor +# +# Licensees holding valid commercial KDAB State Machine Editor Library +# licenses may use this file in accordance with the KDAB State Machine Editor +# Library License Agreement provided with the Software. +# +# Contact info@kdab.com if any conditions of this licensing are not clear to you. +# + +if(WITH_INTERNAL_GRAPHVIZ) + # Function creates extra scope to keep these variables local + function(add_graphviz_subdirectory) + #TODO check if there are unneeded features to disable + + if(WITH_STATIC_GRAPHVIZ) + set(BUILD_SHARED_LIBS OFF) + endif() + if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/graphviz/CMakeLists.txt") + message(FATAL_ERROR "Please do git submodule update --init --recursive") + endif() + + add_subdirectory(graphviz) + endfunction() + + add_graphviz_subdirectory() +endif() diff --git a/3rdparty/graphviz b/3rdparty/graphviz new file mode 160000 index 00000000..6e66f982 --- /dev/null +++ b/3rdparty/graphviz @@ -0,0 +1 @@ +Subproject commit 6e66f982e5113296692b300b9a0821b515e56ca6 diff --git a/CMakeLists.txt b/CMakeLists.txt index cba8abc2..4d506e13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,16 +50,6 @@ project( VERSION 1.99.50 ) -add_definitions( - -DQT_NO_CAST_TO_ASCII - -DQT_NO_CAST_FROM_ASCII - -DQT_STRICT_ITERATORS - -DQT_NO_URL_CAST_FROM_STRING - -DQT_NO_CAST_FROM_BYTEARRAY - -DQT_USE_QSTRINGBUILDER - -DQT_USE_FAST_OPERATOR_PLUS -) - set(KDSME_SOVERSION "2") #means the 2.x ABI is frozen. ABI changes will must go to version 3 include(FeatureSummary) @@ -217,7 +207,9 @@ set(INSTALL_TARGETS_DEFAULT_ARGS # search for Graphviz set(GRAPHVIZ_MIN_VERSION "2.30.1") -find_package(Graphviz) +if(NOT DEFINED WITH_INTERNAL_GRAPHVIZ) + find_package(Graphviz) +endif() set_package_properties( Graphviz PROPERTIES TYPE RECOMMENDED @@ -231,6 +223,7 @@ if(GRAPHVIZ_FOUND) elseif(NOT CMAKE_SYSTEM_NAME STREQUAL QNX) message(STATUS "Auto-enabling internal Graphviz build, since no installed version is available") set(WITH_INTERNAL_GRAPHVIZ_DEFAULT ON) + set(GRAPHVIZ_FOUND ON) endif() option(WITH_INTERNAL_GRAPHVIZ "Enable build of external project Graphviz" ${WITH_INTERNAL_GRAPHVIZ_DEFAULT}) @@ -238,94 +231,7 @@ add_feature_info("Internal build of Graphviz" WITH_INTERNAL_GRAPHVIZ "enable wit set(WITH_STATIC_GRAPHVIZ OFF) # Whether the Graphviz build we're using is static or not -- WIP -if(WITH_INTERNAL_GRAPHVIZ) - # CMake is really awful here... - set(source_dir ${CMAKE_CURRENT_BINARY_DIR}/graphviz-src) - set(install_dir ${CMAKE_CURRENT_BINARY_DIR}/graphviz-install) - - # work-around: https://cmake.org/Bug/view.php?id=15052 - set(include_dir "${install_dir}/include") - file(MAKE_DIRECTORY ${include_dir}) - set(GRAPHVIZ_INCLUDE_DIR ${include_dir}) - - if(UNIX OR WITH_STATIC_GRAPHVIZ) - set(libfolder "lib") - else() - set(libfolder "bin") - endif() - - if(WITH_STATIC_GRAPHVIZ) - set(staticdotlayoutplugin_library - "${install_dir}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gvplugin_dot_layout${CMAKE_STATIC_LIBRARY_SUFFIX}" - ) - set(link_libraries_absolute) - foreach(link_library "xdot;gvc;cgraph;pathplan") - list(APPEND link_libraries_absolute - ${install_dir}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${link_library}${CMAKE_STATIC_LIBRARY_SUFFIX} - ) - endforeach() - else() - set(GRAPHVIZ_CGRAPH_LIBRARY - "${install_dir}/${libfolder}/${CMAKE_SHARED_LIBRARY_PREFIX}cgraph${CMAKE_SHARED_LIBRARY_SUFFIX}" - ) - set(GRAPHVIZ_GVC_LIBRARY - "${install_dir}/${libfolder}/${CMAKE_SHARED_LIBRARY_PREFIX}gvc${CMAKE_SHARED_LIBRARY_SUFFIX}" - ) - set(link_libraries_absolute "${GRAPHVIZ_CGRAPH_LIBRARY};${GRAPHVIZ_GVC_LIBRARY}") - endif() - - set(win_build_utilities ${source_dir}/windows/dependencies/graphviz-build-utilities) - string(TIMESTAMP graphvizDate) - set(GRAPHVIZ_MAJOR_VERSION 2) - set(GRAPHVIZ_MINOR_VERSION 48) - set(GRAPHVIZ_PATCH_VERSION 0) - set(graphvizVersion "${GRAPHVIZ_MAJOR_VERSION}.${GRAPHVIZ_MINOR_VERSION}.${GRAPHVIZ_PATCH_VERSION}") - # cmake-lint: disable=C0301 - externalproject_add( - GraphvizExternalProject - GIT_REPOSITORY "https://gitlab.com/graphviz/graphviz.git" - GIT_TAG ${graphvizVersion} - GIT_PROGRESS 1 - USES_TERMINAL_DOWNLOAD - TRUE # needed for Ninja so we can see the Git progress (cf. https://gitlab.kitware.com/cmake/cmake/-/issues/18238) - CMAKE_ARGS - -DVERSION=${graphvizVersion} - -DDATE=${graphvizDate} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} - -DCMAKE_C_COMPILER_AR=${CMAKE_C_COMPILER_AR} - -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} - -DCMAKE_CXX_COMPILER_AR=${CMAKE_CXX_COMPILER_AR} - -DCMAKE_INSTALL_PREFIX=${install_dir} - $<$:-DCMAKE_IGNORE_PATH="C:/Strawberry/c/bin"> - $<$:-DCMAKE_SYSTEM_PREFIX_PATH=${win_build_utilities}$${win_build_utilities}/winflexbison$${win_build_utilities}/Perl64$${win_build_utilities}/GnuWin/bin> - BUILD_COMMAND "" # skip, make install is enough - SOURCE_DIR ${source_dir} - INSTALL_DIR ${install_dir} - INSTALL_COMMAND ${CMAKE_COMMAND} --build . --target install - # Note: BUILD_BYPRODUCTS only available since CMake 3.2 - # Needed to make ExternalProject_Add in combination with the Ninja generator work - # Also see: https://cmake.org/pipermail/cmake/2015-April/060234.html - BUILD_BYPRODUCTS ${staticdotlayoutplugin_library} ${link_libraries_absolute} - ) - - if(WITH_STATIC_GRAPHVIZ) - add_library(GraphvizStaticDotLayoutPlugin IMPORTED STATIC) - set_target_properties( - GraphvizStaticDotLayoutPlugin - PROPERTIES IMPORTED_LOCATION "${staticdotlayoutplugin_library}" - INTERFACE_COMPILE_DEFINITIONS - "CGRAPH_EXPORTS;GVC_EXPORTS;WITH_CGRAPH" # Fix export macro madness in Graphviz - INTERFACE_INCLUDE_DIRECTORIES ${include_dir} - INTERFACE_LINK_LIBRARIES "${link_libraries_absolute}" - ) - else() - # in case of a Graphviz dynamic library build, we need to install - install(DIRECTORY ${install_dir}/ DESTINATION ".") - endif() - - set(GRAPHVIZ_FOUND TRUE) -endif() +add_subdirectory(3rdparty) # # Compiler & linker settings diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 0e6a3d12..e02031fc 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -12,6 +12,16 @@ # Contact info@kdab.com if any conditions of this licensing are not clear to you. # +add_definitions( + -DQT_NO_CAST_TO_ASCII + -DQT_NO_CAST_FROM_ASCII + -DQT_STRICT_ITERATORS + -DQT_NO_URL_CAST_FROM_STRING + -DQT_NO_CAST_FROM_BYTEARRAY + -DQT_USE_QSTRINGBUILDER + -DQT_USE_FAST_OPERATOR_PLUS +) + include_directories(${CMAKE_CURRENT_BINARY_DIR}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-examples.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-examples.h) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4a0c6160..1edd8959 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,6 +12,16 @@ # Contact info@kdab.com if any conditions of this licensing are not clear to you. # +add_definitions( + -DQT_NO_CAST_TO_ASCII + -DQT_NO_CAST_FROM_ASCII + -DQT_STRICT_ITERATORS + -DQT_NO_URL_CAST_FROM_STRING + -DQT_NO_CAST_FROM_BYTEARRAY + -DQT_USE_QSTRINGBUILDER + -DQT_USE_FAST_OPERATOR_PLUS +) + set(HAVE_GRAPHVIZ ${GRAPHVIZ_FOUND}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config-kdsme.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kdsme.h) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 7a535edd..e6c83921 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -116,9 +116,6 @@ if(GRAPHVIZ_FOUND) target_link_libraries(kdstatemachineeditor_core PRIVATE GraphvizStaticDotLayoutPlugin) endif() target_link_libraries(kdstatemachineeditor_core PRIVATE ${GRAPHVIZ_GVC_LIBRARY} ${GRAPHVIZ_CGRAPH_LIBRARY}) - if(WITH_INTERNAL_GRAPHVIZ) - add_dependencies(kdstatemachineeditor_core GraphvizExternalProject) - endif() target_include_directories(kdstatemachineeditor_core PRIVATE ${GRAPHVIZ_INCLUDE_DIR}) endif()