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

Rename cmake options #77

Merged
merged 1 commit into from
Dec 11, 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
12 changes: 6 additions & 6 deletions .github/workflows/build-external-graphviz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ jobs:
--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' }}
-DBUILD_STATIC=${{ matrix.lib_type == 'Static' }}
-DWITH_INTERNAL_GRAPHVIZ=OFF
-DKDSME_QT6=ON
-DBUILD_TESTING=${{ matrix.build_type == 'Debug' }}
-DKDSME_EXAMPLES=ON
-DKDSME_DOCS=${{ matrix.build_type == 'Debug' && runner.os == 'Linux' }}
-DBUILD_SHARED_LIBS=${{ matrix.lib_type == 'Shared' }}
-DKDSME_INTERNAL_GRAPHVIZ=OFF

- name: Build Project
run: cmake --build ./build
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ jobs:
--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' }}
-DBUILD_STATIC=${{ matrix.lib_type == 'Static' }}
-DKDSME_QT6=${{ startsWith(matrix.config.qt_version, '6.') }}
-DBUILD_TESTING=${{ matrix.build_type == 'Debug' }}
-DKDSME_EXAMPLES=ON
-DKDSME_DOCS=${{ matrix.build_type == 'Debug' && runner.os == 'Linux' }}
-DBUILD_SHARED_LIBS=${{ matrix.lib_type == 'Shared' }}

- name: Build Project
run: cmake --build ./build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:

- name: Configure project
run: >
cmake -S . -B ./build -DBUILD_DOCS=ON
cmake -S . -B ./build -DKDSME_DOCS=ON

- name: Create docs
run: cmake --build ./build --target docs
Expand Down
4 changes: 2 additions & 2 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
# Contact [email protected] if any conditions of this licensing are not clear to you.
#

if(WITH_INTERNAL_GRAPHVIZ)
if(KDSME_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)
if(KDSME_STATIC_GRAPHVIZ)
set(BUILD_SHARED_LIBS OFF)
endif()
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/graphviz/CMakeLists.txt")
Expand Down
10 changes: 9 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ Version 2.0.0:
* Use official Graphviz from upstream with -DWITH_INTERNAL_GRAPHVIZ=True
(Bad side-effect: allows dynamic builds only, but external graphviz still supported)
* Fixed build with more recent graphviz versions
* Buildsystem: new Option BUILD_STATIC to create static libraries
* Buildsystem: new Option BUILD_SHARED_LIBS to select between shared or static libraries
* Renamed the following CMake options
* BUILD_DOCS -> KDSME_DOCS
* BUILD_EXAMPLES -> KDSME_EXAMPLES
* BUILD_QT6 -> KDSME_QT6
* WITH_INTERNAL_GRAPHVIZ -> KDSME_INTERNAL_GRAPHVIZ
* WITH_STATIC_GRAPHVIZ -> KDSME_STATIC_GRAPHVIZ
* Use standard cmake options instead of custom ones:
* BUILD_TESTS -> BUILD_TESTING

Version 1.2.8:
--------------
Expand Down
92 changes: 55 additions & 37 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,37 @@
# Pass the following variables to cmake to control the build:
# (See INSTALL.txt for more information)
#
# -DWITH_INTERNAL_GRAPHVIZ=[true|false]
# -DKDSME_INTERNAL_GRAPHVIZ=[true|false]
# Allow to build with an external Graphviz install.
# We build with our internal graphviz sub-module but someone might want to
# build against distro package, which is not recommended and probably broken.
# Default=true
#
# -WITH_STATIC_GRAPHVIZ=[true|false]
# -KDSME_STATIC_GRAPHVIZ=[true|false]
# Allow the internal Graphviz build to be statically.
# Currently shared graphviz builds on Windows have link issues.
# Default=true
#
# -DBUILD_QT6=[true|false]
# -DKDSME_QT6=[true|false]
# Build against Qt6 rather than Qt5
# Default=false (Qt5 will be used even if Qt6 is available)
#
# -DBUILD_DOCS=[true|false]
# -DKDSME_DOCS=[true|false]
# Build the documentation. Documentation is never built when cross-compiling.
# Default=true
#
# -DBUILD_EXAMPLES=[true|false]
# -DKDSME_EXAMPLES=[true|false]
# Build the examples. Examples are never built when cross-compiling.
# Default=true
#
# -DBUILD_TESTS=[true|false]
# -DBUILD_TESTING=[true|false]
# Build the test harness. Tests are never built when cross-compiling.
# Note: disabling tests also disables building the kdstatemachineeditor test application.
# Default=True
#
# -DBUILD_STATIC=[true|false]
# Build static libraries
# Default=false
# -DBUILD_SHARED_LIBS=[true|false]
# Build shared libraries
# Default=true

cmake_minimum_required(VERSION 3.16)

Expand All @@ -69,23 +69,38 @@ endif()

include(FeatureSummary)

# Declare an option as renamed, and eventually update the old cache entry
function(renamed_option _old _new)
get_property(
_old_set
CACHE ${_old}
PROPERTY VALUE
SET
)
if(_old_set)
message(DEPRECATION "\"${_old}\" was renamed \"${_new}\". Cache entry will be updated.")
set_property(CACHE ${_new} PROPERTY VALUE ${${_old}})
unset(${_old} CACHE)
endif()
endfunction()

if(CMAKE_CROSSCOMPILING)
set(BUILD_DOCS OFF)
set(BUILD_EXAMPLES OFF)
set(BUILD_TESTS OFF)
set(KDSME_DOCS OFF)
set(KDSME_EXAMPLES OFF)
set(BUILD_TESTING OFF)
else()
option(BUILD_DOCS "Build KDStateMachineEditor documentation" ON)
option(BUILD_EXAMPLES "Build examples directory" ON)
option(BUILD_TESTS "Build the test harness" ON)
option(KDSME_DOCS "Build KDStateMachineEditor documentation" ON)
option(KDSME_EXAMPLES "Build examples directory" ON)
option(BUILD_TESTING "Build the test harness" ON)
endif()
option(BUILD_QT6 "Build against Qt 6" OFF)
option(BUILD_STATIC "Build statically" OFF)
renamed_option(BUILD_DOCS KDSME_DOCS)
renamed_option(BUILD_EXAMPLES KDSME_EXAMPLES)
renamed_option(BUILD_TESTS BUILD_TESTING)

if(BUILD_STATIC)
set(BUILD_LIBRARY_MODE "STATIC")
else()
set(BUILD_LIBRARY_MODE "SHARED")
endif()
option(KDSME_QT6 "Build against Qt 6" OFF)
renamed_option(BUILD_QT6 KDSME_QT6)

option(BUILD_SHARED_LIBS "Build shared libraries" ON)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/ECM/modules")
Expand All @@ -106,7 +121,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

if(BUILD_QT6)
if(KDSME_QT6)
set(QT_VERSION_MAJOR 6)
set(QT_MIN_VERSION "6.1.0")
find_package(
Expand Down Expand Up @@ -146,7 +161,7 @@ set_package_properties(
)

# QtXmlPatterns is removed since Qt6
if(NOT BUILD_QT6)
if(NOT KDSME_QT6)
find_package(Qt5XmlPatterns ${QT_MIN_VERSION} CONFIG QUIET)
set_package_properties(
Qt5XmlPatterns PROPERTIES
Expand Down Expand Up @@ -199,7 +214,7 @@ set(LIB_INSTALL_DIR
${CMAKE_INSTALL_LIBDIR}
CACHE STRING "Library install destination."
)
if(BUILD_QT6)
if(KDSME_QT6)
set(INCLUDE_INSTALL_ROOT ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}${KDSME_LIBRARY_QTID})
else()
set(INCLUDE_INSTALL_ROOT ${CMAKE_INSTALL_INCLUDEDIR}/)
Expand Down Expand Up @@ -227,13 +242,16 @@ set(INSTALL_TARGETS_DEFAULT_ARGS
"/Applications/Qt${QT_VERSION_MAJOR}"
)

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")
option(KDSME_INTERNAL_GRAPHVIZ "Enable internal build of external project Graphviz" ON)
renamed_option(WITH_INTERNAL_GRAPHVIZ KDSME_INTERNAL_GRAPHVIZ)
add_feature_info("Internal build of Graphviz" KDSME_INTERNAL_GRAPHVIZ "disable with KDSME_INTERNAL_GRAPHVIZ=OFF")

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

Expand Down Expand Up @@ -296,7 +314,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated -Wextra -Woverloaded-virtual -Winit-self")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wmissing-include-dirs -Wunused -Wno-div-by-zero -Wundef")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpointer-arith -Wmissing-noreturn -Werror=return-type -Wswitch")
if(NOT BUILD_QT6)
if(NOT KDSME_QT6)
if(HAVE_GXX_GNUXX11) # QNX needs gnu++0x rather than c++0x for compiling QML V4 private headers
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
elseif(HAVE_GXX_CXX11)
Expand Down Expand Up @@ -336,24 +354,24 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
else()
#Always disable tests, examples, docs when used as a submodule
set(${PROJECT_NAME}_IS_ROOT_PROJECT FALSE)
set(BUILD_TESTS FALSE)
set(BUILD_EXAMPLES FALSE)
set(BUILD_DOCS FALSE)
set(BUILD_TESTING FALSE)
set(KDSME_EXAMPLES FALSE)
set(KDSME_DOCS FALSE)
endif()

if(BUILD_TESTS AND NOT CMAKE_CROSSCOMPILING)
if(BUILD_TESTING AND NOT CMAKE_CROSSCOMPILING)
enable_testing()
endif()

set(TEST_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data)

add_subdirectory(src)

if(BUILD_EXAMPLES)
if(KDSME_EXAMPLES)
add_subdirectory(examples)
endif()

if(BUILD_DOCS)
if(KDSME_DOCS)
add_subdirectory(docs)
endif()

Expand Down
30 changes: 15 additions & 15 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"generator": "Ninja",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"BUILD_DOCS": "OFF"
"KDSME_DOCS": "OFF"
}
},
{
Expand All @@ -18,7 +18,7 @@
"binaryDir": "${sourceDir}/build-dev",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BUILD_TESTS": "ON"
"BUILD_TESTING": "ON"
}
},
{
Expand All @@ -27,7 +27,7 @@
"inherits": "dev-base",
"binaryDir": "${sourceDir}/build-dev5-external-graphviz",
"cacheVariables": {
"WITH_INTERNAL_GRAPHVIZ": "OFF"
"KDSME_INTERNAL_GRAPHVIZ": "OFF"
}
},
{
Expand All @@ -36,7 +36,7 @@
"inherits": "dev-base",
"binaryDir": "${sourceDir}/build-dev5",
"cacheVariables": {
"WITH_INTERNAL_GRAPHVIZ": "ON"
"KDSME_INTERNAL_GRAPHVIZ": "ON"
}
},
{
Expand All @@ -45,8 +45,8 @@
"inherits": "dev-base",
"binaryDir": "${sourceDir}/build-dev6-external-graphviz",
"cacheVariables": {
"BUILD_QT6": "ON",
"WITH_INTERNAL_GRAPHVIZ": "OFF"
"KDSME_QT6": "ON",
"KDSME_INTERNAL_GRAPHVIZ": "OFF"
}
},
{
Expand All @@ -55,8 +55,8 @@
"inherits": "dev-base",
"binaryDir": "${sourceDir}/build-dev6",
"cacheVariables": {
"BUILD_QT6": "ON",
"WITH_INTERNAL_GRAPHVIZ": "ON"
"KDSME_QT6": "ON",
"KDSME_INTERNAL_GRAPHVIZ": "ON"
}
},
{
Expand All @@ -66,7 +66,7 @@
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"BUILD_TESTS": "OFF"
"BUILD_TESTING": "OFF"
}
},
{
Expand All @@ -75,7 +75,7 @@
"inherits": "rel-base",
"binaryDir": "${sourceDir}/build-rel5-external-graphviz",
"cacheVariables": {
"WITH_INTERNAL_GRAPHVIZ": "OFF"
"KDSME_INTERNAL_GRAPHVIZ": "OFF"
}
},
{
Expand All @@ -84,7 +84,7 @@
"inherits": "rel-base",
"binaryDir": "${sourceDir}/build-rel5",
"cacheVariables": {
"WITH_INTERNAL_GRAPHVIZ": "ON"
"KDSME_INTERNAL_GRAPHVIZ": "ON"
}
},
{
Expand All @@ -93,8 +93,8 @@
"inherits": "rel-base",
"binaryDir": "${sourceDir}/build-rel6-external-graphviz",
"cacheVariables": {
"BUILD_QT6": "ON",
"WITH_INTERNAL_GRAPHVIZ": "OFF"
"KDSME_QT6": "ON",
"KDSME_INTERNAL_GRAPHVIZ": "OFF"
}
},
{
Expand All @@ -103,8 +103,8 @@
"inherits": "rel-base",
"binaryDir": "${sourceDir}/build-rel6",
"cacheVariables": {
"BUILD_QT6": "ON",
"WITH_INTERNAL_GRAPHVIZ": "ON"
"KDSME_QT6": "ON",
"KDSME_INTERNAL_GRAPHVIZ": "ON"
}
}
]
Expand Down
6 changes: 3 additions & 3 deletions INSTALL.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ Building on Windows with mingw:
% mingw32-make install

== Testing ==
To build the testing harness, pass -DBUILD_TESTS=true to CMake, like so:
% cmake -DBUILD_TESTS=true
To build the testing harness, pass -DBUILD_TESTING=true to CMake, like so:
% cmake -DBUILD_TESTING=true

Then run 'make test' to run the unit tests.

Expand All @@ -68,7 +68,7 @@ on Windows you might want set "GRAPHVIZ_ROOT=C:\Program Files\Graphviz".

When you run cmake it will inform you about missing dependencies.

Graphviz can be built for you by passing the -DWITH_INTERNAL_GRAPHVIZ=True
Graphviz can be built for you by passing the -DKDSME_INTERNAL_GRAPHVIZ=True
option to CMake. Be advised that Graphviz may have different minimum
requirements for CMake, compiler, etc. than this software.

Expand Down
Loading
Loading