Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecated macro #566

Merged
merged 2 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 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 @@ -123,12 +137,13 @@ function(set_common_options_on_targets)
list(APPEND common_compile_options ${TREMOTESF_COMMON_COMPILE_OPTIONS})
endif()

set(
common_compile_definitions
QT_DEPRECATED_WARNINGS
QT_DISABLE_DEPRECATED_BEFORE=0x050e00
QT_MESSAGELOGCONTEXT
)
set(common_compile_definitions 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")
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
Loading