aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside-tools/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside-tools/cmake')
-rw-r--r--sources/pyside-tools/cmake/PySideAndroid.cmake53
-rw-r--r--sources/pyside-tools/cmake/PySideToolsHelpers.cmake37
-rw-r--r--sources/pyside-tools/cmake/PySideToolsSetup.cmake16
3 files changed, 106 insertions, 0 deletions
diff --git a/sources/pyside-tools/cmake/PySideAndroid.cmake b/sources/pyside-tools/cmake/PySideAndroid.cmake
new file mode 100644
index 000000000..d89da4f1b
--- /dev/null
+++ b/sources/pyside-tools/cmake/PySideAndroid.cmake
@@ -0,0 +1,53 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+set(QT_MAJOR_VERSION 6)
+
+# Locate Java
+include(UseJava)
+# Find JDK 8.0
+find_package(Java 1.8 COMPONENTS Development REQUIRED)
+# Find QtJavaHelpers.java
+include("${QT6_INSTALL_PREFIX}/${QT6_INSTALL_LIBS}/cmake/Qt6/QtJavaHelpers.cmake")
+
+macro(create_and_install_qt_javabindings)
+
+ # create Qt6AndroidBindings.jar from the following {java_sources}
+ set(android_main_srcs "${QT6_INSTALL_PREFIX}/src/android/java/src/org/qtproject/qt/android/bindings")
+ set(java_sources
+ ${android_main_srcs}/QtActivity.java
+ ${android_main_srcs}/QtApplication.java
+ ${android_main_srcs}/QtService.java
+ )
+ # set android.jar from the sdk, for compiling the java files into .jar
+ set(sdk_jar_location "${ANDROID_SDK_ROOT}/platforms/android-${CMAKE_ANDROID_API}/android.jar")
+ file(GLOB sources_list LIST_DIRECTORIES true "${ANDROID_SDK_ROOT}/platforms/android-${CMAKE_ANDROID_API}/*")
+ if (NOT EXISTS "${sdk_jar_location}")
+ message(FATAL_ERROR "Could not locate Android SDK jar for api '${CMAKE_ANDROID_API}' - ${sdk_jar_location}")
+ endif()
+
+ # this variable is accessed by qt_internal_add_jar
+ set(QT_ANDROID_JAR ${sdk_jar_location})
+
+ set(qt_jar_location "${QT6_INSTALL_PREFIX}/jar/Qt6Android.jar")
+ if (NOT EXISTS "${qt_jar_location}")
+ message(FATAL_ERROR "${qt_jar_location} does not exist. Qt6 installation maybe corrupted.")
+ endif()
+
+ # to be done
+ list(APPEND included_jars ${sdk_jar_location} ${qt_jar_location})
+
+ qt_internal_add_jar(Qt${QT_MAJOR_VERSION}AndroidBindings
+ INCLUDE_JARS ${included_jars}
+ SOURCES ${java_sources}
+ )
+
+ install_jar(Qt${QT_MAJOR_VERSION}AndroidBindings
+ DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/jar"
+ COMPONENT Devel
+ )
+
+ # install other relevant Android jars from the Qt installation.
+ # All the jars would be later packaged together with the Android wheels
+ install(DIRECTORY ${QT6_INSTALL_PREFIX}/jar/ DESTINATION lib/jar)
+endmacro()
diff --git a/sources/pyside-tools/cmake/PySideToolsHelpers.cmake b/sources/pyside-tools/cmake/PySideToolsHelpers.cmake
new file mode 100644
index 000000000..9fb2ec3d0
--- /dev/null
+++ b/sources/pyside-tools/cmake/PySideToolsHelpers.cmake
@@ -0,0 +1,37 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+function(pyside_tools_internal_detect_if_cross_building)
+ if(CMAKE_CROSSCOMPILING OR QFP_SHIBOKEN_HOST_PATH)
+ set(is_cross_build TRUE)
+ else()
+ set(is_cross_build FALSE)
+ endif()
+ set(PYSIDE_TOOLS_IS_CROSS_BUILD "${is_cross_build}" PARENT_SCOPE)
+ message(STATUS "PYSIDE_TOOLS_IS_CROSS_BUILD: ${PYSIDE_TOOLS_IS_CROSS_BUILD}")
+endfunction()
+
+function(pyside_tools_internal_set_up_extra_dependency_paths)
+ set(extra_root_path_vars
+ QFP_QT_TARGET_PATH
+ )
+ foreach(root_path IN LISTS extra_root_path_vars)
+ set(new_root_path_value "${${root_path}}")
+ if(new_root_path_value)
+ set(new_prefix_path "${CMAKE_PREFIX_PATH}")
+ list(PREPEND new_prefix_path "${new_root_path_value}/lib/cmake")
+ set(CMAKE_PREFIX_PATH "${new_prefix_path}")
+ set(CMAKE_PREFIX_PATH "${new_prefix_path}" PARENT_SCOPE)
+
+ # Need to adjust the prefix and root paths so that find_package(Qt) and other 3rd
+ # party packages are found successfully when they are located outside of the
+ # default sysroot (whatever that maybe for the target platform).
+ if(PYSIDE_TOOLS_IS_CROSS_BUILD)
+ set(new_root_path "${CMAKE_FIND_ROOT_PATH}")
+ list(PREPEND new_root_path "${new_root_path_value}")
+ set(CMAKE_FIND_ROOT_PATH "${new_root_path}")
+ set(CMAKE_FIND_ROOT_PATH "${new_root_path}" PARENT_SCOPE)
+ endif()
+ endif()
+ endforeach()
+endfunction()
diff --git a/sources/pyside-tools/cmake/PySideToolsSetup.cmake b/sources/pyside-tools/cmake/PySideToolsSetup.cmake
new file mode 100644
index 000000000..93b39460d
--- /dev/null
+++ b/sources/pyside-tools/cmake/PySideToolsSetup.cmake
@@ -0,0 +1,16 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
+
+include(PySideToolsHelpers)
+
+pyside_tools_internal_detect_if_cross_building()
+pyside_tools_internal_set_up_extra_dependency_paths()
+
+find_package(Qt6 REQUIRED COMPONENTS Core HostInfo)
+
+# Don't display "up-to-date / install" messages when installing, to reduce visual clutter.
+if (QUIET_BUILD)
+ set(CMAKE_INSTALL_MESSAGE NEVER)
+endif()