Skip to content

Commit

Permalink
Fix setting QT_DISABLE_DEPRECATED_BEFORE macro
Browse files Browse the repository at this point in the history
  • Loading branch information
equeim committed Dec 16, 2024
1 parent ddc1678 commit 0edda59
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
25 changes: 22 additions & 3 deletions cmake/CommonOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ endif()

if (TREMOTESF_QT6)
set(TREMOTESF_QT_VERSION_MAJOR 6)
set(TREMOTESF_MINIMUM_QT_VERSION 6.6)
set(TREMOTESF_MINIMUM_QT_VERSION 6.6.0)
else()
set(TREMOTESF_QT_VERSION_MAJOR 5)
set(TREMOTESF_MINIMUM_QT_VERSION 5.15)
set(TREMOTESF_MINIMUM_QT_VERSION 5.15.0)
endif()

if (UNIX AND NOT APPLE)
Expand All @@ -32,6 +32,20 @@ if (MSVC AND (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY))
endif()
endif()

function(append_qt_disable_deprecated_macro LIST_VAR)
string(REPLACE "." ";" min_qt_version_components "${TREMOTESF_MINIMUM_QT_VERSION}")
list(GET min_qt_version_components 0 major)
list(GET min_qt_version_components 1 minor)
list(GET min_qt_version_components 2 patch)
math(EXPR macro_value "(${major}<<16)|(${minor}<<8)|(${patch})" OUTPUT_FORMAT HEXADECIMAL)
if (TREMOTESF_QT6)
list(APPEND "${LIST_VAR}" "QT_DISABLE_DEPRECATED_UP_TO=${macro_value}")
else()
list(APPEND "${LIST_VAR}" "QT_DISABLE_DEPRECATED_BEFORE=${macro_value}")
endif()
return(PROPAGATE "${LIST_VAR}")
endfunction()

function(set_common_options_on_targets)
set(
gcc_style_warnings
Expand Down Expand Up @@ -126,10 +140,15 @@ function(set_common_options_on_targets)
set(
common_compile_definitions
QT_DEPRECATED_WARNINGS
QT_DISABLE_DEPRECATED_BEFORE=0x050e00
QT_MESSAGELOGCONTEXT
)

# QT_DISABLE_DEPRECATED_BEFORE can cause linker errors with static Qt
get_target_property(qt_library_type Qt::Core TYPE)
if (NOT (qt_library_type STREQUAL STATIC_LIBRARY))
append_qt_disable_deprecated_macro(common_compile_definitions)
endif()

if (WIN32)
include("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/WindowsMinimumVersion.cmake")
# Minimum supported version, 0x0A00 = Windows 10
Expand Down
4 changes: 4 additions & 0 deletions src/rpc/requestrouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
//
// SPDX-License-Identifier: GPL-3.0-or-later

// Needed to access deprecated QSsl::SslProtocol enum values
#undef QT_DISABLE_DEPRECATED_BEFORE
#undef QT_DISABLE_DEPRECATED_UP_TO

#include "requestrouter.h"

#include <optional>
Expand Down

0 comments on commit 0edda59

Please sign in to comment.