CMake:Android: Add jar files to a ${target}JarSources

For better integrations with Qt Creator, add a custom target with
the Jar files so they are shown under the project files. Since
source_group() is not supported, add_custom_target() is used.

Change-Id: Ie527fdce918d526ee6e8953e27d4e0f4131a9828
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit c76918eca2a964906f1c2a59886b3b6892ffe264)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Assam Boudjelthia 2023-09-08 10:43:12 +03:00 committed by Qt Cherry-pick Bot
parent eb5f183754
commit 0ef9d8a49a

View File

@ -4,6 +4,10 @@
# This function can be used to compile java sources into a jar package. # This function can be used to compile java sources into a jar package.
function(qt_internal_add_jar target) function(qt_internal_add_jar target)
set(options)
set(oneValueArgs OUTPUT_DIR)
set(multiValueArgs INCLUDE_JARS SOURCES)
cmake_parse_arguments(arg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(javac_target_version "${QT_ANDROID_JAVAC_TARGET}") set(javac_target_version "${QT_ANDROID_JAVAC_TARGET}")
if (NOT javac_target_version) if (NOT javac_target_version)
@ -18,4 +22,8 @@ function(qt_internal_add_jar target)
set(CMAKE_JAVA_COMPILE_FLAGS -source "${javac_source_version}" -target "${javac_target_version}" -Xlint:unchecked -bootclasspath "${QT_ANDROID_JAR}") set(CMAKE_JAVA_COMPILE_FLAGS -source "${javac_source_version}" -target "${javac_target_version}" -Xlint:unchecked -bootclasspath "${QT_ANDROID_JAR}")
add_jar(${ARGV}) add_jar(${ARGV})
foreach(f IN LISTS arg_SOURCES)
_qt_internal_expose_source_file_to_ide(${target} "${f}")
endforeach()
endfunction() endfunction()