// Copyright (C) 2020 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

/*!
    \page android-building.html
    \title Qt for Android - Building from Source
    \ingroup androidplatform
    \brief How to configure and build Qt for Android directly from source.
    \previouspage android-getting-started.html
    \nextpage android-building-user-projects.html

    This page describes the process of configuring and building
    \l{Qt for Android}. To download and install a pre-built Qt for Android,
    follow the instructions on the \l{Getting Started with Qt} page.

    \section1 Prerequisites

    To build Qt for Android from source please ensure all requirements
    from \l{Getting Started with Qt for Android} are met before continuing.

    \section2 Windows

    Building Qt for Android on Windows also requires the following software:

    \list
        \li MinGW 11.2 toolchain
    \endlist

    \note Qt for Android does not support building from source with Microsoft Visual C++ (MSVC).

    Install the requirements, and set the \c PATH to include the
    newly installed binaries:

    \badcode
        set MINGW_ROOT=<MINGW_ROOT_PATH>\bin
        set PATH=%MINGW_ROOT%;%PATH%
    \endcode

    To verify the installation, run:

    \badcode
        where mingw32-make.exe
    \endcode

    The command should list mingw32-make.exe under the path \e {<MINGW_ROOT>} first.

    \section1 Getting the Sources

    You can download the Qt sources from the \l {Qt Downloads} page, or follow
    the wiki guide for \l {Getting the source code}.

    \section1 Configuring

    Qt 6 allows building Qt for Android from source code using \c CMake. Qt 6 keeps
    the same configure script from Qt 5. The main difference is that Qt for Android
    is dependent on a host Qt build, which means to build Qt for Android, you
    need to build Qt for the desktop platform used as a host (for example Linux,
    \macos, or Windows).

    To configure Qt for Android, create a shadow build directory to keep the source
    directory clean:

    \badcode
    mkdir <path_to_build_dir>/build-qt
    cd <path_to_build_dir>/build-qt
    \endcode

    And then run the configure script:

    \badcode
    <path_to_qt_source>/configure -platform android-clang -prefix </path/to/install> -android-ndk $ANDROID_NDK_ROOT -android-sdk $ANDROID_SDK_ROOT -qt-host-path <path_to_host_qt_installation>
    \endcode

    \include use-ninja-note.qdocinc ninja-note

    \section2 Architectures

    Qt for Android supports the following ABIs:

    \include supported-platforms.qdocinc android

    To choose the ABI to build for, use the \e {-android-abis} feature of the
    configure script.

    \note \QtVer does not yet support being built for multiple ABIs at the same time.

    \section1 Advanced Configure Arguments

    Qt for Android contains Java code which is compiled into *.jar files with
    \e javac. To set the \e javac version for source and target, use \e -android-javac-source
    and \e -android-javac-target respectively:

    \badcode
    -android-javac-source 8 -android-javac-target 8
    \endcode

    To build Qt as a developer build instead of a prefix build, use the following
    instead of \c -prefix argument:

    \badcode
    -developer-build
    \endcode

    \l{Qt Configure Options} contains more information about the configure options.

    \section1 Building

    To build the configured Qt code, run the following command:

    \badcode
    cmake --build . --parallel
    \endcode

    \section1 Installing

    Now, to install Qt, run the following command:

    \badcode
    cmake --install .
    \endcode

    On Unix based OSes you should prefix the install command with the \c sudo command.

    If you haven't provided the \c{--prefix <install-dir>} configure option, the
    installation is placed under \c{/usr/local/Qt-<version>}.
*/
