If a user:
- targets Android
- sets cmake_minimum_required(3.29) in their project which implies
policy CMP0155 being set to NEW
- sets CMAKE_CXX_STANDARD >= 20
- uses Qt Creator's maintenance tool provider
- uses Qt Creator's default of ANDROID_USE_LEGACY_TOOLCHAIN_FILE=OFF
then they will hit an issue where the Threads package cannot be found
due to a CMake bug that causes all try_compile calls to fail, which
in turns causes the Qt6 package not being found.
Android and ANDROID_USE_LEGACY_TOOLCHAIN_FILE being OFF is relevant,
because in that case CMake fails to find the
CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS tool, which is used during
try_compile builds.
CMP0155 set to NEW and CMAKE_CXX_STANDARD >= 20 is relevant,
because only in that case will CMake try to use the scan deps tool to
scan for modules during try_compile builds.
The maintenance tool provider is relevant in this case, because CMake
records the CMP0155 policy value at function definition time.
Normally without a dependency provider, the policy value at Threads
package lookup time would be OLD because each Qt6Config.cmake file
has a cmake_minimum_required(3.16..3.21) call which overrides any
other policy value.
But because the dependency provider function is defined before any of
Qt's code is loaded, it inherits the CMP0155 NEW from
cmake_minimum_required(3.29) of the user's project. That causes
all find_package lookups to use CMP0155=NEW, ignoring Qt's request.
This works by design from CMake's PoV, but causes unfortunate fallout
in this case.
Because we can't influence the recorded policy value of the provided
function from the outside in any way, the only thing we can do is
disable module scanning via CMAKE_CXX_SCAN_FOR_MODULES.
Work around the issue by setting CMAKE_CXX_SCAN_FOR_MODULES to OFF
inside Qt6Config.cmake, which will set it in the directory scope of
the find_package(Qt6) caller, affecting all try_compile calls there.
Do it only in the specific conditions mentioned above.
Allow opting out of the variable assignment by configuring with
-DQT_NO_SET_CMAKE_CXX_SCAN_FOR_MODULES_TO_OFF=ON
Doing this in Qt6Config.cmake allows working around the issue when
using older Creator versions that don't work around it themselves,
See https://gitlab.kitware.com/cmake/cmake/-/issues/27169
Pick-to: 6.8 6.9 6.10
Fixes: QTBUG-139439
Change-Id: Id171c88566c41b65b24c2f2a3874e3f3c0abc814
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
One can now run "ninja android_docs" to generate HTML docs for Android
Java sources of Qt. This is done with javadoc.
One can now run "ninja android_source_jars" to generate source jars for
Android. They're supposed to be loaded into an IDE.
The targets are enabled automatically for Android builds.
For non-Android builds, set QT_BUILD_HOST_JAVA_DOCS=ON to create those
targets. In that case you must also set ANDROID_SDK_ROOT.
Fixes: QTBUG-117028
Change-Id: I2df51153359a95870c055d3ee373b8381f10cb51
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io>
The function is used in semi-public API and should in
QtPublicAndroidHelpers.cmake.
Amends de40931eba
Pick-to: 6.9
Change-Id: I3946ecb091584ac5406b3eb4d2024210398f26a3
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Function generalize the detecting of the latest available Android
platform in the ANDROID_SDK_ROOT directory.
Change-Id: Ib1d064428c414625f24765b50cff500a0ad5d27e
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>