Skip to content

Commit

Permalink
Make WITH_INTERNAL_GRAPHVIZ default (#61)
Browse files Browse the repository at this point in the history
* Make WITH_INTERNAL_GRAPHVIZ default

Also update graphviz which now has PIC enabled

* omit default WITH_INTERNAL_GRAPHVIZ on Github CI

* [win] set flex/bison from graphviz inside CMake

* Unify CI build

* Update CMakeLists.txt

fix the cmake-lint disable for long-lines

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Remove libgtk2.0-dev from build deps

* CI enable --warn-uninitialized -Werror=dev

---------

Co-authored-by: Allen Winter <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 23, 2024
1 parent 426863b commit 6e28780
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 49 deletions.
22 changes: 3 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt update -qq
sudo apt install -y doxygen libgtk2.0-dev
sudo apt install -y doxygen
- name: Install Dependencies on macOS
if: ${{ runner.os == 'macOS' }}
Expand Down Expand Up @@ -81,32 +81,16 @@ jobs:
with:
submodules: recursive

- name: Configure project (Linux/macOS)
if: ${{ runner.os != 'Windows' }}
- name: Configure project
run: >
cmake -S . -B ./build -G Ninja
--warn-uninitialized -Werror=dev
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_OSX_ARCHITECTURES="${{ matrix.config.macos_architectures }}"
-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' }}
-DWITH_INTERNAL_GRAPHVIZ=ON
- name: Configure project (Windows)
if: ${{ runner.os == 'Windows' }}
run: >
cmake -S . -B ./build -G Ninja
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-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' }}
-DWITH_INTERNAL_GRAPHVIZ=ON
-DCMAKE_PREFIX_PATH="${{github.workspace}}/3rdparty/graphviz/windows/dependencies/libraries"
-DCMAKE_PROGRAM_PATH="${{github.workspace}}/3rdparty/graphviz/windows/dependencies/graphviz-build-utilities"
-DBISON_EXECUTABLE="${{github.workspace}}/3rdparty/graphviz/windows/dependencies/graphviz-build-utilities/winflexbison/win_bison.exe"
-DFLEX_EXECUTABLE="${{github.workspace}}/3rdparty/graphviz/windows/dependencies/graphviz-build-utilities/winflexbison/win_flex.exe"
- name: Build Project
run: cmake --build ./build
Expand Down
19 changes: 15 additions & 4 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ if(WITH_INTERNAL_GRAPHVIZ)
#TODO check if there are unneeded features to disable

if(WITH_STATIC_GRAPHVIZ)
set(CMAKE_POSITION_INDEPENDENT_CODE ON
)#TODO remove after https://gitlab.com/graphviz/graphviz/-/merge_requests/3823 is merged
set(BUILD_SHARED_LIBS OFF)
endif()
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/graphviz/CMakeLists.txt")
Expand All @@ -30,17 +28,30 @@ if(WITH_INTERNAL_GRAPHVIZ)
# cmake-lint: disable=C0103
set(with_gvedit
"OFF"
CACHE STRING " GVEdit interactive graph editor" FORCE
CACHE STRING "GVEdit interactive graph editor" FORCE
)
add_subdirectory(graphviz)

# cmake-lint: disable=C0301
if(WIN32)
# On Windows we need some dependencies available for tests
file(GLOB GRAPHVIZ_DEPENDENCIES
${CMAKE_CURRENT_SOURCE_DIR}/graphviz/windows/dependencies/libraries/x64/bin/*
)
file(COPY ${GRAPHVIZ_DEPENDENCIES} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/graphviz/windows/dependencies/libraries)
list(APPEND CMAKE_PROGRAM_PATH
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/graphviz/windows/dependencies/graphviz-build-utilities
)
set(BISON_EXECUTABLE
${CMAKE_CURRENT_SOURCE_DIR}/graphviz/windows/dependencies/graphviz-build-utilities/winflexbison/win_bison.exe
)
set(FLEX_EXECUTABLE
${CMAKE_CURRENT_SOURCE_DIR}/graphviz/windows/dependencies/graphviz-build-utilities/winflexbison/win_flex.exe
)
endif()

add_subdirectory(graphviz)
endfunction()

add_graphviz_subdirectory()
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/graphviz
Submodule graphviz updated from ef3ba9 to 7a7e2d
39 changes: 15 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# -DWITH_INTERNAL_GRAPHVIZ=[true|false]
# Allow to build with an internal Graphviz install.
# In the case where a separate Graphviz installation is not practical or desired.
# Default=true if Graphviz is not located; false otherwise
# Default=true
#
# -WITH_STATIC_GRAPHVIZ=[true|false]
# Allow the internal Graphviz build to be statically.
Expand Down Expand Up @@ -210,42 +210,33 @@ set(INSTALL_TARGETS_DEFAULT_ARGS
"/Applications/Qt${QT_VERSION_MAJOR}"
)

# search for Graphviz
set(GRAPHVIZ_MIN_VERSION "2.30.1")
if(NOT DEFINED WITH_INTERNAL_GRAPHVIZ)
find_package(Graphviz)
endif()
set_package_properties(
Graphviz PROPERTIES
TYPE RECOMMENDED
DESCRIPTION "Graph visualization software"
PURPOSE "Needed for automatic layout of state charts"
URL "https://www.graphviz.org/"
)

if(GRAPHVIZ_FOUND)
set(WITH_INTERNAL_GRAPHVIZ_DEFAULT OFF)
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})
add_feature_info("Internal build of Graphviz" WITH_INTERNAL_GRAPHVIZ "enable with WITH_INTERNAL_GRAPHVIZ=ON")
option(WITH_INTERNAL_GRAPHVIZ "Enable internal build of external project Graphviz" ON)
add_feature_info("Internal build of Graphviz" WITH_INTERNAL_GRAPHVIZ "disable with WITH_INTERNAL_GRAPHVIZ=OFF")

if(WITH_INTERNAL_GRAPHVIZ)
option(WITH_STATIC_GRAPHVIZ "Enable static build of Graphviz when internally building" ON)
add_feature_info(
"Statically build Graphviz for internal builds" WITH_INTERNAL_GRAPHVIZ "disable with WITH_STATIC_GRAPHVIZ=OFF"
)
set(GRAPHVIZ_FOUND ON)

include_directories(${PROJECT_SOURCE_DIR}/src/fwd_headers)
include_directories(${PROJECT_SOURCE_DIR}/3rdparty/graphviz/lib/common)
include_directories(${PROJECT_SOURCE_DIR}/3rdparty/graphviz/lib/gvc)
include_directories(${PROJECT_SOURCE_DIR}/3rdparty/graphviz/lib/pathplan)
include_directories(${PROJECT_SOURCE_DIR}/3rdparty/graphviz/lib/cgraph)
include_directories(${PROJECT_SOURCE_DIR}/3rdparty/graphviz/lib/cdt)
else()
# search for External Graphviz installation, NOT SUPPORTED anymore
set(GRAPHVIZ_MIN_VERSION "2.30.1")
find_package(Graphviz)
set_package_properties(
Graphviz PROPERTIES
TYPE RECOMMENDED
DESCRIPTION "Graph visualization software"
PURPOSE "Needed for automatic layout of state charts"
URL "https://www.graphviz.org/"
)
endif()

add_subdirectory(3rdparty)
Expand Down
1 change: 0 additions & 1 deletion src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ if(GRAPHVIZ_FOUND)
if(WITH_STATIC_GRAPHVIZ)
list(APPEND LIB_SRCS layout/graphvizlayout/graphviz_staticbuild.c)
endif()
add_definitions(${GRAPHVIZ_COMPILE_FLAGS})
endif()

add_library(kdstatemachineeditor_core SHARED ${LIB_SRCS})
Expand Down

0 comments on commit 6e28780

Please sign in to comment.