Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt 6 and CMake platform dependent code not working. Why?
Qt 6.11 is out! See what's new in the release blog

Qt 6 and CMake platform dependent code not working. Why?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 293 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bogong
    wrote on last edited by
    #1

    Hello!

    Does anyone know about Qt 6 platform dependant code and how it need to be done now? Got strange problem with Qt 6 and CMake when trying to implement different pice of code for each of platform:

    #if defined(Q_OS_MAC)
    	pHandler = qobject_cast<AStoreKitNativeHandlerInterface*>(
    		new AStoreKitIOSNativeHandler(this)
    	);
    #elif defined(Q_OS_ANDROID)
    	pHandler = qobject_cast<AStoreKitNativeHandlerInterface*>(
    		new AStoreKitAndroidNativeHandler(this)
    	);
    #elif defined(Q_OS_ANDROID)
    	pHandler = qobject_cast<AStoreKitNativeHandlerInterface*>(
    		new AStoreKitMacOSNativeHandler(this)
    	);
    #endif
    

    and

    // iOS includes
    #if defined(Q_OS_IOS)
    #include <astorekitiosnativehandler.h>
    #endif
    
    // Android includes
    #if defined(Q_OS_ANDROID)
    #include <astorekitandroidnativehandler.h>
    #endif
    
    // MacOS includes
    #if defined(Q_OS_MAC)
    #include <astorekitmacosnativehandler.h>
    #endif
    

    When compiling, don't see Q_OS_IOS and Q_OS_ANDROID. Working only Q_OS_MAC. The same code with QMake and *.pro files working perfectly. Is there any changes for Qt 6 and CMake? Or it's next one bug?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      I don't see what this should have to do with qmake or cmake - those defines come from Qt (exactly: qsystemdetection.h, automatically included by qglobal.h) so make sure qglobal.h is included before you use those macros.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved