Multiple conditionals in QMake pro file
-
I have this code that copies additional folders from my build directory to the output:
copydata.commands += mkdir -p $$OUT_PWD/dir1 ; copydata.commands += mkdir -p $$OUT_PWD/dir2 ; copydata.commands += echo "Copying additional files..." ; copydata.commands += $(COPY_DIR) $$PWD/dir1/* $$OUT_PWD/dir2/ ; copydata.commands += $(COPY_DIR) $$PWD/dir1/* $$OUT_PWD/dir2/ ; first.depends = $(first) copydata export(first.depends) export(copydata.commands) QMAKE_EXTRA_TARGETS += first copydata
I only want this to run if dir1 OR dir2 don't exist OR are empty as they take time to copy on every compile. I've tried every combination of this condition (along with isEmpty) to no avail:
!exists( $$OUT_PWD/dir1 ) || !exists( $$OUT_PWD/dir2 ){
What's the proper syntax to combine conditions or is that not allowed? Just wondering what the best way to do this is ... I know I can always hack it to work by nesting these conditions or using an extra variable but it should work just with the built in isEmpty() and exists() functions. Thanks.
-
http://doc.qt.io/qt-5/qmake-language.html#scopes-and-conditions
use the pipe -
|
. -
I've tried every variation of the conditionals with the pipe operator as well.
!exists( $$OUT_PWD/dir1 ) | !exists( $$OUT_PWD/dir2 ) !exists(( $$OUT_PWD/dir1 ) | !exists( $$OUT_PWD/dir2 )) !exists(( $$OUT_PWD/dir1 ) | ( $$OUT_PWD/dir2 ))
None of these work the way it's supposed to. It will ALWAYS copy the files over. Any suggestions?
-
if(!exists( $$OUT_PWD/dir1 )|!exists( $$OUT_PWD/dir2 )) { // ... }
I got this directly from the
qmake
manual, by the way.
http://doc.qt.io/qt-5/qmake-test-function-reference.html#if-condition -
I've tried that too ... but I see what I'm doing wrong. I guess you have to manually run qmake every time you delete the folder to test it or else it won't update the condition. I just kept rebuilding it, which didn't work. Thanks. Guess one of my previous conditions would have worked for this as well.