CMake creates Microsoft Visual Studio projects with incorrect settings
The CMakeLists.txt
CMake configuration file for MuseScore currently applies the following default settings to generated Microsoft Visual Studio projects:
-
Force the
install
andpackage
targets not to depend on theall
target. -
Set the startup project to
mscore
.
These settings are fine. However, the second setting is applied using incorrect syntax, causing the startup project to end up not getting set at all. (It's possible that this syntax used to work in previous versions of Visual Studio, but it doesn't work in either Visual Studio 2017 or Visual Studio 2019). This needs to be fixed.
Additionally, the following settings should also be applied:
-
Set Debugging | Command to the full path of the built executable installed by the
INSTALL
project. -
Set Debugging | Command Arguments to
--debug
so that MuseScore is run in debug mode while being debugged.
Note: This setting requires CMake 3.13.0 or later, so it won't work in Visual Studio 2017, which comes with CMake 3.12.x. -
Set Debugging | Working Directory to the full path of the location of the built executable installed by the
INSTALL
project.
Currently, the developer has to manually apply the above settings each and every time the Visual Studio projects are generated or regenerated by CMake. Otherwise, any attempt to debug fails with a series of very confusing error messages (e.g., “MuseScore3.exe - Entry Point Not Found: The procedure entry point ?isNCName@QXmlUtils@@SA_NAEBVQString@@@Z
could not be located in the dynamic link library C:\Qt\5.9.9\msvc2017_64\bin\Qt5XmlPatterns.dll
.”).
Fixing these problems will make it possible to start debugging MuseScore in Visual Studio immediately after building.
Finally, in the CMakeSettings.json
schema file, the buildCommandArgs
property of the x64-RelWithDebInfo
configuration is set to "-v"
. This is a setting for the Ninja generator, but the schema isn't set up for that generator. Instead, it specifies the “Visual Studio 15 2017 Win64” generator, which uses the Microsoft Build Engine (MSBuild). Consequently, building inside Visual Studio using the CMake | Build All command fails with the following error message: “error MSB1016: Specify the verbosity level.”
In Ninja, the "-v"
option is used to show all command lines while building. Since MSBuild already shows the command lines by default, the incorrect "-v"
setting should simply be removed.
Comments
PR #5905.
Fixed in branch master, commit a0a9298ca5
_Fix #303483: CMake creates Microsoft Visual Studio projects with incorrect settings
The “CMakeLists.txt” CMake configuration file for MuseScore applies the following default settings to generated Microsoft Visual Studio projects:
Force the “install” and “package” targets not to depend on the “all” target.
Set the startup project to “mscore”.
These settings are fine. However, the second setting was applied using incorrect syntax, causing the startup project to end up not getting set at all. (It's possible that this syntax used to work in previous versions of Visual Studio, but it doesn't work in either Visual Studio 2017 or Visual Studio 2019). This is now fixed.
Additionally, the following settings are now applied:
Set “Debugging” | “Command” to the full path of the built executable installed by the “INSTALL” project.
Set “Debugging” | “Command Arguments” to “--debug” so that MuseScore is run in debug mode while being debugged. (Note: This setting requires CMake 3.13.0 or later, so it won't work in Visual Studio 2017, which comes with CMake 3.12.x.)
Set “Debugging” | “Working Directory” to the full path of the location of the built executable installed by the “INSTALL” project.
Prior to this fix, the developer had to manually apply the above settings each and every time the Visual Studio projects were generated or regenerated by CMake. Otherwise, any attempt to debug failed with a series of very confusing error messages (e.g., “MuseScore3.exe - Entry Point Not Found: The procedure entry point ?isNCName@QXmlUtils@@SA_NAEBVQString@@@Z could not be located in the dynamic link library C:\Qt\5.9.9\msvc2017_64\bin\Qt5XmlPatterns.dll.”).
These problems are now fixed, making it possible to start debugging MuseScore in Visual Studio immediately after building.
Finally, in the “CMakeSettings.json” schema file, the “buildCommandArgs” property of the “x64-RelWithDebInfo” configuration was set to “-v”. This is a setting for the Ninja generator, but the schema isn't set up for that generator. Instead, it specifies the “Visual Studio 15 2017 Win64” generator, which uses the Microsoft Build Engine (MSBuild). Consequently, building inside Visual Studio using the “CMake” | “Build All” command failed with the following error message: “error MSB1016: Specify the verbosity level.”
In Ninja, the “-v” option is used to show all command lines while building. Since MSBuild already shows the command lines by default, the incorrect “-v” setting has simply been removed._
Fixed in branch master, commit a1bb651ea3
_Merge pull request #5905 from Spire42/303483-CMake-creates-VS-projects-with-incorrect-settings
Fix #303483: CMake creates Microsoft Visual Studio projects with incorrect settings_
Automatically closed -- issue fixed for 2 weeks with no activity.