Specify source and build directory explicitly for multi-ABI external projects

When building Android multi-ABI application in source tree the
ExternalProject_Add call generates a ninja rule that looks as
follows:
  cd <BINARY_DIR> && cmake <CMAKE_ARGS> <SOURCE_DIR>
In general case the rule works correctly unless SOURCE_DIR contains
CMakeCache.txt. In this case the cmake call uses the existing
CMakeCache.txt as the reference and tries to reuse the build directory
of the main ABI. It leads to the inconsistency for multi-ABI builds
and rewriting CMakeCache.txt. Passing both '-B' and '-S' arguments
explicitly avoids using CMakeCache.txt from a main build/source
directory and fixes in-source multi-ABI builds.

Fixes: QTBUG-107843
Pick-to: 6.4
Change-Id: I010b47bff81052401aebe459e7893838a9b99bc1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2022-10-24 14:09:09 +02:00
parent 6d46788e43
commit 97007e1ace

View File

@ -1096,13 +1096,17 @@ function(_qt_internal_configure_android_multiabi_target target)
ExternalProject_Add("qt_internal_android_${abi}"
SOURCE_DIR "${CMAKE_SOURCE_DIR}"
BINARY_DIR "${android_abi_build_dir}"
CMAKE_ARGS
CONFIGURE_COMMAND
"${CMAKE_COMMAND}"
"-G${CMAKE_GENERATOR}"
"-DCMAKE_TOOLCHAIN_FILE=${qt_abi_toolchain_path}"
"-DQT_HOST_PATH=${QT_HOST_PATH}"
"-DQT_IS_ANDROID_MULTI_ABI_EXTERNAL_PROJECT=ON"
"-DQT_INTERNAL_ANDROID_MULTI_ABI_BINARY_DIR=${CMAKE_BINARY_DIR}"
"${config_arg}"
"${extra_cmake_args}"
"-B" "${android_abi_build_dir}"
"-S" "${CMAKE_SOURCE_DIR}"
EXCLUDE_FROM_ALL TRUE
BUILD_COMMAND "" # avoid top-level build of external project
)