I have a qmake batch file which uses a .pri and .pro to create a visual studio C++ project which is used to create a dll. But I would like to setup the properties of this project automatically, particularly the debugging command and command line arguments is this possible in qmake?
It is possible, create a
add_qt_path.pri
file somewhere with the following contents:
# test if windows
win32 {
# test if already exists
VCXPROJ_USER_FILE = "$${OUT_PWD}/$${TARGET}.vcxproj.user"
!exists( $${VCXPROJ_USER_FILE}) {
# generate file contents
TEMPNAME = $${QMAKE_QMAKE} # contains full dir of qmake used
QTDIR = $$dirname(TEMPNAME) # gets only the path
# vcxproj.user template
VCXPROJ_USER = "<?xml version=\"1.0\" encoding=\"utf-8\"?>$$escape_expand(\\n)\
<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">$$escape_expand(\\n)\
<PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$$escape_expand(\\n)\
<LocalDebuggerEnvironment>PATH=$${QTDIR};%PATH%</LocalDebuggerEnvironment>$$escape_expand(\\n)\
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>$$escape_expand(\\n)\
</PropertyGroup>$$escape_expand(\\n)\
<PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$$escape_expand(\\n)\
<LocalDebuggerEnvironment>PATH=$${QTDIR};%PATH%</LocalDebuggerEnvironment>$$escape_expand(\\n)\
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>$$escape_expand(\\n)\
</PropertyGroup>$$escape_expand(\\n)\
<PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|x64'\">$$escape_expand(\\n)\
<LocalDebuggerEnvironment>PATH=$${QTDIR};%PATH%</LocalDebuggerEnvironment>$$escape_expand(\\n)\
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>$$escape_expand(\\n)\
</PropertyGroup>$$escape_expand(\\n)\
<PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|x64'\">$$escape_expand(\\n)\
<LocalDebuggerEnvironment>PATH=$${QTDIR};%PATH%</LocalDebuggerEnvironment>$$escape_expand(\\n)\
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>$$escape_expand(\\n)\
</PropertyGroup>$$escape_expand(\\n)\
</Project>$$escape_expand(\\n)\
"
# write file
write_file($${VCXPROJ_USER_FILE}, VCXPROJ_USER)
}
}
then include it into your qmake project (*.pro) file, after the TARGET deifnition:
QT += core
QT -= gui
TARGET = test3
CONFIG += console
CONFIG -= app_bundle
include(./../../add_qt_path.pri) # add qt path to vs project
# other qmake stuff
You can also add to the *.vcxproj.user any other entries such as debugging command and command line arguments, just take a look on how Visual Studio auto generates the in the *.vcxproj.user file when you set them up manually.