qt5base-lts/cmake/QtJavaHelpers.cmake
Assam Boudjelthia 9826e4e38b Android: report more warnings for Jar builds
this makes it more visible in the build when introduing
or having java code that for example might be doing
something wrong. deprecation option can't be added at this
 point since we compile the java code against the max
supported version and that will always print a lot of
deprecation warnings that are valid for the max version
but not valid for the min supported version.

Task-number: QTBUG-118077
Change-Id: I7d1e9c80d5208817a342cc1d79a28f233feeda0e
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
2023-11-24 03:48:39 +02:00

31 lines
1019 B
CMake

# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
# This function can be used to compile java sources into a jar package.
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}")
if (NOT javac_target_version)
set(javac_target_version "8")
endif()
set(javac_source_version "${QT_ANDROID_JAVAC_SOURCE}")
if (NOT javac_source_version)
set(javac_source_version "8")
endif()
set(CMAKE_JAVA_COMPILE_FLAGS -source "${javac_source_version}" -target "${javac_target_version}"
-Xlint:unchecked,cast,divzero,fallthrough,overrides,path -classpath "${QT_ANDROID_JAR}")
add_jar(${ARGV})
foreach(f IN LISTS arg_SOURCES)
_qt_internal_expose_source_file_to_ide(${target} "${f}")
endforeach()
endfunction()