Add examples to `SDL.sln`
Description
Each C example from the examples/ directory is added as a Visual C++ project to SDL.sln, making it easy to test and see the examples on Windows. The projects include the .c file and README.txt. To avoid code duplication in .vcxproj files, common code is moved to Directory.Build.props.
The project files can be automatically generated with the provided generate.py python file, but they still need to be manually added to the appropriate place in the VS solution (using Add existing project).
The initial project files were made with JetBrains Rider and not Visual Studio, but they do work in VS. There might be slight differences if you compare with the test projects.
Existing Issue(s)
- Resolves #11207
This seems reasonable to me, @icculus?
I'm curious whether the examples rebuild when switching between Configuration (Release|Debug)and Platform (Win32|x64).
It does rebuild, both the example and the main SDL project.
For some reason, the examples don't work when I build Win32. Runtime error about SDL3.dll missing. The tests work fine /shrug.
This looks fine to me as a first version.
Our vcxproj projects contain a lot of repeated code. Perhaps we should add all common code in a shared .props.
I did such a thing in https://github.com/libsdl-org/SDL/pull/7257 (for the wrong reason).
The only thing we lose with such change is easy modification of target options in the Visual Studio IDE.
I'm not against this, but we're absolutely going to forget to add new programs over time.
I'm not against this, but we're absolutely going to forget to add new programs over time.
Probably best to add a comment to CMakeLists.txt, since new additions are likely to modify that file. (Could you please add it if you wish, I'm not familiar with the comment syntax there.)
Can you add text here to describe the process of adding a new examples project? We can add it to CMakeLists.txt after this is merged.
Sure, here it is:
- Add a new example in
examples/ - Run
python VisualC/examples/generate.py- Take note of the newly generated
.vcxprojfiles
- Take note of the newly generated
- Modify the
.vcxprojfiles if necessary (adding content such as BMP or WAV files) - Open
VisualC/SDL.slnin Visual Studio or JetBrains Rider - Locate the appropriate folder in the Solution Explorer
- Add the newly generated projects: Right click → Add → Existing project...
- Test if they work
- Save the
SDL.slnsolution
Merged, thanks!
This is causing Visual Studio warnings:
C:\projects\SDL-experimental\VisualC\examples\audio\03-load-wav\03-load-wav.vcxproj : warning : Wildcards and/or some other MSBuild constructs used in project item definitions are not supported in VC projects. They can lead to unexpected behavior, instability or performance degradation in the Visual Studio IDE. Please refer to https://aka.ms/cpp/projectwildcards for supported options.
Can you have generate.py expand the wildcards?
If you mean glob-like expansion: glob.glob