Important: Please read the Qt Code of Conduct -

[solved] PRO function calls

  • Hello,

    I am developing on 64bit Win7 and am trying to figure out why a
    @system(cd $$mydir)@

    call in my .pro file is not working. I have tried hard coding the path
    @system(cd C:/)@

    changing the cd call to chdir and even trying different combinations of parenthesis and still have issues. Here is my stub:

    Project created by QtCreator 2012-05-11T11:47:17


    QT += core

    QT -= gui

    TARGET = test
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += main.cpp

    system(cd C:/)

    This setup seems to work fine on Linux (with the appropriate changes to mydir and dir call). Is this a known compatibility issue? I have not found any documented forms of it...

  • Moderators

    I do not think changing directories is a good idea in qmake. What do you want to do?

  • I have some code generation scripts that need to run on compilation in another directory, normally I would readjust the way the script executes but this is a part of a much larger project and editing the script may destabilize other coder's projects. I cannot really make this a 'one-off' solution unfortunately.

  • [quote author="urgentDiplomacy" date="1336762437"]Hello,

    This setup seems to work fine on Linux (with the appropriate changes to mydir and dir call).[/quote]

    I don't know why you think this works on Linux. IMO, this should fail under any OS. As the command passed to system() will run in another process.

  • If you're not able to change the original scripts, I would write wrapper script that takes the desired directory as argument, changes directory to it and calls then calls the original script.

  • Thanks Volker and Herder for your help! I should have said that some people on my project believe that it works in linux but it doesn't for the reasons you specified Herder.

    [SOLVED] thanks to Herder.

Log in to reply