Replace function $$find always returns nothing

OMGtechy

I have a QT project file (.pro), and would like to add some compiler specific flags.

Rather than typing out if win32-msvc2013|win32-msvc2010|... for every version of MSVC, I thought I could just search for the substring "msvc".

I did some research and found the find function, which seems perfect for the job.

To test this, I added message($$find($$QMAKESPEC, "*msvc*")) to the project file. However, it always prints blank, regardless of whether or not the $$QMAKESPEC variable contains the substring "msvc". I've also tried message($$find($$QMAKESPEC, "msvc")), message($$find($$QMAKESPEC, msvc)) and message($$find($$QMAKESPEC, *msvc*)).

I checked the value of $$QMAKESPEC with message($$QMAKESPEC), and it printed E:/Qt/5.4/msvc2013_64/mkspecs/win32-msvc2013.

How can I use the find function to check for a substring in a variable in a QT project file?

Update

Frank Osterfeld suggested using msvc { ... } in the comments, which works great! However I feel this question is still useful as $$find still isn't working as expected.


Version Info

Qt Creator 3.3.2 (opensource) Based on Qt 5.4.1 (MSVC 2010, 32 bit)

Built on Mar 4 2015 at 00:09:05

From revision 3af3fe7ad3

Simon Warta

There are qmake methods that take a string and there are methods that take a variable.

Replace $$find($$QMAKESPEC, "msvc") by $$find(QMAKESPEC, "msvc").

Testme

message("Test me")
message($$QMAKESPEC)
# MSVC
message($$find($$QMAKESPEC, "msvc"))
message($$find(QMAKESPEC, "msvc"))
# linux
message($$find($$QMAKESPEC, "linux"))
message($$find(QMAKESPEC, "linux"))
# g++ does not work because it is a regular expression
message($$find($$QMAKESPEC, "g++"))
message($$find(QMAKESPEC, "g++"))
# g\+\+ does work
message($$find($$QMAKESPEC, "g\+\+"))
message($$find(QMAKESPEC, "g\+\+"))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related