QMake $${LITERAL_DOLLAR}0 not expanded to command line at compile - Qt Creator, MacOS

  • I am trying to pass $0 to the command line without success. While the qmake message function properly expands LITERAL_DOLLAR, it is not expanded on the command line at compile.

    You can see in the qmake code and compile output below that both the LITERAL_DOLLAR and proceeding 0 are omitted from the awk command.

    [QMake Code]

    MY_DIR = MyDir=/Library/mydir
    message("COMMAND awk 'NR==2 {$${LITERAL_DOLLAR}0=\"$${MY_DIR}\"} 1' myrc.sample > .myrc")
    myrcupdate.target   = .myrc
    myrcupdate.depends  = myrcupdateMessage
    myrcupdate.commands = awk \'NR==2 {$${LITERAL_DOLLAR}0=\"$${MY_DIR}\"} 1\' myrc.sample > .myrc
    myrcupdateMessage.commands = @echo Updating myrc entry $${MY_DIR}
    QMAKE_EXTRA_TARGETS += myrcupdate myrcupdateMessage
    PRE_TARGETDEPS      += .myrc

    [Compile Output]

    Project MESSAGE: COMMAND awk 'NR==2 {$0="MyDir=/Library/mydir"} 1' myrc.sample > .myrc
    Updating myrc entry MyDir=/Library/mydir
    awk: syntax error at source line 1
     context is
    	NR==2 >>>  {= <<< "MyDir=/Library/mydir"} 1
    awk: illegal statement at source line 1
    make[1]: *** [.myrc] Error 2
    make: *** [sub-MY_SUB_PROJECT-make_first-ordered] Error 2
    awk 'NR==2 {=MyDir=/Library/mydir} 1' myrc.sample > .myrc
    13:40:08: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project MY_PROJECT (kit: Desktop Qt 5.7.1 clang 64bit static)
    The kit Desktop Qt 5.7.1 clang 64bit static has configuration issues which might be the root cause for this problem.
    When executing step "Make"

    Is this qmake behaviour intentional ?

  • While I'm still not successful to expand $${LITERAL_DOLLAR}0 to the command line at compile, I did resolve the generated compile error by changing from awk to sed.

    [Work around]


    myrcupdate.commands = awk \'NR==2 {$${LITERAL_DOLLAR}0=\"$${MY_DIR}\"} 1\' myrc.sample > .myrc


    myrcupdate.commands = sed -i \'\' \'2s%.*%$${MY_DIR}%\'  .myrc

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