Skip to content

Commit 648e420

Browse files
drdanziamsergio
authored andcommitted
Rename cmake options
Following the conventions used in the other KD* repositories, use variables with a name that start with the project name. Renamed 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_STATIC -> BUILD_SHARED_LIBS * BUILD_TESTS -> BUILD_TESTING Cache entries are automatically updated.
1 parent 45a1571 commit 648e420

File tree

21 files changed

+137
-112
lines changed

21 files changed

+137
-112
lines changed

.github/workflows/build-external-graphviz.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ jobs:
6767
--warn-uninitialized -Werror=dev
6868
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
6969
-DCMAKE_OSX_ARCHITECTURES="arm64"
70-
-DBUILD_QT6=ON
71-
-DBUILD_TESTS=${{ matrix.build_type == 'Debug' }}
72-
-DBUILD_EXAMPLES=ON
73-
-DBUILD_DOCS=${{ matrix.build_type == 'Debug' && runner.os == 'Linux' }}
74-
-DBUILD_STATIC=${{ matrix.lib_type == 'Static' }}
75-
-DWITH_INTERNAL_GRAPHVIZ=OFF
70+
-DKDSME_QT6=ON
71+
-DBUILD_TESTING=${{ matrix.build_type == 'Debug' }}
72+
-DKDSME_EXAMPLES=ON
73+
-DKDSME_DOCS=${{ matrix.build_type == 'Debug' && runner.os == 'Linux' }}
74+
-DBUILD_SHARED_LIBS=${{ matrix.lib_type == 'Shared' }}
75+
-DKDSME_INTERNAL_GRAPHVIZ=OFF
7676
7777
- name: Build Project
7878
run: cmake --build ./build

.github/workflows/build.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ jobs:
9090
--warn-uninitialized -Werror=dev
9191
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
9292
-DCMAKE_OSX_ARCHITECTURES="${{ matrix.config.macos_architectures }}"
93-
-DBUILD_QT6=${{ startsWith(matrix.config.qt_version, '6.') }}
94-
-DBUILD_TESTS=${{ matrix.build_type == 'Debug' }}
95-
-DBUILD_EXAMPLES=ON
96-
-DBUILD_DOCS=${{ matrix.build_type == 'Debug' && runner.os == 'Linux' }}
97-
-DBUILD_STATIC=${{ matrix.lib_type == 'Static' }}
93+
-DKDSME_QT6=${{ startsWith(matrix.config.qt_version, '6.') }}
94+
-DBUILD_TESTING=${{ matrix.build_type == 'Debug' }}
95+
-DKDSME_EXAMPLES=ON
96+
-DKDSME_DOCS=${{ matrix.build_type == 'Debug' && runner.os == 'Linux' }}
97+
-DBUILD_SHARED_LIBS=${{ matrix.lib_type == 'Shared' }}
9898
9999
- name: Build Project
100100
run: cmake --build ./build

.github/workflows/documentation.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545

4646
- name: Configure project
4747
run: >
48-
cmake -S . -B ./build -DBUILD_DOCS=ON
48+
cmake -S . -B ./build -DKDSME_DOCS=ON
4949
5050
- name: Create docs
5151
run: cmake --build ./build --target docs

3rdparty/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
# Contact [email protected] if any conditions of this licensing are not clear to you.
1414
#
1515

16-
if(WITH_INTERNAL_GRAPHVIZ)
16+
if(KDSME_INTERNAL_GRAPHVIZ)
1717
# Function creates extra scope to keep these variables local
1818
function(add_graphviz_subdirectory)
1919
#TODO check if there are unneeded features to disable
2020

21-
if(WITH_STATIC_GRAPHVIZ)
21+
if(KDSME_STATIC_GRAPHVIZ)
2222
set(BUILD_SHARED_LIBS OFF)
2323
endif()
2424
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/graphviz/CMakeLists.txt")

CHANGES

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ Version 2.0.0:
77
* Use official Graphviz from upstream with -DWITH_INTERNAL_GRAPHVIZ=True
88
(Bad side-effect: allows dynamic builds only, but external graphviz still supported)
99
* Fixed build with more recent graphviz versions
10-
* Buildsystem: new Option BUILD_STATIC to create static libraries
10+
* Buildsystem: new Option BUILD_SHARED_LIBS to select between shared or static libraries
11+
* Renamed the following CMake options
12+
* BUILD_DOCS -> KDSME_DOCS
13+
* BUILD_EXAMPLES -> KDSME_EXAMPLES
14+
* BUILD_QT6 -> KDSME_QT6
15+
* WITH_INTERNAL_GRAPHVIZ -> KDSME_INTERNAL_GRAPHVIZ
16+
* WITH_STATIC_GRAPHVIZ -> KDSME_STATIC_GRAPHVIZ
17+
* Use standard cmake options instead of custom ones:
18+
* BUILD_TESTS -> BUILD_TESTING
1119

1220
Version 1.2.8:
1321
--------------

CMakeLists.txt

+55-37
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,37 @@
1717
# Pass the following variables to cmake to control the build:
1818
# (See INSTALL.txt for more information)
1919
#
20-
# -DWITH_INTERNAL_GRAPHVIZ=[true|false]
20+
# -DKDSME_INTERNAL_GRAPHVIZ=[true|false]
2121
# Allow to build with an external Graphviz install.
2222
# We build with our internal graphviz sub-module but someone might want to
2323
# build against distro package, which is not recommended and probably broken.
2424
# Default=true
2525
#
26-
# -WITH_STATIC_GRAPHVIZ=[true|false]
26+
# -KDSME_STATIC_GRAPHVIZ=[true|false]
2727
# Allow the internal Graphviz build to be statically.
2828
# Currently shared graphviz builds on Windows have link issues.
2929
# Default=true
3030
#
31-
# -DBUILD_QT6=[true|false]
31+
# -DKDSME_QT6=[true|false]
3232
# Build against Qt6 rather than Qt5
3333
# Default=false (Qt5 will be used even if Qt6 is available)
3434
#
35-
# -DBUILD_DOCS=[true|false]
35+
# -DKDSME_DOCS=[true|false]
3636
# Build the documentation. Documentation is never built when cross-compiling.
3737
# Default=true
3838
#
39-
# -DBUILD_EXAMPLES=[true|false]
39+
# -DKDSME_EXAMPLES=[true|false]
4040
# Build the examples. Examples are never built when cross-compiling.
4141
# Default=true
4242
#
43-
# -DBUILD_TESTS=[true|false]
43+
# -DBUILD_TESTING=[true|false]
4444
# Build the test harness. Tests are never built when cross-compiling.
4545
# Note: disabling tests also disables building the kdstatemachineeditor test application.
4646
# Default=True
4747
#
48-
# -DBUILD_STATIC=[true|false]
49-
# Build static libraries
50-
# Default=false
48+
# -DBUILD_SHARED_LIBS=[true|false]
49+
# Build shared libraries
50+
# Default=true
5151

5252
cmake_minimum_required(VERSION 3.16)
5353

@@ -69,23 +69,38 @@ endif()
6969

7070
include(FeatureSummary)
7171

72+
# Declare an option as renamed, and eventually update the old cache entry
73+
function(renamed_option _old _new)
74+
get_property(
75+
_old_set
76+
CACHE ${_old}
77+
PROPERTY VALUE
78+
SET
79+
)
80+
if(_old_set)
81+
message(DEPRECATION "\"${_old}\" was renamed \"${_new}\". Cache entry will be updated.")
82+
set_property(CACHE ${_new} PROPERTY VALUE ${${_old}})
83+
unset(${_old} CACHE)
84+
endif()
85+
endfunction()
86+
7287
if(CMAKE_CROSSCOMPILING)
73-
set(BUILD_DOCS OFF)
74-
set(BUILD_EXAMPLES OFF)
75-
set(BUILD_TESTS OFF)
88+
set(KDSME_DOCS OFF)
89+
set(KDSME_EXAMPLES OFF)
90+
set(BUILD_TESTING OFF)
7691
else()
77-
option(BUILD_DOCS "Build KDStateMachineEditor documentation" ON)
78-
option(BUILD_EXAMPLES "Build examples directory" ON)
79-
option(BUILD_TESTS "Build the test harness" ON)
92+
option(KDSME_DOCS "Build KDStateMachineEditor documentation" ON)
93+
option(KDSME_EXAMPLES "Build examples directory" ON)
94+
option(BUILD_TESTING "Build the test harness" ON)
8095
endif()
81-
option(BUILD_QT6 "Build against Qt 6" OFF)
82-
option(BUILD_STATIC "Build statically" OFF)
96+
renamed_option(BUILD_DOCS KDSME_DOCS)
97+
renamed_option(BUILD_EXAMPLES KDSME_EXAMPLES)
98+
renamed_option(BUILD_TESTS BUILD_TESTING)
8399

84-
if(BUILD_STATIC)
85-
set(BUILD_LIBRARY_MODE "STATIC")
86-
else()
87-
set(BUILD_LIBRARY_MODE "SHARED")
88-
endif()
100+
option(KDSME_QT6 "Build against Qt 6" OFF)
101+
renamed_option(BUILD_QT6 KDSME_QT6)
102+
103+
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
89104

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

109-
if(BUILD_QT6)
124+
if(KDSME_QT6)
110125
set(QT_VERSION_MAJOR 6)
111126
set(QT_MIN_VERSION "6.1.0")
112127
find_package(
@@ -146,7 +161,7 @@ set_package_properties(
146161
)
147162

148163
# QtXmlPatterns is removed since Qt6
149-
if(NOT BUILD_QT6)
164+
if(NOT KDSME_QT6)
150165
find_package(Qt5XmlPatterns ${QT_MIN_VERSION} CONFIG QUIET)
151166
set_package_properties(
152167
Qt5XmlPatterns PROPERTIES
@@ -199,7 +214,7 @@ set(LIB_INSTALL_DIR
199214
${CMAKE_INSTALL_LIBDIR}
200215
CACHE STRING "Library install destination."
201216
)
202-
if(BUILD_QT6)
217+
if(KDSME_QT6)
203218
set(INCLUDE_INSTALL_ROOT ${CMAKE_INSTALL_INCLUDEDIR}/${CMAKE_PROJECT_NAME}${KDSME_LIBRARY_QTID})
204219
else()
205220
set(INCLUDE_INSTALL_ROOT ${CMAKE_INSTALL_INCLUDEDIR}/)
@@ -227,13 +242,16 @@ set(INSTALL_TARGETS_DEFAULT_ARGS
227242
"/Applications/Qt${QT_VERSION_MAJOR}"
228243
)
229244

230-
option(WITH_INTERNAL_GRAPHVIZ "Enable internal build of external project Graphviz" ON)
231-
add_feature_info("Internal build of Graphviz" WITH_INTERNAL_GRAPHVIZ "disable with WITH_INTERNAL_GRAPHVIZ=OFF")
245+
option(KDSME_INTERNAL_GRAPHVIZ "Enable internal build of external project Graphviz" ON)
246+
renamed_option(WITH_INTERNAL_GRAPHVIZ KDSME_INTERNAL_GRAPHVIZ)
247+
add_feature_info("Internal build of Graphviz" KDSME_INTERNAL_GRAPHVIZ "disable with KDSME_INTERNAL_GRAPHVIZ=OFF")
232248

233-
if(WITH_INTERNAL_GRAPHVIZ)
234-
option(WITH_STATIC_GRAPHVIZ "Enable static build of Graphviz when internally building" ON)
249+
if(KDSME_INTERNAL_GRAPHVIZ)
250+
option(KDSME_STATIC_GRAPHVIZ "Enable static build of Graphviz when internally building" ON)
251+
renamed_option(WITH_STATIC_GRAPHVIZ KDSME_STATIC_GRAPHVIZ)
235252
add_feature_info(
236-
"Statically build Graphviz for internal builds" WITH_INTERNAL_GRAPHVIZ "disable with WITH_STATIC_GRAPHVIZ=OFF"
253+
"Statically build Graphviz for internal builds" KDSME_INTERNAL_GRAPHVIZ
254+
"disable with KDSME_STATIC_GRAPHVIZ=OFF"
237255
)
238256
set(GRAPHVIZ_FOUND ON)
239257

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

344-
if(BUILD_TESTS AND NOT CMAKE_CROSSCOMPILING)
362+
if(BUILD_TESTING AND NOT CMAKE_CROSSCOMPILING)
345363
enable_testing()
346364
endif()
347365

348366
set(TEST_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data)
349367

350368
add_subdirectory(src)
351369

352-
if(BUILD_EXAMPLES)
370+
if(KDSME_EXAMPLES)
353371
add_subdirectory(examples)
354372
endif()
355373

356-
if(BUILD_DOCS)
374+
if(KDSME_DOCS)
357375
add_subdirectory(docs)
358376
endif()
359377

CMakePresets.json

+15-15
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"generator": "Ninja",
88
"cacheVariables": {
99
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
10-
"BUILD_DOCS": "OFF"
10+
"KDSME_DOCS": "OFF"
1111
}
1212
},
1313
{
@@ -18,7 +18,7 @@
1818
"binaryDir": "${sourceDir}/build-dev",
1919
"cacheVariables": {
2020
"CMAKE_BUILD_TYPE": "Debug",
21-
"BUILD_TESTS": "ON"
21+
"BUILD_TESTING": "ON"
2222
}
2323
},
2424
{
@@ -27,7 +27,7 @@
2727
"inherits": "dev-base",
2828
"binaryDir": "${sourceDir}/build-dev5-external-graphviz",
2929
"cacheVariables": {
30-
"WITH_INTERNAL_GRAPHVIZ": "OFF"
30+
"KDSME_INTERNAL_GRAPHVIZ": "OFF"
3131
}
3232
},
3333
{
@@ -36,7 +36,7 @@
3636
"inherits": "dev-base",
3737
"binaryDir": "${sourceDir}/build-dev5",
3838
"cacheVariables": {
39-
"WITH_INTERNAL_GRAPHVIZ": "ON"
39+
"KDSME_INTERNAL_GRAPHVIZ": "ON"
4040
}
4141
},
4242
{
@@ -45,8 +45,8 @@
4545
"inherits": "dev-base",
4646
"binaryDir": "${sourceDir}/build-dev6-external-graphviz",
4747
"cacheVariables": {
48-
"BUILD_QT6": "ON",
49-
"WITH_INTERNAL_GRAPHVIZ": "OFF"
48+
"KDSME_QT6": "ON",
49+
"KDSME_INTERNAL_GRAPHVIZ": "OFF"
5050
}
5151
},
5252
{
@@ -55,8 +55,8 @@
5555
"inherits": "dev-base",
5656
"binaryDir": "${sourceDir}/build-dev6",
5757
"cacheVariables": {
58-
"BUILD_QT6": "ON",
59-
"WITH_INTERNAL_GRAPHVIZ": "ON"
58+
"KDSME_QT6": "ON",
59+
"KDSME_INTERNAL_GRAPHVIZ": "ON"
6060
}
6161
},
6262
{
@@ -66,7 +66,7 @@
6666
"hidden": true,
6767
"cacheVariables": {
6868
"CMAKE_BUILD_TYPE": "Release",
69-
"BUILD_TESTS": "OFF"
69+
"BUILD_TESTING": "OFF"
7070
}
7171
},
7272
{
@@ -75,7 +75,7 @@
7575
"inherits": "rel-base",
7676
"binaryDir": "${sourceDir}/build-rel5-external-graphviz",
7777
"cacheVariables": {
78-
"WITH_INTERNAL_GRAPHVIZ": "OFF"
78+
"KDSME_INTERNAL_GRAPHVIZ": "OFF"
7979
}
8080
},
8181
{
@@ -84,7 +84,7 @@
8484
"inherits": "rel-base",
8585
"binaryDir": "${sourceDir}/build-rel5",
8686
"cacheVariables": {
87-
"WITH_INTERNAL_GRAPHVIZ": "ON"
87+
"KDSME_INTERNAL_GRAPHVIZ": "ON"
8888
}
8989
},
9090
{
@@ -93,8 +93,8 @@
9393
"inherits": "rel-base",
9494
"binaryDir": "${sourceDir}/build-rel6-external-graphviz",
9595
"cacheVariables": {
96-
"BUILD_QT6": "ON",
97-
"WITH_INTERNAL_GRAPHVIZ": "OFF"
96+
"KDSME_QT6": "ON",
97+
"KDSME_INTERNAL_GRAPHVIZ": "OFF"
9898
}
9999
},
100100
{
@@ -103,8 +103,8 @@
103103
"inherits": "rel-base",
104104
"binaryDir": "${sourceDir}/build-rel6",
105105
"cacheVariables": {
106-
"BUILD_QT6": "ON",
107-
"WITH_INTERNAL_GRAPHVIZ": "ON"
106+
"KDSME_QT6": "ON",
107+
"KDSME_INTERNAL_GRAPHVIZ": "ON"
108108
}
109109
}
110110
]

INSTALL.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ Building on Windows with mingw:
4242
% mingw32-make install
4343

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

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

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

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

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

0 commit comments

Comments
 (0)