CMake creates Microsoft Visual Studio projects with incorrect settings
CMakeLists.txt CMake configuration file for MuseScore currently applies the following default settings to generated Microsoft Visual Studio projects:
packagetargets not to depend on the
Set the startup project to
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
Set Debugging | Command Arguments to
--debugso 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
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
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.