Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to make qt to detect embeded device on compiling time?



  • at the moment I'm playing with a raspberry pi and I have a problem with the Qt Creator when want to run the app on my PC or on Raspberry.

    When running the program on pi I have to add

    target.path = /home/pi/atpSmartHome
    INSTALLS += target
    

    but when I have to run it on PC I have to comment out thowse lines... any way to do comething like

    embeded_PI {
             target.path = /home/pi/atpSmartHome
             INSTALLS += target
    }
    

    or anithing similar to this?

    Many thanks


  • Lifetime Qt Champion

    HI
    Im sure its possible but not sure what to check on - when compiling for the ARM

    http://stackoverflow.com/questions/24549612/qt-project-file-add-libs-depending-on-kit

    I assume you must change the kit to compile to the RB, so maybe the
    CONFIG(Desktop, Desktop|Target_ARM) xx can be used.



  • yes but I'm looking for something like

    KIT = Desktop
    #KIT = RPI
    
    And use contains function
    
    contains( KIT, Desktop ) {
         LIBS += ...
    }
    contains( KIT, RPI) {
         target.path = /home/pi/atpSmartHome
    INSTALLS += target
    }
    

    how to maker qt Creator to detect witch settings to use?


  • Lifetime Qt Champion

    @arsinte_andrei
    Ok, does this work then?
    You have to "flip" KIT when you change but I guess that is ok?


  • Lifetime Qt Champion

    @arsinte_andrei
    It wont auto detect.

    You could just check kit name maybe

    MY_QT_INSTALL_PREFIX=$$[QT_INSTALL_PREFIX]
    equals(MY_QT_INSTALL_PREFIX,"C:/Qt/5.7/mingw53_32"){
    message($$[QT_INSTALL_PREFIX])
    }

    When i change between STATIC and normal kits i can catch it this way.
    I assume you can do the same for ARM.

    To check it that can work for you

    insert
    message($$[QT_INSTALL_PREFIX])

    in the .pro file and change kits and see what it prints.
    You should then easy be able to use equals to know when
    its for ARM.

    Searching the forum it also seems that

    linux-arm-gnueabi-g++ {
    ...
    }

    also works for some platforms. So I guess it also depends on the
    mkspec actually used on your platform.



  • yes.. this is what I've been looking for
    now is working
    here you have the code

    
    MY_QT_INSTALL_PREFIX=$$[QT_INSTALL_PREFIX]
    equals(MY_QT_INSTALL_PREFIX,"/home/andrei/raspi/qt5pi"){
    message($$[QT_INSTALL_PREFIX])
    target.path = /home/pi/myApp
    INSTALLS += target
    }
    

    many thanks


Log in to reply