Load A Qt Project To VS Solution That Has Custom Configurations
-
Hi Community,
I have Qt Visual Studio Solution that has multiple projects under it. The solution has 2 custom build configurations say customDebug and customRelease. I have a qt project that was created using qt creator and its default configurations are release and debug. I would like to add this project to my solution using the vs qt extension by selecting the pro file. On doing this its generating vcxproj and filter files for the new project. On trying to add the project using the gernerated vcxproj file. it says there is no information about the project with respect to the 2 custom build configurations.
How can i resolve this?
how can i create that custom configuration for the qt project? -
C Christian Ehrlicher moved this topic from General and Desktop on
-
@Abhi_Varma I am a huge fan of the command line tool
sed
to replace text in text files. There are package managers for Windows like Scoop (https://scoop.sh/) and Chocolatey (https://chocolatey.org/) which will help to easily installsed
on Windows (I am using Scoop; it's just two lines on the PowerShell to install).Recently I used it to set the correct PlatformToolset and WindowsTargetPlatformVersion, as our previous approach was deleting the old solution, opening the generated vcxproj-file (freshly generated with qmake), and finally manually answering Visual Studio's question about upgrading to the most recent versions (if you don't delete the solution first, the question will not appear and you'll get some incompatibilities). Also, this now enables multiprocessor compilation by default. Just in case you want to go down that route, here are the sed commands we use (for some older qmake/Qt version):
sed -i "s@<PlatformToolset>v120</PlatformToolset>@<PlatformToolset>v142</PlatformToolset>@" MyProject.vcxproj sed -i "s@<WindowsTargetPlatformVersion>10\.0\..*</WindowsTargetPlatformVersion>@<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>@" MyProject.vcxproj sed -i "s@^\(.*\)<WarningLevel>Level3</WarningLevel>@\1<WarningLevel>Level3</WarningLevel>\n\1<MultiProcessorCompilation>true</MultiProcessorCompilation>@" MyProject.vcxproj
@SimonSchroeder This looks interesting, will find some time to try it. But what I have done is create a new project under my solution with the same name as the qt project. I configured it with all necessary setting. then i copied all the contents of the project into the folder of the newly created project and right clicked and added files to the project. Once the files are loaded under the project the settings are auto applied to each file.
-
First of all, from my experience using the VS plugin for Qt does not provide the best experience. We use
qmake -tp vc MyProject.pro
on the command line instead. In any case, the .vcxproj file is just an XML file. Try opening it with a text editor and change the build configuration from Release and Debug to customRelease and customDebug. This might be the quickest solution. You could also try to create a new build configuration as a copy of the existing Release/Debug configurations directly inside VS for this project. -
First of all, from my experience using the VS plugin for Qt does not provide the best experience. We use
qmake -tp vc MyProject.pro
on the command line instead. In any case, the .vcxproj file is just an XML file. Try opening it with a text editor and change the build configuration from Release and Debug to customRelease and customDebug. This might be the quickest solution. You could also try to create a new build configuration as a copy of the existing Release/Debug configurations directly inside VS for this project.@SimonSchroeder I am aware about editing the vcxproj file. The problem I'm trying to avoid is say my project has many files under it. If I edit the vcxproj file then I have add settings for each file for both customdebug and customrelease manually. I would like to avoid this laborious task. Hence looking for a better solution.
-
@SimonSchroeder I am aware about editing the vcxproj file. The problem I'm trying to avoid is say my project has many files under it. If I edit the vcxproj file then I have add settings for each file for both customdebug and customrelease manually. I would like to avoid this laborious task. Hence looking for a better solution.
@Abhi_Varma I am a huge fan of the command line tool
sed
to replace text in text files. There are package managers for Windows like Scoop (https://scoop.sh/) and Chocolatey (https://chocolatey.org/) which will help to easily installsed
on Windows (I am using Scoop; it's just two lines on the PowerShell to install).Recently I used it to set the correct PlatformToolset and WindowsTargetPlatformVersion, as our previous approach was deleting the old solution, opening the generated vcxproj-file (freshly generated with qmake), and finally manually answering Visual Studio's question about upgrading to the most recent versions (if you don't delete the solution first, the question will not appear and you'll get some incompatibilities). Also, this now enables multiprocessor compilation by default. Just in case you want to go down that route, here are the sed commands we use (for some older qmake/Qt version):
sed -i "s@<PlatformToolset>v120</PlatformToolset>@<PlatformToolset>v142</PlatformToolset>@" MyProject.vcxproj sed -i "s@<WindowsTargetPlatformVersion>10\.0\..*</WindowsTargetPlatformVersion>@<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>@" MyProject.vcxproj sed -i "s@^\(.*\)<WarningLevel>Level3</WarningLevel>@\1<WarningLevel>Level3</WarningLevel>\n\1<MultiProcessorCompilation>true</MultiProcessorCompilation>@" MyProject.vcxproj
-
@Abhi_Varma I am a huge fan of the command line tool
sed
to replace text in text files. There are package managers for Windows like Scoop (https://scoop.sh/) and Chocolatey (https://chocolatey.org/) which will help to easily installsed
on Windows (I am using Scoop; it's just two lines on the PowerShell to install).Recently I used it to set the correct PlatformToolset and WindowsTargetPlatformVersion, as our previous approach was deleting the old solution, opening the generated vcxproj-file (freshly generated with qmake), and finally manually answering Visual Studio's question about upgrading to the most recent versions (if you don't delete the solution first, the question will not appear and you'll get some incompatibilities). Also, this now enables multiprocessor compilation by default. Just in case you want to go down that route, here are the sed commands we use (for some older qmake/Qt version):
sed -i "s@<PlatformToolset>v120</PlatformToolset>@<PlatformToolset>v142</PlatformToolset>@" MyProject.vcxproj sed -i "s@<WindowsTargetPlatformVersion>10\.0\..*</WindowsTargetPlatformVersion>@<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>@" MyProject.vcxproj sed -i "s@^\(.*\)<WarningLevel>Level3</WarningLevel>@\1<WarningLevel>Level3</WarningLevel>\n\1<MultiProcessorCompilation>true</MultiProcessorCompilation>@" MyProject.vcxproj
@SimonSchroeder This looks interesting, will find some time to try it. But what I have done is create a new project under my solution with the same name as the qt project. I configured it with all necessary setting. then i copied all the contents of the project into the folder of the newly created project and right clicked and added files to the project. Once the files are loaded under the project the settings are auto applied to each file.
-