Skip to content

Commit ea8f2dc

Browse files
drdanziamsergio
authored andcommitted
Add BUILD_STATIC option to create static libraries
1 parent 650665b commit ea8f2dc

File tree

7 files changed

+26
-6
lines changed

7 files changed

+26
-6
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ jobs:
2323
- macos-latest
2424
build_type:
2525
- Debug
26+
lib_type:
27+
- Shared
28+
- Static
2629
config:
2730
- qt_version: 6.6.2
2831
qt_modules: qtscxml
@@ -68,6 +71,7 @@ jobs:
6871
-DBUILD_TESTS=${{ matrix.build_type == 'Debug' }}
6972
-DBUILD_EXAMPLES=ON
7073
-DBUILD_DOCS=${{ matrix.build_type == 'Debug' && runner.os == 'Linux' }}
74+
-DBUILD_STATIC=${{ matrix.lib_type == 'Static' }}
7175
-DWITH_INTERNAL_GRAPHVIZ=OFF
7276
7377
- name: Build Project

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
build_type:
2626
- Debug
2727
- Release
28+
lib_type:
29+
- Shared
30+
- Static
2831
config:
2932
- qt_version: 5.15.2
3033
qt_arch: win64_msvc2019_64
@@ -91,6 +94,7 @@ jobs:
9194
-DBUILD_TESTS=${{ matrix.build_type == 'Debug' }}
9295
-DBUILD_EXAMPLES=ON
9396
-DBUILD_DOCS=${{ matrix.build_type == 'Debug' && runner.os == 'Linux' }}
97+
-DBUILD_STATIC=${{ matrix.lib_type == 'Static' }}
9498
9599
- name: Build Project
96100
run: cmake --build ./build

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Version 2.0.0: (unreleased):
77
* Use official Graphviz from upstream with -DWITH_INTERNAL_GRAPHVIZ=True
88
(Bad side-effect: allows dynamic builds only)
99
* Fixed build with more recent graphviz versions
10+
* Buildsystem: new Option BUILD_STATIC to create static libraries
1011

1112
Version 1.2.8:
1213
--------------

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
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
4851

4952
cmake_minimum_required(VERSION 3.16)
5053

@@ -76,6 +79,13 @@ else()
7679
option(BUILD_TESTS "Build the test harness" ON)
7780
endif()
7881
option(BUILD_QT6 "Build against Qt 6" OFF)
82+
option(BUILD_STATIC "Build statically" OFF)
83+
84+
if(BUILD_STATIC)
85+
set(BUILD_LIBRARY_MODE "STATIC")
86+
else()
87+
set(BUILD_LIBRARY_MODE "SHARED")
88+
endif()
7989

8090
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
8191
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/ECM/modules")

src/core/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ if(GRAPHVIZ_FOUND)
7777
endif()
7878
endif()
7979

80-
add_library(kdstatemachineeditor_core SHARED ${LIB_SRCS})
80+
add_library(kdstatemachineeditor_core ${BUILD_LIBRARY_MODE} ${LIB_SRCS})
8181
add_library(KDSME::Core ALIAS kdstatemachineeditor_core)
8282
target_link_libraries(
8383
kdstatemachineeditor_core
@@ -159,7 +159,7 @@ install(
159159
EXPORT KDSME_TARGETS
160160
${INSTALL_TARGETS_DEFAULT_ARGS}
161161
)
162-
if(MSVC)
162+
if(MSVC AND NOT BUILD_STATIC)
163163
install(
164164
FILES "$<TARGET_PDB_FILE_DIR:kdstatemachineeditor_core>/$<TARGET_PDB_FILE_NAME:kdstatemachineeditor_core>"
165165
DESTINATION ${BIN_INSTALL_DIR}

src/debuginterface/debuginterfaceclient/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if(NOT BUILD_QT6)
1717
qt5_generate_repc(DEBUGINTERFACECLIENT_SRCS ../debuginterface.rep REPLICA)
1818
endif()
1919

20-
add_library(kdstatemachineeditor_debuginterfaceclient SHARED ${DEBUGINTERFACECLIENT_SRCS})
20+
add_library(kdstatemachineeditor_debuginterfaceclient ${BUILD_LIBRARY_MODE} ${DEBUGINTERFACECLIENT_SRCS})
2121

2222
if(BUILD_QT6)
2323
qt6_add_repc_replicas(kdstatemachineeditor_debuginterfaceclient ../debuginterface.rep)
@@ -82,7 +82,7 @@ install(
8282
EXPORT KDSME_TARGETS
8383
${INSTALL_TARGETS_DEFAULT_ARGS}
8484
)
85-
if(MSVC)
85+
if(MSVC AND NOT BUILD_STATIC)
8686
# cmake-lint: disable=C0301
8787
install(
8888
FILES

src/view/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
file(GLOB_RECURSE QML_JS_FILES *.qml *.js)
1717

1818
add_library(
19-
kdstatemachineeditor_view SHARED
19+
kdstatemachineeditor_view
20+
${BUILD_LIBRARY_MODE}
2021
command/command.cpp
2122
command/commandfactory.cpp
2223
command/createelementcommand.cpp
@@ -97,7 +98,7 @@ install(
9798
EXPORT KDSME_TARGETS
9899
${INSTALL_TARGETS_DEFAULT_ARGS}
99100
)
100-
if(MSVC)
101+
if(MSVC AND NOT BUILD_STATIC)
101102
install(
102103
FILES "$<TARGET_PDB_FILE_DIR:kdstatemachineeditor_view>/$<TARGET_PDB_FILE_NAME:kdstatemachineeditor_view>"
103104
DESTINATION ${BIN_INSTALL_DIR}

0 commit comments

Comments
 (0)