CMake creates Microsoft Visual Studio projects with incorrect settings

• Apr 6, 2020 - 20:40
Reported version
3.x-dev
Type
Development
Frequency
Once
Severity
S4 - Minor
Reproducibility
Always
Status
closed
Regression
No
Workaround
Yes
Project

The CMakeLists.txt CMake configuration file for MuseScore currently applies the following default settings to generated Microsoft Visual Studio projects:

  1. Force the install and package targets not to depend on the all target.

  2. 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:

  1. Set Debugging | Command to the full path of the built executable installed by the INSTALL project.

  2. 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.

  3. 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

Status PR created fixed

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:

  1. Force the “install” and “package” targets not to depend on the “all” target.

  2. 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:

  1. Set “Debugging” | “Command” to the full path of the built executable installed by the “INSTALL” project.

  2. 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.)

  3. 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_

Fix version
3.5.0