Skip to content

Commit

Permalink
Sync extra cmake from upstream KDE and KDAB (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
winterz committed Jan 7, 2024
1 parent 36f7b98 commit e70a798
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
2 changes: 0 additions & 2 deletions cmake/ECM/modules/ECMGenerateHeaders.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmake/ECM/modules/ECMSetupVersion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
9 changes: 8 additions & 1 deletion cmake/ECM/modules/QtVersionOption.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down
16 changes: 9 additions & 7 deletions cmake/KDAB/modules/KDCompilerFlags.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# SPDX-FileCopyrightText: 2021-2023 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
# SPDX-FileCopyrightText: 2021 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
#
# SPDX-License-Identifier: BSD-3-Clause
#
Expand Down Expand Up @@ -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()

Expand All @@ -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}")
Expand Down
7 changes: 5 additions & 2 deletions cmake/KDAB/modules/KDFunctions.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# SPDX-FileCopyrightText: 2021-2023 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
# SPDX-FileCopyrightText: 2021 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
#
# SPDX-License-Identifier: BSD-3-Clause
#
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion cmake/KDAB/modules/KDInstallLocation.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# SPDX-FileCopyrightText: 2012-2023 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
# SPDX-FileCopyrightText: 2012 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
#
# SPDX-License-Identifier: BSD-3-Clause
#
Expand Down

0 comments on commit e70a798

Please sign in to comment.