Skip to content

Commit

Permalink
Merge pull request #53 from KDAB/work/winterz/upstream
Browse files Browse the repository at this point in the history
upstream KDAB and KDE ECM cmake files
  • Loading branch information
Allen Winter authored Apr 1, 2024
2 parents b28f9b2 + 42fbff2 commit 604be97
Show file tree
Hide file tree
Showing 18 changed files with 267 additions and 223 deletions.
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
endif()

if(${PROJECT_NAME}_QT6)
set(Qt_VERSION_MAJOR 6)
set(QT_VERSION_MAJOR 6)
set(QT_MIN_VERSION "6.0.0")
find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Widgets PrintSupport Xml)
list(
Expand All @@ -126,7 +126,7 @@ if(${PROJECT_NAME}_QT6)
)
set(${PROJECT_NAME}_LIBRARY_QTID "-qt6")
else()
set(Qt_VERSION_MAJOR 5)
set(QT_VERSION_MAJOR 5)
set(QT_MIN_VERSION 5.9.0)
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Widgets PrintSupport Xml)
list(
Expand Down Expand Up @@ -236,7 +236,7 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)

# Generate .pri file for qmake users (except when using the VS generator)
if(NOT CMAKE_CONFIGURATION_TYPES)
if(Qt_VERSION_MAJOR EQUAL 5 OR (Qt_VERSION_MAJOR EQUAL 6 AND Qt6Core_VERSION VERSION_GREATER "6.2"))
if(QT_VERSION_MAJOR EQUAL 5 OR (QT_VERSION_MAJOR EQUAL 6 AND Qt6Core_VERSION VERSION_GREATER "6.2"))
include(ECMGeneratePriFile) #not available for Qt6.2 or lower
set(PROJECT_VERSION_STRING ${${PROJECT_NAME}_VERSION})
ecm_generate_pri_file(
Expand Down Expand Up @@ -267,10 +267,10 @@ endif()
add_subdirectory(src)

if(${PROJECT_NAME}_PYTHON_BINDINGS)
if(Qt_VERSION_MAJOR EQUAL 5 AND Qt5Core_VERSION VERSION_LESS 5.12)
if(QT_VERSION_MAJOR EQUAL 5 AND Qt5Core_VERSION VERSION_LESS 5.12)
message(WARNING "** Disabling Python Bindings. Qt version is too old and unsupported.")
set(${PROJECT_NAME}_PYTHON_BINDINGS OFF)
elseif(Qt_VERSION_MAJOR EQUAL 6 AND Qt6Core_VERSION VERSION_LESS 6.2)
elseif(QT_VERSION_MAJOR EQUAL 6 AND Qt6Core_VERSION VERSION_LESS 6.2)
message(WARNING "** Disabling Python Bindings. shiboken6 is too old and unsupported")
set(${PROJECT_NAME}_PYTHON_BINDINGS OFF)
elseif(CMAKE_BUILD_TYPE MATCHES "^[Dd]eb" OR ${PROJECT_NAME}_STATIC)
Expand All @@ -283,12 +283,12 @@ endif()

if(${PROJECT_NAME}_TESTS OR ${PROJECT_NAME}_EXAMPLES)
if(NOT EMSCRIPTEN)
find_package(Qt${Qt_VERSION_MAJOR}Sql)
find_package(Qt${QT_VERSION_MAJOR}Sql)
endif()
endif()

if(${PROJECT_NAME}_TESTS)
find_package(Qt${Qt_VERSION_MAJOR}Test REQUIRED)
find_package(Qt${QT_VERSION_MAJOR}Test REQUIRED)
add_subdirectory(unittests)
endif()

Expand Down
5 changes: 2 additions & 3 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 Expand Up @@ -178,7 +176,8 @@ function(ECM_GENERATE_HEADERS camelcase_forwarding_headers_var)
endif()

set(_actualheader "${CMAKE_CURRENT_SOURCE_DIR}/${EGH_RELATIVE}${originalbasename}.${EGH_HEADER_EXTENSION}")
if (NOT EXISTS ${_actualheader})
get_source_file_property(_generated "${_actualheader}" GENERATED)
if (NOT _generated AND NOT EXISTS ${_actualheader})
message(FATAL_ERROR "Could not find \"${_actualheader}\"")
endif()

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
26 changes: 17 additions & 9 deletions cmake/KDAB/modules/FindKDChart.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,38 @@
# KDChart_LIBRARIES - Path to KDChart libraries.
# KDChart_INCLUDE_DIR - Path to the KDChart include directory.
#
# SPDX-FileCopyrightText: 2015-2023 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
# SPDX-FileCopyrightText: 2015 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
#
# SPDX-License-Identifier: BSD-3-Clause
#

include(FindPackageHandleStandardArgs)

find_library(KDChart_LIBRARIES
NAMES KDChart kdchart kdchart2 kdchartd2 NAMES_PER_DIR
find_library(
KDChart_LIBRARIES
NAMES KDChart
kdchart
kdchart2
kdchartd2
NAMES_PER_DIR
HINTS ${KDChart_DIR} ENV KDChart_DIR
PATH_SUFFIXES lib)
PATH_SUFFIXES lib
)

find_path(KDChart_INCLUDE_DIR
find_path(
KDChart_INCLUDE_DIR
NAMES KDChartGlobal.h
HINTS ${KDChart_DIR} ENV KDChart_DIR
PATH_SUFFIXES include include/KDChart)
PATH_SUFFIXES include include/KDChart
)

mark_as_advanced(KDChart_LIBRARIES KDChart_INCLUDE_DIR)

find_package_handle_standard_args(KDChart DEFAULT_MSG KDChart_LIBRARIES KDChart_INCLUDE_DIR)

if(KDChart_FOUND)
add_library(KDChart UNKNOWN IMPORTED)
set_target_properties(KDChart PROPERTIES
IMPORTED_LOCATION ${KDChart_LIBRARIES}
INTERFACE_INCLUDE_DIRECTORIES ${KDChart_INCLUDE_DIR})
set_target_properties(
KDChart PROPERTIES IMPORTED_LOCATION ${KDChart_LIBRARIES} INTERFACE_INCLUDE_DIRECTORIES ${KDChart_INCLUDE_DIR}
)
endif()
81 changes: 43 additions & 38 deletions cmake/KDAB/modules/FindPySide2.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# SPDX-FileCopyrightText: 2019-2023 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
# SPDX-FileCopyrightText: 2019 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
# Author: Renato Araujo Oliveira Filho <[email protected]>
#
# SPDX-License-Identifier: BSD-3-Clause
Expand All @@ -23,18 +23,9 @@ set(PYSIDE2_FOUND FALSE)
if(PYSIDE2_PRIV_FOUND)
set(PYSIDE2_FOUND TRUE)
message(STATUS "Using PySide2 found in the system!")
pkg_get_variable(SHIBOKEN_BINARY
pyside2
generator_location
)
pkg_get_variable(PYSIDE2_BASEDIR
pyside2
typesystemdir
)
pkg_get_variable(PYSIDE_INCLUDE_DIR
pyside2
includedir
)
pkg_get_variable(SHIBOKEN_BINARY pyside2 generator_location)
pkg_get_variable(PYSIDE2_BASEDIR pyside2 typesystemdir)
pkg_get_variable(PYSIDE_INCLUDE_DIR pyside2 includedir)
set(PYSIDE_TYPESYSTEMS ${PYSIDE2_BASEDIR})
set(PYSIDE2_SO_VERSION ${PYSIDE2_PRIV_VERSION})
set(PYSIDE_LIBRARY ${PYSIDE2_PRIV_LINK_LIBRARIES})
Expand All @@ -45,7 +36,8 @@ else()
get_filename_component(PYTHON_LIBRARY_FILENAME ${PYTHON_LIBRARY_FILENAME} NAME)

execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
COMMAND
${Python3_EXECUTABLE} -c "if True:
import os, sys
try:
import PySide2.QtCore as QtCore
Expand All @@ -58,16 +50,18 @@ else()
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT PYSIDE2_BASEDIR)
message(
FATAL_ERROR
"The PySide2 module could not be imported. Make sure you have it installed "
"by checking the output of \"pip${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR} list\""
message(FATAL_ERROR "The PySide2 module could not be imported. Make sure you have it installed "
"by checking the output of \"pip${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR} list\""
)
endif()

set(PYSIDE_BASEDIR ${PYSIDE2_BASEDIR} CACHE PATH "Top level install of PySide2" FORCE)
set(PYSIDE_BASEDIR
${PYSIDE2_BASEDIR}
CACHE PATH "Top level install of PySide2" FORCE
)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
COMMAND
${Python3_EXECUTABLE} -c "if True:
import os
import PySide2.QtCore as QtCore
print(os.path.basename(QtCore.__file__).split('.', 1)[1])
Expand All @@ -77,7 +71,8 @@ else()
)

execute_process(
COMMAND ${Python3_EXECUTABLE} -c "if True:
COMMAND
${Python3_EXECUTABLE} -c "if True:
import os
import PySide2.QtCore as QtCore
print(';'.join(map(str, QtCore.__version_info__)))
Expand All @@ -103,10 +98,15 @@ else()

#PySide
#===============================================================================
find_path(PYSIDE_INCLUDE_DIR
pyside.h
if(PYSIDE_CUSTOM_PREFIX STREQUAL "")
set(PYSIDE_CUSTOM_PREFIX ${PYSIDE2_BASEDIR})
endif()

find_path(
PYSIDE_INCLUDE_DIR pyside.h
PATHS ${PYSIDE2_BASEDIR}/include ${PYSIDE_CUSTOM_PREFIX}/include/PySide2
NO_DEFAULT_PATH)
NO_DEFAULT_PATH NO_CACHE NO_SYSTEM_ENVIRONMENT_PATH
)

# Platform specific library names
if(MSVC)
Expand All @@ -119,15 +119,17 @@ else()
set(PYSIDE_LIBRARY_BASENAMES "libpyside2.${PYSIDE2_SUFFIX}")
endif()

find_file(PYSIDE_LIBRARY
${PYSIDE_LIBRARY_BASENAMES}
find_file(
PYSIDE_LIBRARY ${PYSIDE_LIBRARY_BASENAMES}
PATHS ${PYSIDE2_BASEDIR} ${PYSIDE_CUSTOM_PREFIX}/lib
NO_DEFAULT_PATH)
NO_DEFAULT_PATH
)

find_path(PYSIDE_TYPESYSTEMS
typesystem_core.xml
find_path(
PYSIDE_TYPESYSTEMS typesystem_core.xml
PATHS ${PYSIDE2_BASEDIR}/typesystems ${PYSIDE_CUSTOM_PREFIX}/share/PySide2/typesystems
NO_DEFAULT_PATH)
NO_DEFAULT_PATH
)
endif()

if(PYSIDE2_FOUND)
Expand All @@ -142,17 +144,20 @@ if(PYSIDE2_FOUND)
set_property(TARGET PySide2::pyside2 PROPERTY IMPORTED_IMPLIB ${PYSIDE_LIBRARY})
endif()
set_property(TARGET PySide2::pyside2 PROPERTY IMPORTED_LOCATION ${PYSIDE_LIBRARY})
set_property(TARGET PySide2::pyside2 APPEND PROPERTY
INTERFACE_INCLUDE_DIRECTORIES
${PYSIDE_INCLUDE_DIR}
${PYSIDE_INCLUDE_DIR}/QtCore/
${PYSIDE_INCLUDE_DIR}/QtGui/
${PYSIDE_INCLUDE_DIR}/QtWidgets/
${Python3_INCLUDE_DIRS}
set_property(
TARGET PySide2::pyside2
APPEND
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
${PYSIDE_INCLUDE_DIR}
${PYSIDE_INCLUDE_DIR}/QtCore/
${PYSIDE_INCLUDE_DIR}/QtGui/
${PYSIDE_INCLUDE_DIR}/QtWidgets/
${Python3_INCLUDE_DIRS}
)
endif()

find_package_handle_standard_args(PySide2
find_package_handle_standard_args(
PySide2
REQUIRED_VARS PYSIDE2_BASEDIR PYSIDE_INCLUDE_DIR PYSIDE_LIBRARY PYSIDE_TYPESYSTEMS
VERSION_VAR PYSIDE2_SO_VERSION
)
Loading

0 comments on commit 604be97

Please sign in to comment.