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

QtCreator Qbs GoogleTest help needed



  • Hi,

    I was looking to use GoogleTest in my Qbs project but could not figure out the best way to do it so I used QtCreator wizard to create a GoogleTest project and see the generated qbs product. This did not solve my problem because the build system needs to be passed a path to a source version of the GoogleTest framework while I want to support system install.

    However, looking at the generated code I thought I could do something similar but encountered an issue which I do not know if it ias a bug in Qbs or QtCreator or if the generated code I base mine on is just plain wrong.

    In the product qbs file I import some JS file with helper functions:

    import "googlecommon.js" as googleCommon
    Product{
        ...
        // here I can acces qbs properties (like hostOS)
       cpp.includePaths: {
                if (qbs.hostOS.contains("linux"))
                    ....
        }
    }
    

    but in the JS file the code is not fucntional

    function somefunc() {
            // here all qbs properties(like hostOS) are undefined
            // and code looking like this do not work
            if (qbs.hostOS.contains("linux"))
                return ;
    }
    

    I am not sure how to accomplish what I want to do, which is writing helper functions in my JS file that access the qbs module properties (like hostOS) ; or if I should fill a bug report for Qbs or QtCreator (In the code generated by Qtcreator the error does not pop-up because the erroneous code is never called). Any help is appreciated.

    Thanks



  • @Xavier-Thomas You may use a work-around by passing parameters to somfunc() to resolve problem temporarily. Maybe a problem with creating context being corrupted could cause properties being undefined.


Log in to reply