First Commit

This commit is contained in:
2025-11-18 14:18:26 -07:00
parent 33eb6e3707
commit 27277ec342
6106 changed files with 3571167 additions and 0 deletions

View File

@@ -0,0 +1,163 @@
#
# SPDX-FileCopyrightText: 2019 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: BSD-3-Clause
#
# PYSIDE_BASEDIR - Top of the PySide2 installation
# PYSIDE_INCLUDE_DIR - Directories to include to use PySide2
# PYSIDE_LIBRARY - Files to link against to use PySide2
# PYSIDE_TYPESYSTEMS - Type system files that should be used by other bindings extending PySide2
#
# You can install PySide2 from Qt repository with
# pip3 install --index-url=https://download.qt.io/official_releases/QtForPython --trusted-host download.qt.io pyside2
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PYSIDE2_PRIV QUIET pyside2)
endif()
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)
set(PYSIDE_TYPESYSTEMS ${PYSIDE2_BASEDIR})
set(PYSIDE2_SO_VERSION ${PYSIDE2_PRIV_VERSION})
set(PYSIDE_LIBRARY ${PYSIDE2_PRIV_LINK_LIBRARIES})
list(GET PYSIDE_LIBRARY 0 PYSIDE_LIBRARY)
else()
# extract python library basename
list(GET Python3_LIBRARIES 0 PYTHON_LIBRARY_FILENAME)
get_filename_component(PYTHON_LIBRARY_FILENAME ${PYTHON_LIBRARY_FILENAME} NAME)
execute_process(
COMMAND
${Python3_EXECUTABLE} -c "if True:
import os, sys
try:
import PySide2.QtCore as QtCore
print(os.path.dirname(QtCore.__file__))
except Exception as error:
print(error, file=sys.stderr)
exit()
"
OUTPUT_VARIABLE PYSIDE2_BASEDIR
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\""
)
endif()
set(PYSIDE_BASEDIR
${PYSIDE2_BASEDIR}
CACHE PATH "Top level install of PySide2" FORCE
)
execute_process(
COMMAND
${Python3_EXECUTABLE} -c "if True:
import os
import PySide2.QtCore as QtCore
print(os.path.basename(QtCore.__file__).split('.', 1)[1])
"
OUTPUT_VARIABLE PYSIDE2_SUFFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND
${Python3_EXECUTABLE} -c "if True:
import os
import PySide2.QtCore as QtCore
print(';'.join(map(str, QtCore.__version_info__)))
"
OUTPUT_VARIABLE PYSIDE2_SO_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
list(GET PYSIDE2_SO_VERSION 0 PYSIDE2_SO_MACRO_VERSION)
list(GET PYSIDE2_SO_VERSION 1 PYSIDE2_SO_MICRO_VERSION)
list(GET PYSIDE2_SO_VERSION 2 PYSIDE2_SO_MINOR_VERSION)
string(REPLACE ";" "." PYSIDE2_SO_VERSION "${PYSIDE2_SO_VERSION}")
if(NOT APPLE)
set(PYSIDE2_SUFFIX "${PYSIDE2_SUFFIX}.${PYSIDE2_SO_MACRO_VERSION}.${PYSIDE2_SO_MICRO_VERSION}")
else()
string(REPLACE ".so" "" PYSIDE2_SUFFIX ${PYSIDE2_SUFFIX})
set(PYSIDE2_SUFFIX "${PYSIDE2_SUFFIX}.${PYSIDE2_SO_MACRO_VERSION}.${PYSIDE2_SO_MICRO_VERSION}.dylib")
endif()
set(PYSIDE2_FOUND TRUE)
message(STATUS "PySide2 base dir: ${PYSIDE2_BASEDIR}")
message(STATUS "PySide2 suffix: ${PYSIDE2_SUFFIX}")
#PySide
#===============================================================================
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_CACHE NO_SYSTEM_ENVIRONMENT_PATH
)
# Platform specific library names
if(MSVC)
set(PYSIDE_LIBRARY_BASENAMES "pyside2.abi3.lib")
elseif(CYGWIN)
set(PYSIDE_LIBRARY_BASENAMES "")
elseif(WIN32)
set(PYSIDE_LIBRARY_BASENAMES "libpyside2.${PYSIDE2_SUFFIX}")
else()
set(PYSIDE_LIBRARY_BASENAMES "libpyside2.${PYSIDE2_SUFFIX}")
endif()
find_file(
PYSIDE_LIBRARY ${PYSIDE_LIBRARY_BASENAMES}
PATHS ${PYSIDE2_BASEDIR} ${PYSIDE_CUSTOM_PREFIX}/lib
NO_DEFAULT_PATH
)
find_path(
PYSIDE_TYPESYSTEMS typesystem_core.xml
PATHS ${PYSIDE2_BASEDIR}/typesystems ${PYSIDE_CUSTOM_PREFIX}/share/PySide2/typesystems
NO_DEFAULT_PATH
)
endif()
if(PYSIDE2_FOUND)
message(STATUS "PySide include dir: ${PYSIDE_INCLUDE_DIR}")
message(STATUS "PySide library: ${PYSIDE_LIBRARY}")
message(STATUS "PySide typesystems: ${PYSIDE_TYPESYSTEMS}")
message(STATUS "PySide2 version: ${PYSIDE2_SO_VERSION}")
# Create PySide2 target
add_library(PySide2::pyside2 SHARED IMPORTED GLOBAL)
if(MSVC)
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}
)
endif()
find_package_handle_standard_args(
PySide2
REQUIRED_VARS PYSIDE2_BASEDIR PYSIDE_INCLUDE_DIR PYSIDE_LIBRARY PYSIDE_TYPESYSTEMS
VERSION_VAR PYSIDE2_SO_VERSION
)

View File

@@ -0,0 +1,147 @@
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: BSD-3-Clause
#
# PYSIDE_BASEDIR - Top of the PySide6 installation
# PYSIDE_INCLUDE_DIR - Directories to include to use PySide6
# PYSIDE_LIBRARY - Files to link against to use PySide6
# PYSIDE_TYPESYSTEMS - Type system files that should be used by other bindings extending PySide6
#
# You can install PySide6 from Qt repository with
# pip3 install --index-url=https://download.qt.io/official_releases/QtForPython --trusted-host download.qt.io pyside6
set(PYSIDE6_FOUND FALSE)
# extract python library basename
list(GET Python3_LIBRARIES 0 PYTHON_LIBRARY_FILENAME)
get_filename_component(PYTHON_LIBRARY_FILENAME ${PYTHON_LIBRARY_FILENAME} NAME)
execute_process(
COMMAND
${Python3_EXECUTABLE} -c "if True:
import os, sys
try:
import PySide6.QtCore as QtCore
print(os.path.dirname(QtCore.__file__))
except Exception as error:
print(error, file=sys.stderr)
exit()
"
OUTPUT_VARIABLE PYSIDE6_BASEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT PYSIDE6_BASEDIR)
message(FATAL_ERROR "The PySide6 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()
if(PYSIDE6_BASEDIR)
set(PYSIDE_BASEDIR
${PYSIDE6_BASEDIR}
CACHE PATH "Top level install of PySide6" FORCE
)
execute_process(
COMMAND
${Python3_EXECUTABLE} -c "if True:
import os
import PySide6.QtCore as QtCore
print(os.path.basename(QtCore.__file__).split('.', 1)[1])
"
OUTPUT_VARIABLE PYSIDE6_SUFFIX
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND
${Python3_EXECUTABLE} -c "if True:
import os
import PySide6.QtCore as QtCore
print(';'.join(map(str, QtCore.__version_info__)))
"
OUTPUT_VARIABLE PYSIDE6_SO_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
list(GET PYSIDE6_SO_VERSION 0 PYSIDE6_SO_MACRO_VERSION)
list(GET PYSIDE6_SO_VERSION 1 PYSIDE6_SO_MICRO_VERSION)
list(GET PYSIDE6_SO_VERSION 2 PYSIDE6_SO_MINOR_VERSION)
string(REPLACE ";" "." PYSIDE6_SO_VERSION "${PYSIDE6_SO_VERSION}")
if(NOT APPLE)
set(PYSIDE6_SUFFIX "${PYSIDE6_SUFFIX}.${PYSIDE6_SO_MACRO_VERSION}.${PYSIDE6_SO_MICRO_VERSION}")
else()
string(REPLACE ".so" "" PYSIDE6_SUFFIX ${PYSIDE6_SUFFIX})
set(PYSIDE6_SUFFIX "${PYSIDE6_SUFFIX}.${PYSIDE6_SO_MACRO_VERSION}.${PYSIDE6_SO_MICRO_VERSION}.dylib")
endif()
set(PYSIDE6_FOUND TRUE)
message(STATUS "PySide6 base dir: ${PYSIDE6_BASEDIR}")
message(STATUS "PySide6 suffix: ${PYSIDE6_SUFFIX}")
endif()
if(PYSIDE6_FOUND)
#PySide
#===============================================================================
find_path(
PYSIDE_INCLUDE_DIR pyside.h
PATH_SUFFIXES PySide6
PATHS ${PYSIDE6_BASEDIR}/include ${PYSIDE_CUSTOM_PREFIX}/include
)
# Platform specific library names
if(MSVC)
set(PYSIDE_LIBRARY_BASENAMES "pyside6.abi3.lib")
elseif(CYGWIN)
set(PYSIDE_LIBRARY_BASENAMES "")
elseif(WIN32)
set(PYSIDE_LIBRARY_BASENAMES "libpyside6.${PYSIDE6_SUFFIX}")
else()
set(PYSIDE_LIBRARY_BASENAMES "libpyside6.${PYSIDE6_SUFFIX}")
endif()
find_library(
PYSIDE_LIBRARY
NAMES ${PYSIDE_LIBRARY_BASENAMES}
PATHS ${PYSIDE6_BASEDIR} ${PYSIDE_CUSTOM_PREFIX}/lib
)
find_path(
PYSIDE_TYPESYSTEMS typesystem_core.xml
PATHS ${PYSIDE6_BASEDIR}/typesystems ${PYSIDE_CUSTOM_PREFIX}/share/PySide6/typesystems
/usr/share/PySide6/typesystems
NO_DEFAULT_PATH
)
endif()
if(PYSIDE6_FOUND)
message(STATUS "PySide include dir: ${PYSIDE_INCLUDE_DIR}")
message(STATUS "PySide library: ${PYSIDE_LIBRARY}")
message(STATUS "PySide typesystems: ${PYSIDE_TYPESYSTEMS}")
message(STATUS "PySide6 version: ${PYSIDE6_SO_VERSION}")
# Create PySide6 target
add_library(PySide6::pyside6 SHARED IMPORTED GLOBAL)
if(MSVC)
set_property(TARGET PySide6::pyside6 PROPERTY IMPORTED_IMPLIB ${PYSIDE_LIBRARY})
endif()
set_property(TARGET PySide6::pyside6 PROPERTY IMPORTED_LOCATION ${PYSIDE_LIBRARY})
set_property(
TARGET PySide6::pyside6
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(
PySide6
REQUIRED_VARS PYSIDE6_BASEDIR PYSIDE_INCLUDE_DIR PYSIDE_LIBRARY PYSIDE_TYPESYSTEMS
VERSION_VAR PYSIDE6_SO_VERSION
)

View File

@@ -0,0 +1,201 @@
#
# SPDX-FileCopyrightText: 2019 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: BSD-3-Clause
#
# SHIBOKEN_INCLUDE_DIR - Directories to include to use SHIBOKEN
# SHIBOKEN_LIBRARY - Files to link against to use SHIBOKEN
# SHIBOKEN_BINARY - Executable name
# SHIBOKEN_BUILD_TYPE - Tells if Shiboken was compiled in Release or Debug mode.
# You can install Shiboken from Qt repository with
# pip3 install --index-url=https://download.qt.io/official_releases/QtForPython \
# --trusted-host download.qt.io shiboken2-generator
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(SHIBOKEN2_PRIV QUIET shiboken2)
endif()
set(SHIBOKEN_FOUND FALSE)
if(SHIBOKEN2_PRIV_FOUND)
set(SHIBOKEN_FOUND TRUE)
message(STATUS "Using shiboken found in the system!")
pkg_get_variable(SHIBOKEN_BINARY shiboken2 generator_location)
pkg_get_variable(SHIBOKEN_BASEDIR shiboken2 libdir)
pkg_get_variable(SHIBOKEN_INCLUDE_DIR shiboken2 includedir)
set(SHIBOKEN_VERSION ${SHIBOKEN2_PRIV_VERSION})
set(SHIBOKEN_LIBRARY ${SHIBOKEN2_PRIV_LINK_LIBRARIES})
else()
execute_process(
COMMAND
${Python3_EXECUTABLE} -c "if True:
import os
try:
import shiboken2_generator
print(shiboken2_generator.__path__[0])
except:
exit()
"
OUTPUT_VARIABLE SHIBOKEN_GENERATOR_BASEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT SHIBOKEN_GENERATOR_BASEDIR)
message(FATAL_ERROR "The shiboken2_generator 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()
execute_process(
COMMAND
${Python3_EXECUTABLE} -c "if True:
import os
try:
import shiboken2
print(shiboken2.__path__[0])
except:
exit()
"
OUTPUT_VARIABLE SHIBOKEN_BASEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT SHIBOKEN_BASEDIR)
message(FATAL_ERROR "The shiboken2 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()
execute_process(
COMMAND
${Python3_EXECUTABLE} -c "if True:
import os
import shiboken2
print(';'.join(filter(None, map(str, shiboken2.__version_info__))))
"
OUTPUT_VARIABLE SHIBOKEN_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
list(GET SHIBOKEN_VERSION 0 SHIBOKEN_MACRO_VERSION)
list(GET SHIBOKEN_VERSION 1 SHIBOKEN_MICRO_VERSION)
list(GET SHIBOKEN_VERSION 2 SHIBOKEN_MINOR_VERSION)
string(REPLACE ";" "." SHIBOKEN_VERSION "${SHIBOKEN_VERSION}")
if(SHIBOKEN_CUSTOM_PREFIX STREQUAL "")
set(SHIBOKEN_CUSTOM_PREFIX ${SHIBOKEN_GENERATOR_BASEDIR})
endif()
message(STATUS "ShibokenGenerator base dir: ${SHIBOKEN_GENERATOR_BASEDIR}")
message(STATUS "Shiboken base dir: ${SHIBOKEN_BASEDIR}")
message(STATUS "Shiboken custom path: ${SHIBOKEN_CUSTOM_PREFIX}")
if(SHIBOKEN_BASEDIR)
find_path(
SHIBOKEN_INCLUDE_DIR shiboken.h
PATHS ${SHIBOKEN_CUSTOM_PREFIX} ${SHIBOKEN_GENERATOR_BASEDIR}/include
NO_DEFAULT_PATH NO_CACHE NO_SYSTEM_ENVIRONMENT_PATH
)
if(MSVC)
set(SHIBOKEN_LIBRARY_BASENAMES "shiboken2.abi3.lib")
elseif(CYGWIN)
set(SHIBOKEN_LIBRARY_BASENAMES "")
elseif(WIN32)
set(SHIBOKEN_LIBRARY_BASENAMES "libshiboken2.${PYSIDE2_SUFFIX}")
elseif(APPLE)
set(SHIBOKEN_LIBRARY_BASENAMES
libshiboken2.abi3.dylib libshiboken2.abi3.${SHIBOKEN_MACRO_VERSION}.dylib
libshiboken2.abi3.${SHIBOKEN_MACRO_VERSION}.${SHIBOKEN_MICRO_VERSION}.dylib
libshiboken2.abi3.${SHIBOKEN_VERSION}.dylib
)
else()
set(SHIBOKEN_LIBRARY_BASENAMES
libshiboken2.abi3.so libshiboken2.abi3.so.${SHIBOKEN_MACRO_VERSION}
libshiboken2.abi3.so.${SHIBOKEN_MACRO_VERSION}.${SHIBOKEN_MICRO_VERSION}
libshiboken2.abi3.so.${SHIBOKEN_VERSION}
)
endif()
if(NOT SHIBOKEN_INCLUDE_DIR)
return()
endif()
set(SHIBOKEN_SEARCH_PATHS ${SHIBOKEN_CUSTOM_PREFIX})
list(APPEND SHIBOKEN_SEARCH_PATHS ${SHIBOKEN_BASEDIR})
list(APPEND SHIBOKEN_SEARCH_PATHS ${SHIBOKEN_GENERATOR_BASEDIR})
find_file(
SHIBOKEN_LIBRARY ${SHIBOKEN_LIBRARY_BASENAMES}
PATHS ${SHIBOKEN_SEARCH_PATHS}
NO_DEFAULT_PATH
)
find_program(
SHIBOKEN_BINARY shiboken2
PATHS ${SHIBOKEN_SEARCH_PATHS}
NO_DEFAULT_PATH
)
endif()
if(SHIBOKEN_INCLUDE_DIR
AND SHIBOKEN_LIBRARY
AND SHIBOKEN_BINARY
)
set(SHIBOKEN_FOUND TRUE)
endif()
if(SHIBOKEN_FOUND)
endif()
if(MSVC)
# On Windows we must link to python3.dll that is a small library that links against python3x.dll
# that allow us to choose any python3x.dll at runtime
execute_process(
COMMAND
${Python3_EXECUTABLE} -c "if True:
for lib in '${Python3_LIBRARIES}'.split(';'):
if '/' in lib:
prefix, py = lib.rsplit('/', 1)
if py.startswith('python3'):
print(prefix + '/python3.lib')
break
"
OUTPUT_VARIABLE PYTHON_LIMITED_LIBRARIES
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else()
# On Linux and MacOs our modules should not link with any python library
# that must be handled by the main process
set(PYTHON_LIMITED_LIBRARIES "")
endif()
endif()
if(SHIBOKEN_FOUND)
message(STATUS "Shiboken include dir: ${SHIBOKEN_INCLUDE_DIR}")
message(STATUS "Shiboken library: ${SHIBOKEN_LIBRARY}")
message(STATUS "Shiboken binary: ${SHIBOKEN_BINARY}")
message(STATUS "Shiboken version: ${SHIBOKEN_VERSION}")
# Create shiboke2 target
add_library(Shiboken2::libshiboken SHARED IMPORTED GLOBAL)
if(MSVC)
set_property(TARGET Shiboken2::libshiboken PROPERTY IMPORTED_IMPLIB ${SHIBOKEN_LIBRARY})
endif()
set_property(TARGET Shiboken2::libshiboken PROPERTY IMPORTED_LOCATION ${SHIBOKEN_LIBRARY})
set_property(
TARGET Shiboken2::libshiboken
APPEND
PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${SHIBOKEN_INCLUDE_DIR} ${Python3_INCLUDE_DIRS}
)
set_property(
TARGET Shiboken2::libshiboken
APPEND
PROPERTY INTERFACE_LINK_LIBRARIES ${PYTHON_LIMITED_LIBRARIES}
)
# Generator target
add_executable(Shiboken2::shiboken IMPORTED GLOBAL)
set_property(TARGET Shiboken2::shiboken PROPERTY IMPORTED_LOCATION ${SHIBOKEN_BINARY})
endif()
find_package_handle_standard_args(
Shiboken2
REQUIRED_VARS SHIBOKEN_BASEDIR SHIBOKEN_INCLUDE_DIR SHIBOKEN_LIBRARY SHIBOKEN_BINARY
VERSION_VAR SHIBOKEN_VERSION
)

View File

@@ -0,0 +1,181 @@
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: BSD-3-Clause
#
# SHIBOKEN_INCLUDE_DIR - Directories to include to use SHIBOKEN
# SHIBOKEN_LIBRARY - Files to link against to use SHIBOKEN
# SHIBOKEN_BINARY - Executable name
# SHIBOKEN_BUILD_TYPE - Tells if Shiboken was compiled in Release or Debug mode.
# You can install Shiboken from Qt repository with
# pip3 install --index-url=https://download.qt.io/official_releases/QtForPython \
# --trusted-host download.qt.io shiboken6-generator
set(SHIBOKEN_FOUND FALSE)
execute_process(
COMMAND
${Python3_EXECUTABLE} -c "if True:
import os
try:
import shiboken6_generator
print(shiboken6_generator.__path__[0])
except:
exit()
"
OUTPUT_VARIABLE SHIBOKEN_GENERATOR_BASEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT SHIBOKEN_GENERATOR_BASEDIR)
message(FATAL_ERROR "The shiboken6_generator 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()
execute_process(
COMMAND
${Python3_EXECUTABLE} -c "if True:
import os
try:
import shiboken6
print(shiboken6.__path__[0])
except:
exit()
"
OUTPUT_VARIABLE SHIBOKEN_BASEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT SHIBOKEN_BASEDIR)
message(FATAL_ERROR "The shiboken6 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()
execute_process(
COMMAND
${Python3_EXECUTABLE} -c "if True:
import os
import shiboken6
print(';'.join(filter(None, map(str, shiboken6.__version_info__))))
"
OUTPUT_VARIABLE SHIBOKEN_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
list(GET SHIBOKEN_VERSION 0 SHIBOKEN_MACRO_VERSION)
list(GET SHIBOKEN_VERSION 1 SHIBOKEN_MICRO_VERSION)
list(GET SHIBOKEN_VERSION 2 SHIBOKEN_MINOR_VERSION)
string(REPLACE ";" "." SHIBOKEN_VERSION "${SHIBOKEN_VERSION}")
message(STATUS "ShibokenGenerator base dir: ${SHIBOKEN_GENERATOR_BASEDIR}")
message(STATUS "Shiboken base dir: ${SHIBOKEN_BASEDIR}")
message(STATUS "Shiboken custom path: ${SHIBOKEN_CUSTOM_PREFIX}")
if(SHIBOKEN_BASEDIR)
# Alternatively we could do find_package(Shiboken6Tools)?
find_path(
SHIBOKEN_INCLUDE_DIR shiboken.h
PATH_SUFFIXES shiboken6
PATHS ${SHIBOKEN_CUSTOM_PREFIX} ${SHIBOKEN_GENERATOR_BASEDIR}/include
)
if(MSVC)
set(SHIBOKEN_LIBRARY_BASENAMES "shiboken6.abi3.lib")
elseif(CYGWIN)
set(SHIBOKEN_LIBRARY_BASENAMES "")
elseif(WIN32)
set(SHIBOKEN_LIBRARY_BASENAMES "libshiboken6.${PYSIDE2_SUFFIX}")
elseif(APPLE)
set(SHIBOKEN_LIBRARY_BASENAMES
libshiboken6.abi3.dylib libshiboken6.abi3.${SHIBOKEN_MACRO_VERSION}.dylib
libshiboken6.abi3.${SHIBOKEN_MACRO_VERSION}.${SHIBOKEN_MICRO_VERSION}.dylib
libshiboken6.abi3.${SHIBOKEN_VERSION}.dylib
)
else()
set(SHIBOKEN_LIBRARY_BASENAMES
libshiboken6.abi3.so libshiboken6.abi3.so.${SHIBOKEN_MACRO_VERSION}
libshiboken6.abi3.so.${SHIBOKEN_MACRO_VERSION}.${SHIBOKEN_MICRO_VERSION}
libshiboken6.abi3.so.${SHIBOKEN_VERSION}
)
endif()
if(NOT SHIBOKEN_INCLUDE_DIR)
message(STATUS "No include dir found for Shiboken")
return()
endif()
set(SHIBOKEN_SEARCH_PATHS ${SHIBOKEN_CUSTOM_PREFIX})
list(APPEND SHIBOKEN_SEARCH_PATHS ${SHIBOKEN_BASEDIR})
list(APPEND SHIBOKEN_SEARCH_PATHS ${SHIBOKEN_GENERATOR_BASEDIR})
find_library(
SHIBOKEN_LIBRARY
NAMES ${SHIBOKEN_LIBRARY_BASENAMES}
PATHS ${SHIBOKEN_SEARCH_PATHS}
)
find_program(SHIBOKEN_BINARY shiboken6 PATHS ${SHIBOKEN_SEARCH_PATHS})
endif()
if(SHIBOKEN_INCLUDE_DIR
AND SHIBOKEN_LIBRARY
AND SHIBOKEN_BINARY
)
set(SHIBOKEN_FOUND TRUE)
endif()
if(SHIBOKEN_FOUND)
endif()
if(MSVC)
# On Windows we must link to python3.dll that is a small library that links against python3x.dll
# that allow us to choose any python3x.dll at runtime
execute_process(
COMMAND
${Python3_EXECUTABLE} -c "if True:
for lib in '${Python3_LIBRARIES}'.split(';'):
if '/' in lib:
prefix, py = lib.rsplit('/', 1)
if py.startswith('python3'):
print(prefix + '/python3.lib')
break
"
OUTPUT_VARIABLE PYTHON_LIMITED_LIBRARIES
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else()
# On Linux and MacOs our modules should not link with any python library
# that must be handled by the main process
set(PYTHON_LIMITED_LIBRARIES "")
endif()
if(SHIBOKEN_FOUND)
message(STATUS "Shiboken include dir: ${SHIBOKEN_INCLUDE_DIR}")
message(STATUS "Shiboken library: ${SHIBOKEN_LIBRARY}")
message(STATUS "Shiboken binary: ${SHIBOKEN_BINARY}")
message(STATUS "Shiboken version: ${SHIBOKEN_VERSION}")
# Create shiboken2 target
add_library(Shiboken6::libshiboken SHARED IMPORTED GLOBAL)
if(MSVC)
set_property(TARGET Shiboken6::libshiboken PROPERTY IMPORTED_IMPLIB ${SHIBOKEN_LIBRARY})
endif()
set_property(TARGET Shiboken6::libshiboken PROPERTY IMPORTED_LOCATION ${SHIBOKEN_LIBRARY})
set_property(
TARGET Shiboken6::libshiboken
APPEND
PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${SHIBOKEN_INCLUDE_DIR} ${Python3_INCLUDE_DIRS}
)
set_property(
TARGET Shiboken6::libshiboken
APPEND
PROPERTY INTERFACE_LINK_LIBRARIES ${PYTHON_LIMITED_LIBRARIES}
)
# Generator target
add_executable(Shiboken6::shiboken IMPORTED GLOBAL)
set_property(TARGET Shiboken6::shiboken PROPERTY IMPORTED_LOCATION ${SHIBOKEN_BINARY})
endif()
find_package_handle_standard_args(
Shiboken6
REQUIRED_VARS SHIBOKEN_BASEDIR SHIBOKEN_INCLUDE_DIR SHIBOKEN_LIBRARY SHIBOKEN_BINARY
VERSION_VAR SHIBOKEN_VERSION
)

View File

@@ -0,0 +1,36 @@
#
# SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: BSD-3-Clause
#
"""
Script to fix bugs in code generated by shiboken-generator vr2
"""
import sys
import re
def removeExtraNamespaceForDefaultEnumValue(filename):
"""
Remove namespace from default flag value
this is a shiboken2 bug fixed on shiboken6
"""
regex = re.compile(r"\s=\s[^\s]+::{}")
newContent = ""
with open(filename, encoding='utf-8') as f:
for line in f:
newContent += re.sub(regex, ' = {}', line)
with open(filename, "w", encoding='utf-8') as f:
f.write(newContent)
# Usage: <script> <list-of-files>
# It will fix the file inplace
if __name__ == '__main__':
for fileToFix in sys.argv[1:]:
print("Fixup: {}".format(fileToFix))
removeExtraNamespaceForDefaultEnumValue(fileToFix)

View File

@@ -0,0 +1,41 @@
#
# SPDX-FileCopyrightText: 2012 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
#
# SPDX-License-Identifier: BSD-3-Clause
#
# Some default installation locations. These should be global, with any project
# specific locations added to the end. These paths are all relative to the
# install prefix.
#
# These paths attempt to adhere to the FHS, and are similar to those provided
# by autotools and used in many Linux distributions.
# Use GNU install directories
include(GNUInstallDirs)
if(NOT INSTALL_RUNTIME_DIR)
set(INSTALL_RUNTIME_DIR ${CMAKE_INSTALL_BINDIR})
endif()
if(NOT INSTALL_LIBRARY_DIR)
set(INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR})
endif()
if(NOT INSTALL_ARCHIVE_DIR)
set(INSTALL_ARCHIVE_DIR ${CMAKE_INSTALL_LIBDIR})
endif()
if(NOT INSTALL_INCLUDE_DIR)
set(INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR})
endif()
if(NOT INSTALL_DATADIR)
set(INSTALL_DATADIR ${CMAKE_INSTALL_DATADIR})
endif()
if(NOT INSTALL_DOC_DIR)
set(INSTALL_DOC_DIR ${CMAKE_INSTALL_DOCDIR}${${PROJECT_NAME}_LIBRARY_QTID})
endif()
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
else()
set(CMAKE_INSTALL_RPATH "$ORIGIN/../${INSTALL_LIBRARY_DIR}")
endif()

View File

@@ -0,0 +1,173 @@
#
# SPDX-FileCopyrightText: 2019 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: BSD-3-Clause
#
# Save path to this cmake file (so it can be used later in the macros)
set(THIS_CMAKE_LIST_DIR ${CMAKE_CURRENT_LIST_DIR})
if(NOT ${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX)
# cmake-lint: disable=C0103
set(${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX
${CMAKE_INSTALL_PREFIX}
CACHE FILEPATH "Custom path to install python bindings."
)
endif()
message(STATUS "PYTHON INSTALL PREFIX ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}")
if(WIN32)
set(PATH_SEP "\;")
else()
set(PATH_SEP ":")
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#remove noisy compiler warnings (as the generated code is not necessarily super-warning-free)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-all -Wno-extra")
endif()
# On macOS, check if Qt is a framework build. This affects how include paths should be handled.
get_target_property(QtCore_is_framework Qt5::Core FRAMEWORK)
if(QtCore_is_framework)
# Get the path to the framework dir.
list(GET Qt5Core_INCLUDE_DIRS 0 QT_INCLUDE_DIR)
get_filename_component(QT_FRAMEWORK_INCLUDE_DIR "${QT_INCLUDE_DIR}/../" ABSOLUTE)
# QT_INCLUDE_DIR points to the QtCore.framework directory, so we need to adjust this to point
# to the actual include directory, which has include files for non-framework parts of Qt.
get_filename_component(QT_INCLUDE_DIR "${QT_INCLUDE_DIR}/../../include" ABSOLUTE)
endif()
# Flags that we will pass to shiboken-generator
# --generator-set=shiboken: tells the generator that we want to use shiboken to generate code,
# a doc generator is also available
# --enable-parent-ctor-heuristic: Enable heuristics to detect parent relationship on constructors,
# this try to guess parent ownership based on the arguments of the constructors
# --enable-pyside-extensionsL: This will generate code for Qt based classes, adding extra attributes,
# like signal, slot;
# --enable-return-value-heuristic: Similar as --enable-parent-ctor-heuristic this use some logic to guess
# parent child relationship based on the returned argument
# --use-isnull-as-nb_nonzero: If a class have an isNull() const method, it will be used to compute
# the value of boolean casts.
# Example, QImage::isNull() will be used when on python side you do `if (myQImage)`
set(GENERATOR_EXTRA_FLAGS
--generator-set=shiboken
--enable-parent-ctor-heuristic
--enable-pyside-extensions
--enable-return-value-heuristic
--use-isnull-as-nb_nonzero
-std=c++${CMAKE_CXX_STANDARD}
)
# 2017-04-24 The protected hack can unfortunately not be disabled, because
# Clang does produce linker errors when we disable the hack.
# But the ugly workaround in Python is replaced by a shiboken change.
if(WIN32 OR DEFINED AVOID_PROTECTED_HACK)
set(GENERATOR_EXTRA_FLAGS ${GENERATOR_EXTRA_FLAGS} --avoid-protected-hack)
add_definitions(-DAVOID_PROTECTED_HACK)
endif()
# Replace all semicolons in a string with this platform's path separator
macro(make_path varname)
# accepts any number of path variables
string(REPLACE ";" "${PATH_SEP}" ${varname} "${ARGN}")
endmacro()
# Creates a PySide module target based on the arguments
# This will:
# 1 - Create a Cmake custom-target that call shiboken-generator passign the correct arguments
# 2 - Create a Cmake library target called "Py${libraryName}" the output name of this target
# will be changed to match PySide template
# Args:
# libraryName - The name of the output module
# typesystemPaths - A list of paths where shiboken should look for typesystem files
# includePaths - Include paths necessary to parse your class. *This is not the same as build*
# outputSource - The files that will be generated by shiboken
# targetIncludeDirs - This will be passed to target_include_directories
# targetLinkLibraries - This will be passed to targetLinkLibraries
# globalInclude - A header-file that contains all classes that will be generated
# typesystemXML - The target binding typesystem (that should be the full path)
# dependsArg - This var will be passed to add_custom_command(DEPENDS) so a new generation will be
# trigger if one of these files changes
# moduleOutputDir - Where the library file should be stored
macro(
create_python_bindings
libraryName
typesystemPaths
includePaths
outputSource
targetIncludeDirs
targetLinkLibraries
globalInclude
typesystemXML
dependsArg
moduleOutputDir
)
# Transform the path separators into something shiboken understands.
make_path(shiboken_include_dirs ${includePaths})
make_path(shiboken_typesystem_dirs ${typesystemPaths})
get_property(
raw_python_dir_include_dirs
DIRECTORY
PROPERTY INCLUDE_DIRECTORIES
)
make_path(python_dir_include_dirs ${raw_python_dir_include_dirs})
set(shiboken_include_dirs "${shiboken_include_dirs}${PATH_SEP}${python_dir_include_dirs}")
set(shiboken_framework_include_dirs_option "")
if(CMAKE_HOST_APPLE)
set(shiboken_framework_include_dirs "${QT_FRAMEWORK_INCLUDE_DIR}")
make_path(shiboken_framework_include_dirs ${shiboken_framework_include_dirs})
set(shiboken_framework_include_dirs_option "--framework-include-paths=${shiboken_framework_include_dirs}")
endif()
set_property(SOURCE ${outputSource} PROPERTY SKIP_AUTOGEN ON)
add_custom_command(
OUTPUT ${outputSource}
COMMAND
$<TARGET_PROPERTY:Shiboken2::shiboken,LOCATION> ${GENERATOR_EXTRA_FLAGS} ${globalInclude}
--include-paths=${shiboken_include_dirs} --typesystem-paths=${shiboken_typesystem_dirs}
${shiboken_framework_include_dirs_option} --output-directory=${CMAKE_CURRENT_BINARY_DIR} ${typesystemXML}
COMMAND ${Python3_EXECUTABLE} ${THIS_CMAKE_LIST_DIR}/KDFixupShiboken2.py ${outputSource}
DEPENDS ${typesystemXML} ${dependsArg}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Running generator for ${libraryName} binding..."
)
set(TARGET_NAME "Py${libraryName}")
set(MODULE_NAME "${libraryName}")
add_library(${TARGET_NAME} MODULE ${outputSource})
set_target_properties(
${TARGET_NAME}
PROPERTIES PREFIX ""
OUTPUT_NAME ${MODULE_NAME}
LIBRARY_OUTPUT_DIRECTORY ${moduleOutputDir}
)
if(APPLE)
set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "@loader_path")
elseif(NOT WIN32) #ie. linux
set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN")
endif()
if(WIN32)
set_target_properties(${TARGET_NAME} PROPERTIES SUFFIX ".pyd")
endif()
target_include_directories(${TARGET_NAME} PUBLIC ${targetIncludeDirs})
target_link_libraries(${TARGET_NAME} ${targetLinkLibraries} PySide2::pyside2 Shiboken2::libshiboken)
target_compile_definitions(${TARGET_NAME} PRIVATE Py_LIMITED_API=0x03050000)
if(APPLE)
set_property(
TARGET ${TARGET_NAME}
APPEND
PROPERTY LINK_FLAGS "-undefined dynamic_lookup"
)
endif()
install(TARGETS ${TARGET_NAME} LIBRARY DESTINATION ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX})
endmacro()

View File

@@ -0,0 +1,170 @@
#
# SPDX-FileCopyrightText: 2020 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com>
#
# SPDX-License-Identifier: BSD-3-Clause
#
if(NOT ${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX)
# cmake-lint: disable=C0103
set(${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX
${CMAKE_INSTALL_PREFIX}
CACHE FILEPATH "Custom path to install python bindings."
)
endif()
message(STATUS "PYTHON INSTALL PREFIX ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX}")
if(WIN32)
set(PATH_SEP "\;")
else()
set(PATH_SEP ":")
endif()
#Qt6 requires C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#remove noisy compiler warnings (as the generated code is not necessarily super-warning-free)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-all -Wno-extra")
endif()
# On macOS, check if Qt is a framework build. This affects how include paths should be handled.
get_target_property(QtCore_is_framework Qt6::Core FRAMEWORK)
if(QtCore_is_framework)
# Get the path to the framework dir.
list(GET Qt6Core_INCLUDE_DIRS 0 QT_INCLUDE_DIR)
get_filename_component(QT_FRAMEWORK_INCLUDE_DIR "${QT_INCLUDE_DIR}/../" ABSOLUTE)
# QT_INCLUDE_DIR points to the QtCore.framework directory, so we need to adjust this to point
# to the actual include directory, which has include files for non-framework parts of Qt.
get_filename_component(QT_INCLUDE_DIR "${QT_INCLUDE_DIR}/../../include" ABSOLUTE)
endif()
# Flags that we will pass to shiboken-generator
# --generator-set=shiboken: tells the generator that we want to use shiboken to generate code,
# a doc generator is also available
# --enable-parent-ctor-heuristic: Enable heuristics to detect parent relationship on constructors,
# this try to guess parent ownership based on the arguments of the constructors
# --enable-pyside-extensionsL: This will generate code for Qt based classes, adding extra attributes,
# like signal, slot;
# --enable-return-value-heuristic: Similar as --enable-parent-ctor-heuristic this use some logic to guess
# parent child relationship based on the returned argument
# --use-isnull-as-nb_nonzero: If a class have an isNull() const method, it will be used to compute
# the value of boolean casts.
# Example, QImage::isNull() will be used when on python side you do `if (myQImage)`
set(GENERATOR_EXTRA_FLAGS
--generator-set=shiboken
--enable-parent-ctor-heuristic
--enable-pyside-extensions
--enable-return-value-heuristic
--use-isnull-as-nb_nonzero
-std=c++${CMAKE_CXX_STANDARD}
)
# 2017-04-24 The protected hack can unfortunately not be disabled, because
# Clang does produce linker errors when we disable the hack.
# But the ugly workaround in Python is replaced by a shiboken change.
if(WIN32 OR DEFINED AVOID_PROTECTED_HACK)
set(GENERATOR_EXTRA_FLAGS ${GENERATOR_EXTRA_FLAGS} --avoid-protected-hack)
add_definitions(-DAVOID_PROTECTED_HACK)
endif()
# Replace all semicolons in a string with this platform's path separator
macro(make_path varname)
# accepts any number of path variables
string(REPLACE ";" "${PATH_SEP}" ${varname} "${ARGN}")
endmacro()
# Creates a PySide module target based on the arguments
# This will:
# 1 - Create a Cmake custom-target that call shiboken-generator passign the correct arguments
# 2 - Create a Cmake library target called "Py${libraryName}" the output name of this target
# will be changed to match PySide template
# Args:
# libraryName - The name of the output module
# typesystemPaths - A list of paths where shiboken should look for typesystem files
# includePaths - Include paths necessary to parse your class. *This is not the same as build*
# outputSource - The files that will be generated by shiboken
# targetIncludeDirs - This will be passed to target_include_directories
# targetLinkLibraries - This will be passed to targetLinkLibraries
# globalInclude - A header-file that contains all classes that will be generated
# typesystemXML - The target binding typesystem (that should be the full path)
# dependsArg - This var will be passed to add_custom_command(DEPENDS) so a new generation will be
# trigger if one of these files changes
# moduleOutputDir - Where the library file should be stored
macro(
create_python_bindings
libraryName
typesystemPaths
includePaths
outputSource
targetIncludeDirs
targetLinkLibraries
globalInclude
typesystemXML
dependsArg
moduleOutputDir
)
# Transform the path separators into something shiboken understands.
make_path(shiboken_include_dirs ${includePaths})
make_path(shiboken_typesystem_dirs ${typesystemPaths})
get_property(
raw_python_dir_include_dirs
DIRECTORY
PROPERTY INCLUDE_DIRECTORIES
)
make_path(python_dir_include_dirs ${raw_python_dir_include_dirs})
set(shiboken_framework_include_dirs_option "")
if(CMAKE_HOST_APPLE)
# We need to pass "-iframework /path/to/Qt/<version>/macos/lib/" to shiboken
set(shiboken_framework_include_dirs "${QT_FRAMEWORK_INCLUDE_DIR}/..")
make_path(shiboken_framework_include_dirs ${shiboken_framework_include_dirs})
set(shiboken_framework_include_dirs_option "--framework-include-paths=${shiboken_framework_include_dirs}")
endif()
set_property(SOURCE ${outputSource} PROPERTY SKIP_AUTOGEN ON)
add_custom_command(
OUTPUT ${outputSource}
COMMAND
$<TARGET_PROPERTY:Shiboken6::shiboken,LOCATION> ${GENERATOR_EXTRA_FLAGS} ${globalInclude}
--include-paths=${shiboken_include_dirs} --typesystem-paths=${shiboken_typesystem_dirs}
${shiboken_framework_include_dirs_option} --output-directory=${CMAKE_CURRENT_BINARY_DIR} ${typesystemXML}
DEPENDS ${typesystemXML} ${dependsArg}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Running generator for ${libraryName} binding..."
)
set(TARGET_NAME "Py${libraryName}")
set(MODULE_NAME "${libraryName}")
add_library(${TARGET_NAME} MODULE ${outputSource})
set_target_properties(
${TARGET_NAME}
PROPERTIES PREFIX ""
OUTPUT_NAME ${MODULE_NAME}
LIBRARY_OUTPUT_DIRECTORY ${moduleOutputDir}
)
if(APPLE)
set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "@loader_path")
elseif(NOT WIN32) #ie. linux
set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN")
endif()
if(WIN32)
set_target_properties(${TARGET_NAME} PROPERTIES SUFFIX ".pyd")
endif()
target_include_directories(${TARGET_NAME} PUBLIC ${targetIncludeDirs})
target_link_libraries(${TARGET_NAME} ${targetLinkLibraries} PySide6::pyside6 Shiboken6::libshiboken)
target_compile_definitions(${TARGET_NAME} PRIVATE Py_LIMITED_API=0x03050000)
if(APPLE)
set_property(
TARGET ${TARGET_NAME}
APPEND
PROPERTY LINK_FLAGS "-undefined dynamic_lookup"
)
endif()
install(TARGETS ${TARGET_NAME} LIBRARY DESTINATION ${${PROJECT_NAME}_PYTHON_BINDINGS_INSTALL_PREFIX})
endmacro()

View File

@@ -0,0 +1,58 @@
#
# SPDX-FileCopyrightText: 2016 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
# Author: Allen Winter <allen.winter@kdab.com>
#
# SPDX-License-Identifier: BSD-3-Clause
#
# Assumes you've already found Qt and QT_VERSION_MAJOR is set
#
# Create variables for all the various install paths for the Qt version in use
# Make sure to have found Qt before using this.
# sets variables like QT_INSTALL_PREFIX, QT_INSTALL_DATA, QT_INSTALL_DOCS, etc.
# run qmake -query to see a full list
if(NOT DEFINED QT_VERSION_MAJOR)
message(FATAL_ERROR "Please set QT_VERSION_MAJOR first (ie. set(QT_VERSION_MAJOR 5))")
endif()
# use qtpaths if qmake not found
if(TARGET Qt${QT_VERSION_MAJOR}::qmake)
get_target_property(QT_QMAKE_EXECUTABLE Qt${QT_VERSION_MAJOR}::qmake LOCATION)
elseif(TARGET Qt${QT_VERSION_MAJOR}::qtpaths)
get_target_property(QT_QMAKE_EXECUTABLE Qt${QT_VERSION_MAJOR}::qtpaths LOCATION)
else()
message(FATAL_ERROR "No supported Qt version found. Make sure you find Qt before calling this")
endif()
execute_process(
COMMAND ${QT_QMAKE_EXECUTABLE} -query
RESULT_VARIABLE return_code
OUTPUT_VARIABLE ALL_VARS
)
if(NOT return_code EQUAL 0)
message(WARNING "Failed call: ${QT_QMAKE_EXECUTABLE} -query")
message(FATAL_ERROR "QMake call failed: ${return_code}")
endif()
string(REPLACE "\n" ";" VARS_LIST ${ALL_VARS})
foreach(qval ${VARS_LIST})
if(qval MATCHES "QT_INSTALL_")
string(REPLACE ":" ";" QVAL_LIST ${qval})
list(LENGTH QVAL_LIST listlen)
list(GET QVAL_LIST 0 var)
if(WIN32 AND ${listlen} GREATER 2)
list(GET QVAL_LIST 2 path)
list(GET QVAL_LIST 1 drive)
set(path "${drive}:${path}")
else()
list(GET QVAL_LIST 1 path)
endif()
if(NOT ${var}) #if set already on the command line for example
set(${var}
${path}
CACHE PATH "Qt install path for ${var}"
)
endif()
endif()
endforeach()