QMake errors with platform-specific sections like android: and win32:



  • Hello!
    Something strange happens in my PRO file. My PRO file contains the following workaround for compiling my app on Android:

    android : QT += androidextras
    {
        #QT += androidextras
    
        ANDROID_PACKAGE_SOURCE_DIR = $$PWD/platform/android
    
        android:DISTFILES += \
                $$ANDROID_PACKAGE_SOURCE_DIR/AndroidManifest.xml
    }
    

    QMake works fine with this, and the app compiles in both Android and Windows configurations, but I cannot figure out how curly braces work here, because the following still works in Android configuration, but produces QMake errors in Windows Desktop configuration:

    android
    {
        QT += androidextras
    
        ANDROID_PACKAGE_SOURCE_DIR = $$PWD/platform/android
    
        android:DISTFILES += \
                $$ANDROID_PACKAGE_SOURCE_DIR/AndroidManifest.xml
    }
    

    QMake error in Windows configuration is: Project ERROR: Unknown module(s) in QT: androidextras
    I get the same result if I add the colon after 'andorid'. Why the line 'QT += androidextras' is executed for Windows if there is a condition 'android:'? My QT version is 5.8. QMake version is 3.1. At least my syntax looks like described here http://doc.qt.io/qt-4.8/qmake-tutorial.html and here http://doc.qt.io/qt-4.8/qmake-advanced-usage.html.

    Finally I tried this:

    win32
    {
        message(Compiling on Win32 platform.)
    }
    
    android
    {
        message(Compiling on Android platform.)
    }
    

    and got the both messages all the time independently of the platform I compile for:
    Project MESSAGE: Compiling on Win32 platform.
    Project MESSAGE: Compiling on Android platform.



  • figured this out, it is because the brace should be on the same line like "android {"


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.