From e70a798a0ea1d65f888505c0b2f6f0c020a23786 Mon Sep 17 00:00:00 2001 From: Allen Winter Date: Sun, 7 Jan 2024 07:23:04 -0500 Subject: [PATCH] Sync extra cmake from upstream KDE and KDAB (#279) --- cmake/ECM/modules/ECMGenerateHeaders.cmake | 2 -- cmake/ECM/modules/ECMSetupVersion.cmake | 2 +- cmake/ECM/modules/QtVersionOption.cmake | 9 ++++++++- cmake/KDAB/modules/KDCompilerFlags.cmake | 16 +++++++++------- cmake/KDAB/modules/KDFunctions.cmake | 7 +++++-- cmake/KDAB/modules/KDInstallLocation.cmake | 2 +- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/cmake/ECM/modules/ECMGenerateHeaders.cmake b/cmake/ECM/modules/ECMGenerateHeaders.cmake index 86f35adb..1ae9cf2b 100644 --- a/cmake/ECM/modules/ECMGenerateHeaders.cmake +++ b/cmake/ECM/modules/ECMGenerateHeaders.cmake @@ -118,8 +118,6 @@ Example usage (with ``PREFIX``): Since pre-1.0.0. #]=======================================================================] -include(CMakeParseArguments) - function(ECM_GENERATE_HEADERS camelcase_forwarding_headers_var) set(options) set(oneValueArgs ORIGINAL HEADER_EXTENSION OUTPUT_DIR PREFIX REQUIRED_HEADERS COMMON_HEADER RELATIVE) diff --git a/cmake/ECM/modules/ECMSetupVersion.cmake b/cmake/ECM/modules/ECMSetupVersion.cmake index 330f7365..7164c9a0 100644 --- a/cmake/ECM/modules/ECMSetupVersion.cmake +++ b/cmake/ECM/modules/ECMSetupVersion.cmake @@ -142,7 +142,7 @@ function(ecm_setup_version _version) string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.0*([0-9]+).*" "\\1" _patch "${_version}") endif() - if(NOT ESV_SOVERSION) + if(NOT DEFINED ESV_SOVERSION) # use DEFINED, so "0" as valid SO version is not evaluated to FALSE set(ESV_SOVERSION ${_major}) endif() diff --git a/cmake/ECM/modules/QtVersionOption.cmake b/cmake/ECM/modules/QtVersionOption.cmake index ea37da22..0ea03658 100644 --- a/cmake/ECM/modules/QtVersionOption.cmake +++ b/cmake/ECM/modules/QtVersionOption.cmake @@ -12,6 +12,9 @@ that is, if the major Qt version has not yet been determined otherwise This module is typically included by other modules requiring knowledge about the major Qt version. +If the ECM version passed to find_package was at least 5.240.0 Qt6 is picked by default. +Otherwise Qt5 is picked. + ``QT_MAJOR_VERSION`` is defined to either be "5" or "6". Since 5.82.0. @@ -26,7 +29,11 @@ if (TARGET Qt5::Core) elseif (TARGET Qt6::Core) set(QT_MAJOR_VERSION 6) else() - option(BUILD_WITH_QT6 "Build against Qt 6" OFF) + if (ECM_GLOBAL_FIND_VERSION VERSION_GREATER_EQUAL 5.240) + option(BUILD_WITH_QT6 "Build against Qt 6" ON) + else() + option(BUILD_WITH_QT6 "Build against Qt 6" OFF) + endif() if (BUILD_WITH_QT6) set(QT_MAJOR_VERSION 6) diff --git a/cmake/KDAB/modules/KDCompilerFlags.cmake b/cmake/KDAB/modules/KDCompilerFlags.cmake index 1a01186b..9331d073 100644 --- a/cmake/KDAB/modules/KDCompilerFlags.cmake +++ b/cmake/KDAB/modules/KDCompilerFlags.cmake @@ -1,5 +1,5 @@ # -# SPDX-FileCopyrightText: 2021-2023 Klarälvdalens Datakonsult AB, a KDAB Group company +# SPDX-FileCopyrightText: 2021 Klarälvdalens Datakonsult AB, a KDAB Group company # # SPDX-License-Identifier: BSD-3-Clause # @@ -36,9 +36,10 @@ endif() # Do not treat the operator name keywords and, bitand, bitor, compl, not, or and xor as synonyms as keywords. # They're not supported under Visual Studio out of the box thus using them limits the portability of code -if(CMAKE_COMPILER_IS_GNUCXX OR - CMAKE_C_COMPILER_ID MATCHES "Clang" OR - (CMAKE_C_COMPILER_ID STREQUAL "Intel" AND NOT WIN32)) +if(CMAKE_COMPILER_IS_GNUCXX + OR CMAKE_C_COMPILER_ID MATCHES "Clang" + OR (CMAKE_C_COMPILER_ID STREQUAL "Intel" AND NOT WIN32) +) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-operator-names") endif() @@ -61,9 +62,10 @@ if(CYGWIN) add_definitions(-D_GNU_SOURCE) endif() -if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT APPLE) OR - (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT APPLE) OR - (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND NOT WIN32)) +if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT APPLE) + OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT APPLE) + OR (CMAKE_CXX_COMPILER_ID STREQUAL "Intel" AND NOT WIN32) +) # Linker warnings should be treated as errors set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings ${CMAKE_SHARED_LINKER_FLAGS}") set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings ${CMAKE_MODULE_LINKER_FLAGS}") diff --git a/cmake/KDAB/modules/KDFunctions.cmake b/cmake/KDAB/modules/KDFunctions.cmake index 2aa54f12..38faeb3b 100644 --- a/cmake/KDAB/modules/KDFunctions.cmake +++ b/cmake/KDAB/modules/KDFunctions.cmake @@ -1,5 +1,5 @@ # -# SPDX-FileCopyrightText: 2021-2023 Klarälvdalens Datakonsult AB, a KDAB Group company +# SPDX-FileCopyrightText: 2021 Klarälvdalens Datakonsult AB, a KDAB Group company # # SPDX-License-Identifier: BSD-3-Clause # @@ -21,7 +21,10 @@ endif() function(kd_append_if condition value) if(${condition}) foreach(variable ${ARGN}) - set(${variable} "${${variable}} ${value}" PARENT_SCOPE) + set(${variable} + "${${variable}} ${value}" + PARENT_SCOPE + ) endforeach() endif() endfunction() diff --git a/cmake/KDAB/modules/KDInstallLocation.cmake b/cmake/KDAB/modules/KDInstallLocation.cmake index 96baaf3a..4b6e9d19 100644 --- a/cmake/KDAB/modules/KDInstallLocation.cmake +++ b/cmake/KDAB/modules/KDInstallLocation.cmake @@ -1,5 +1,5 @@ # -# SPDX-FileCopyrightText: 2012-2023 Klarälvdalens Datakonsult AB, a KDAB Group company +# SPDX-FileCopyrightText: 2012 Klarälvdalens Datakonsult AB, a KDAB Group company # # SPDX-License-Identifier: BSD-3-Clause #