Debug/Release scope issue in .pro file
-
Hello Trolls,
I want to run some commands in release build so I used the "mentioned conditions in FAQ section":https://qt-project.org/faq/answer/how_to_deal_correctly_with_project_files_that_should_generate_a_debug_and_r but unfortunately system function calls in DEBUG and RELEASE mode
How can I fix this issue?
@QT += core
QT -= gui
TARGET = dump
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG += release
CONFIG -= debug
SOURCES += main.cppwin32:CONFIG(debug, debug|release) {
error( "You can't build setup under DEBUG mode" )
} else {
!exists( ".\compiler\App\NSIS\makensis.exe" ) {
error( "Unable to find NSIS compiler!" )
} else {
system(".\compiler\App\NSIS\makensis setup.nsi")
}
}OTHER_FILES +=
setup.nsi@ -
"qmake doc":http://qt-project.org/doc/qt-5/qmake-variable-reference.html#config says that "under Windows), the project will be processed three times"
Try this condition:
@
build_pass:CONFIG(debug, debug|release) {
win32: error("You can't build setup under DEBUG mode")
}
else:build_pass {
win32 {
!exists( "test" ) {
error( "Unable to find NSIS compiler!" )
} else {
system("touch test")
}
}
}
@ -
Hi,
Do you have this problem when building with Qt Creator ?
I ask this because your are setting the build mode by hand in your pro file -
[quote author="andreyc" date="1394140726"]"qmake doc":http://qt-project.org/doc/qt-5/qmake-variable-reference.html#config says that "under Windows), the project will be processed three times"[/quote]
I tried it but unfortunately it didn'r fix my issue. I trid this .pro
@#-------------------------------------------------
Project created by QtCreator 2014-03-06T15:05:12
#-------------------------------------------------
QT += core
QT -= gui
TARGET = dump
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG += release
CONFIG -= debug
SOURCES += main.cppbuild_pass:CONFIG(debug, debug|release) {
win32: error("You can't build setup under DEBUG mode")
}
else:build_pass {
win32 {
!exists( "main.cpp" ) {
error( "Unable to find NSIS compiler!" )
} else {
system("dir")
}
}
}@the log was:
@15:08:47: Running steps for project QMakeScope...
15:08:47: Starting: "C:\Qt\Qt5.2.1\5.2.1\mingw48_32\bin\qmake.exe" E:\QMakeScope\QMakeScope.pro -r -spec win32-g++ "CONFIG+=debug" "CONFIG+=declarative_debug" "CONFIG+=qml_debug"
Volume in drive E is VBOX_Public
Volume Serial Number is 0000-0018Directory of E:\QMakeScope
03/06/2014 03:05 PM 17,982 QMakeScope.pro.user
03/06/2014 03:05 PM 132 main.cpp
03/06/2014 03:07 PM 631 QMakeScope.pro
3 File(s) 18,745 bytes
0 Dir(s) 161,306,329,088 bytes free
Volume in drive E is VBOX_Public
Volume Serial Number is 0000-0018Directory of E:\QMakeScope
03/06/2014 03:05 PM 17,982 QMakeScope.pro.user
03/06/2014 03:05 PM 132 main.cpp
03/06/2014 03:07 PM 631 QMakeScope.pro
3 File(s) 18,745 bytes
0 Dir(s) 161,306,324,992 bytes free
15:08:48: The process "C:\Qt\Qt5.2.1\5.2.1\mingw48_32\bin\qmake.exe" exited normally.
15:08:48: Starting: "C:\Qt\Qt5.2.1\Tools\mingw48_32\bin\mingw32-make.exe"
C:/Qt/Qt5.2.1/Tools/mingw48_32/bin/mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'E:/build-QMakeScope-Desktop_Qt_5_2_1_MinGW_32bit-Debug'
g++ -c -pipe -fno-keep-inline-dllexport -O2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG -DQT_NO_DEBUG -DQT_CORE_LIB -I..\QMakeScope -I"C:\Qt\Qt5.2.1\5.2.1\mingw48_32\include" -I"C:\Qt\Qt5.2.1\5.2.1\mingw48_32\include\QtCore" -I"release" -I"." -I"C:\Qt\Qt5.2.1\5.2.1\mingw48_32\mkspecs\win32-g++" -o release\main.o ..\QMakeScope\main.cpp
g++ -Wl,-s -Wl,-subsystem,console -mthreads -o release\dump.exe release/main.o -LC:\Qt\Qt5.2.1\5.2.1\mingw48_32\lib -lQt5Core
mingw32-make[1]: Leaving directory 'E:/build-QMakeScope-Desktop_Qt_5_2_1_MinGW_32bit-Debug'
15:08:49: The process "C:\Qt\Qt5.2.1\Tools\mingw48_32\bin\mingw32-make.exe" exited normally.
15:08:49: Elapsed time: 00:02.@ -
[quote author="SGaist" date="1394142048"]Hi,
Do you have this problem when building with Qt Creator ?
I ask this because your are setting the build mode by hand in your pro file[/quote]Yes indeed. I face this issue with Qt Creator 3.0.1 with Qt 5.2.1.
-
What if you remove
@
CONFIG += release
CONFIG -= debug
@from your pro file ?
-
[quote author="SGaist" date="1394145136"]What if you remove
@
CONFIG += release
CONFIG -= debug
@from your pro file ?[/quote]
It shows me:
[code]:-1: error: You can't build setup under DEBUG mode[/code]
-
If you have not resolved the issue I would suggest to create a simple test.pro file with CONFIG selection logic only.
@
build_pass:CONFIG(debug, debug|release) {
win32: error("You can't build setup under DEBUG mode")
}
else:build_pass {
win32 {
!exists( "main.cpp" ) {
error( "Unable to find NSIS compiler!" )
} else {
system("dir")
}
}
}
@then try to run qmake on this file with different CONFIG options and adjust the conditions above to fit your requirements.
@
qmake test.pro CONFIG+=debug
qmake test.pro
qmake test.pro CONFIG+=release
@ -
[quote author="andreyc" date="1394211334"]If you have not resolved the issue I would suggest to create a simple test.pro file with CONFIG selection logic only.
@
build_pass:CONFIG(debug, debug|release) {
win32: error("You can't build setup under DEBUG mode")
}
else:build_pass {
win32 {
!exists( "main.cpp" ) {
error( "Unable to find NSIS compiler!" )
} else {
system("dir")
}
}
}
@then try to run qmake on this file with different CONFIG options and adjust the conditions above to fit your requirements.
@
qmake test.pro CONFIG+=debug
qmake test.pro
qmake test.pro CONFIG+=release
@[/quote]I did that exactly but it didn't fix the issue :(
I wonder does any one face this issue before.
-
Oops this is very strange!!!
When I called ot from cmd using qmake it worked fine... Does it a bug in Qt Creator?
the output of above .pro:
@e:\QMakeScope>qmake QMakeScope.pro CONFIG+=debug
Project ERROR: You can't build setup under DEBUG modee:\QMakeScope>qmake QMakeScope.pro CONFIG+=release
Volume in drive E is VBOX_Public
Volume Serial Number is 0000-0018Directory of e:\QMakeScope
03/07/2014 11:13 AM <DIR> release
03/06/2014 03:09 PM 17,982 QMakeScope.pro.user
03/07/2014 11:13 AM 14,286 Makefile.Debug
03/07/2014 11:13 AM 14,331 Makefile.Release
03/07/2014 11:13 AM <DIR> debug
03/07/2014 11:13 AM 17,567 Makefile
03/06/2014 03:05 PM 132 main.cpp
03/07/2014 11:14 AM 633 QMakeScope.pro
6 File(s) 73,123 bytes
2 Dir(s) 158,834,917,376 bytes free
Project ERROR: You can't build setup under DEBUG modee:\QMakeScope>@