Skip to content

Commit

Permalink
Add graphviz as submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
dantti committed Jan 14, 2024
1 parent 1c9dbc0 commit 9af16d1
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 104 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,29 @@ jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false
matrix:
os:
- ubuntu-latest
# - ubuntu-latest
- windows-latest
- macos-latest
build_type:
- Debug
- Release
config:
- qt_version: "5.15"
qt_arch: win64_mingw81
# - qt_version: "5.15"
# qt_arch: win64_mingw81
- 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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -90,6 +100,7 @@ jobs:
-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
Expand Down
18 changes: 18 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# This file is part of the KDAB State Machine Editor Library.
#
# SPDX-FileCopyrightText: 2015-2023 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
# Author: Kevin Funk <[email protected]>
#
# 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 [email protected] if any conditions of this licensing are not clear to you.
#

[submodule "3rdparty/graphviz"]
path = 3rdparty/graphviz
url = https://gitlab.com/graphviz/graphviz.git
27 changes: 27 additions & 0 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# This file is part of the KDAB State Machine Editor Library.
#
# SPDX-FileCopyrightText: 2015-2023 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
# Author: Kevin Funk <[email protected]>
#
# 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 [email protected] 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_sonnet_subdirectory)
#TODO check if there are unneeded features to disable

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()
endif()
1 change: 1 addition & 0 deletions 3rdparty/graphviz
Submodule graphviz added at 7c8fe9
99 changes: 1 addition & 98 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,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)
Expand Down Expand Up @@ -239,94 +229,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}
$<$<BOOL:${WIN32}>:-DCMAKE_IGNORE_PATH="C:/Strawberry/c/bin">
$<$<BOOL:${WIN32}>:-DCMAKE_SYSTEM_PREFIX_PATH=${win_build_utilities}$<SEMICOLON>${win_build_utilities}/winflexbison$<SEMICOLON>${win_build_utilities}/Perl64$<SEMICOLON>${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
Expand Down
10 changes: 10 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
# Contact [email protected] 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)
Expand Down
10 changes: 10 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
# Contact [email protected] 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)

Expand Down
2 changes: 1 addition & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ if(GRAPHVIZ_FOUND)
endif()
target_link_libraries(kdstatemachineeditor_core LINK_PRIVATE ${GRAPHVIZ_GVC_LIBRARY} ${GRAPHVIZ_CGRAPH_LIBRARY})
if(WITH_INTERNAL_GRAPHVIZ)
add_dependencies(kdstatemachineeditor_core GraphvizExternalProject)
# add_dependencies(kdstatemachineeditor_core GraphvizExternalProject)
endif()
target_include_directories(kdstatemachineeditor_core PRIVATE ${GRAPHVIZ_INCLUDE_DIR})
endif()
Expand Down

0 comments on commit 9af16d1

Please sign in to comment.