Skip to content

Commit 5c12dc5

Browse files
authored
build: Add an option to use a bundled KDSingleApplication (flameshot-org#4130)
When packaging, distros like to not use bundled dependencies when possible. This adds an option to use a bundled version of KDSingleApplication, or a system version of the library. I briefly explored doing the same for Qt-Color-Widgets, but it seems to expect to be bundled in a project. Signed-off-by: Evan Maddock <[email protected]>
1 parent 23fade7 commit 5c12dc5

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

CMakeLists.txt

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ option(FLAMESHOT_DEBUG_CAPTURE "Enable mode to make debugging easier" OFF)
7474
option(USE_MONOCHROME_ICON "Build using monochrome icon as default" OFF)
7575
option(GENERATE_TS "Regenerate translation source files" OFF)
7676
option(USE_KDSINGLEAPPLICATION "Use KDSingleApplication library" ON)
77+
option(USE_BUNDLED_KDSINGLEAPPLICATION "Use a bundled version of the KDSingleApplication library" ${USE_KDSINGLEAPPLICATION})
7778
option(USE_LAUNCHER_ABSOLUTE_PATH "Use absolute path for the desktop launcher" ON)
7879
option(USE_WAYLAND_CLIPBOARD "USE KF Gui Wayland Clipboard" OFF)
7980
option(DISABLE_UPDATE_CHECKER "Disable check for updates" OFF)
@@ -108,19 +109,23 @@ enable_sanitizers(project_options)
108109
# allow for static analysis options include(cmake/StaticAnalyzers.cmake)
109110

110111
if (USE_KDSINGLEAPPLICATION)
111-
set(KDSingleApplication_EXAMPLES OFF CACHE BOOL "Don't build the examples")
112-
set(KDSingleApplication_STATIC ON CACHE BOOL "Build static versions of the libraries")
112+
if (USE_BUNDLED_KDSINGLEAPPLICATION)
113+
set(KDSingleApplication_EXAMPLES OFF CACHE BOOL "Don't build the examples")
114+
set(KDSingleApplication_STATIC ON CACHE BOOL "Build static versions of the libraries")
113115

114-
# Check if KDSingleApplication is available locally
115-
if(EXISTS "${CMAKE_SOURCE_DIR}/external/KDSingleApplication/CMakeLists.txt")
116-
add_subdirectory("${CMAKE_SOURCE_DIR}/external/KDSingleApplication")
116+
# Check if KDSingleApplication is available locally
117+
if(EXISTS "${CMAKE_SOURCE_DIR}/external/KDSingleApplication/CMakeLists.txt")
118+
add_subdirectory("${CMAKE_SOURCE_DIR}/external/KDSingleApplication")
119+
else()
120+
FetchContent_Declare(
121+
kdsingleApplication
122+
GIT_REPOSITORY https://github.com/KDAB/KDSingleApplication.git
123+
GIT_TAG v1.2.0
124+
)
125+
FetchContent_MakeAvailable(kdsingleApplication)
126+
endif()
117127
else()
118-
FetchContent_Declare(
119-
kdsingleApplication
120-
GIT_REPOSITORY https://github.com/KDAB/KDSingleApplication.git
121-
GIT_TAG v1.2.0
122-
)
123-
FetchContent_MakeAvailable(KDSingleApplication)
128+
find_package(KDSingleApplication-qt6 REQUIRED)
124129
endif()
125130
endif()
126131

src/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,13 @@ if (USE_KDSINGLEAPPLICATION)
218218
message(STATUS "KDSingleApplication is used!")
219219
add_compile_definitions(USE_KDSINGLEAPPLICATION=1)
220220

221+
if (USE_BUNDLED_KDSINGLEAPPLICATION)
222+
target_include_directories(flameshot PRIVATE ${kdsingleapplication_SOURCE_DIR} ${kdsingleapplication_BINARY_DIR})
223+
endif()
224+
221225
target_link_libraries(
222226
flameshot
223-
kdsingleapplication
227+
KDAB::kdsingleapplication
224228
)
225229
endif()
226230

src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-FileCopyrightText: 2017-2019 Alejandro Sirgo Rica & Contributors
33

44
#ifdef USE_KDSINGLEAPPLICATION
5-
#include "kdsingleapplication.h"
5+
#include <kdsingleapplication.h>
66
#ifdef Q_OS_UNIX
77
#include "core/signaldaemon.h"
88
#include "csignal"

0 commit comments

Comments
 (0)