Qt/AUTOMOC cross-compile problems
I'm experiencing problems when attempting to cross-compile a CMake-based Qt 5.12 project that relies on AUTOMOC.
Development platform: Windows 10, Android NDK 18 with clang 7.0.2, CMake 3.12.1. Target platform: Android 21 on 64bit ARM (aarch64)
Observed MOC problems:
- The
--target=aarch64-none-linux-android21
flag is forwarded to all C++ compilation, but does not propagate to moc.exe during AUTOMOC. This causes moc to believe that it's targeting Windows instead of Android. - An extra
-DWIN32
is instead added to the moc.exe arguments. This appear to be a bug, since I'm targeting Android. Might be caused by https://github.com/Kitware/CMake/blob/master/Source/cmQtAutoGeneratorMocUic.cxx#L1288
Steps to reproduce (on Windows):
- Clone the https://github.com/jasondegraw/Qt-CMake-HelloWorld repo , then apply the changes from https://github.com/jasondegraw/Qt-CMake-HelloWorld/pull/2
- Open a command window in the cloned folder. There, run the following commands: (adjust Qt and NDK paths first to fit local installation)
set ANDROID_NDK_ROOT=C:\Android\sdk\ndk-bundle
set QT5_ROOT=C:/Qt/5.12.0/android_arm64_v8a
set PATH="C:\Program Files\CMake\bin";%ANDROID_NDK_ROOT%\prebuilt\windows-x86_64\bin
set CMAKE_ARGS=-DCMAKE_TOOLCHAIN_FILE=%ANDROID_NDK_ROOT%\build\cmake\android.toolchain.cmake -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=%ANDROID_NDK_ROOT%/prebuilt/windows-x86_64/bin/make.exe -DANDROID_ABI=arm64-v8a -DANDROID_STL=c++_shared
cmake -DCMAKE_BUILD_TYPE=debug %CMAKE_ARGS% -DCMAKE_FIND_ROOT_PATH=%QT5_ROOT% .
make VERBOSE=1
- Observe that
--target=aarch64-none-linux-android21
is missing from MOC calls. Instead,-DWIN32
is incorrectly added to the arguments. - Observe that the generated
helloworld_autogen\moc_predefs.h
file contains defines ofWIN32
and_WIN32
.
Edited by Fredrik Orderud