vegastrike / Vega-Strike-Engine-Source

Vega Strike Engine
Other
260 stars 44 forks source link

Compiling under Windows - bootstrap.ps1 not compatible with Visual Studios 2019 #906

Open kheckwrecker opened 2 weeks ago

kheckwrecker commented 2 weeks ago

When compiling under Windows, using Visual Studios 2019, bootstrap.ps1 fails with:

CMake Error: Could not read presets from D:/VegaStrike-0.9.0/Vega-Strike-Engine-Source-0.9.0/engine: Unrecognized "version" field.

Apparently, this is a known issue with the version of CMake used to compile and VS 2019.

However, build.ps1 expects to find VS 2019. The work-around is to install both VS 2022 and VS 2019 and run the compile through VS 2022.

It would be nice, though, to be able to compile with one Visual Studio or the other.

royfalk commented 2 weeks ago

OK. These are actually two issues:

  1. VS2019 has a CMake error.
  2. build.ps1 expects VS2019.

For the first one, can you provide a more full error log, just in case the lines before and after are also relevant. For the second one, that should be a simple fix.

kheckwrecker commented 2 weeks ago

I need to make a correction to the issue I reported. The problem is not with bootstrap.ps1, the problem is with build.ps1. To be clear script/bootstrap.ps1 completes fine with either VS 2019 or VS2022. Sorry for the confusion, I should have kept better notes on where errors originally occurred.

Also, when running script/build.ps1 under the VS 2022 Powershell, I'm not sure build.ps1 actually "uses" VS 2019. I think the build script may fail simply because it expects to find VS 2019, and fails when it does not.

So to clarify, when you launch script/build.ps1 under VS 2019, it fails immediately with the following error:

PS D:\vs9> script/build.ps1 CMake Error: Could not read presets from D:/VS9/engine: Unrecognized "version" field CMake Error: Could not read presets from D:/VS9/engine: Unrecognized "version" field

And then returns to the command prompt. That's it - there are no other messages.

Out of curiosity, I tried editing CMakePresets.json to change the "version" number to 2. Then you get this error message:

PS D:\vs9> script/build.ps1 CMake Error: Could not read presets from D:/VS9/engine: Invalid preset CMake Error: Could not read presets from D:/VS9/engine: Invalid preset

So then I tried changing it to 1, and got this error message:

PS D:\vs9> script/build.ps1 CMake Error: Could not read presets from D:/VS9/engine: File version must be 2 or higher for build and test preset support. CMake Error: Could not read presets from D:/VS9/engine: File version must be 2 or higher for build and test preset support.

Changing it to 4 or higher just gives the same error message as if the "version" is set to 3.

So my next step was to delete VS 2019 and install VS 2022. The script/bootstrap.ps1 ran fine under VS 2022, and build under VS 2022 went much further, but then crashed reporting it could not find VS 2019.

So I installed both VS 2019 and VS 2022, ran script/bootstrap.ps1 and script/build.ps1 under the VS 2022 Powershell and was able to complete the compile.