Skip to content

Commit 0edda59

Browse files
committed
Fix setting QT_DISABLE_DEPRECATED_BEFORE macro
1 parent ddc1678 commit 0edda59

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

cmake/CommonOptions.cmake

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ endif()
88

99
if (TREMOTESF_QT6)
1010
set(TREMOTESF_QT_VERSION_MAJOR 6)
11-
set(TREMOTESF_MINIMUM_QT_VERSION 6.6)
11+
set(TREMOTESF_MINIMUM_QT_VERSION 6.6.0)
1212
else()
1313
set(TREMOTESF_QT_VERSION_MAJOR 5)
14-
set(TREMOTESF_MINIMUM_QT_VERSION 5.15)
14+
set(TREMOTESF_MINIMUM_QT_VERSION 5.15.0)
1515
endif()
1616

1717
if (UNIX AND NOT APPLE)
@@ -32,6 +32,20 @@ if (MSVC AND (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY))
3232
endif()
3333
endif()
3434

35+
function(append_qt_disable_deprecated_macro LIST_VAR)
36+
string(REPLACE "." ";" min_qt_version_components "${TREMOTESF_MINIMUM_QT_VERSION}")
37+
list(GET min_qt_version_components 0 major)
38+
list(GET min_qt_version_components 1 minor)
39+
list(GET min_qt_version_components 2 patch)
40+
math(EXPR macro_value "(${major}<<16)|(${minor}<<8)|(${patch})" OUTPUT_FORMAT HEXADECIMAL)
41+
if (TREMOTESF_QT6)
42+
list(APPEND "${LIST_VAR}" "QT_DISABLE_DEPRECATED_UP_TO=${macro_value}")
43+
else()
44+
list(APPEND "${LIST_VAR}" "QT_DISABLE_DEPRECATED_BEFORE=${macro_value}")
45+
endif()
46+
return(PROPAGATE "${LIST_VAR}")
47+
endfunction()
48+
3549
function(set_common_options_on_targets)
3650
set(
3751
gcc_style_warnings
@@ -126,10 +140,15 @@ function(set_common_options_on_targets)
126140
set(
127141
common_compile_definitions
128142
QT_DEPRECATED_WARNINGS
129-
QT_DISABLE_DEPRECATED_BEFORE=0x050e00
130143
QT_MESSAGELOGCONTEXT
131144
)
132145

146+
# QT_DISABLE_DEPRECATED_BEFORE can cause linker errors with static Qt
147+
get_target_property(qt_library_type Qt::Core TYPE)
148+
if (NOT (qt_library_type STREQUAL STATIC_LIBRARY))
149+
append_qt_disable_deprecated_macro(common_compile_definitions)
150+
endif()
151+
133152
if (WIN32)
134153
include("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/WindowsMinimumVersion.cmake")
135154
# Minimum supported version, 0x0A00 = Windows 10

src/rpc/requestrouter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

5+
// Needed to access deprecated QSsl::SslProtocol enum values
6+
#undef QT_DISABLE_DEPRECATED_BEFORE
7+
#undef QT_DISABLE_DEPRECATED_UP_TO
8+
59
#include "requestrouter.h"
610

711
#include <optional>

0 commit comments

Comments
 (0)