Reputation: 1516
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?
Upvotes: 2
Views: 1500
Reputation: 982
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.
Upvotes: 4
Reputation: 116
Most of the build environment properties can be setup through qmake options (you can find them in qmake sources e.g. *_objectmodel.* files ). Unfortunately, both options you need are in fact runtime options so I don't think you'll be able to set them in the .pri/.pro files. Afaik, they're not even stored in the .vcxproj file but in the .vcxproj.user file. If it was not for this then modifying qmake could have been an option, even though it wouldn't probably worth the effort.
Upvotes: 2