Skip to content

Conversation

@Blargian
Copy link
Contributor

Hi @alesbe

I think we both had some trouble building on windows before. Took me a bit of time over the past few days but eventually got it to work with the latest version of visual studio. I'm opening this pull request as I made some small changes to CMakeLists.txt which helped me get things working on Windows.

List of changes:

  • running cmake -G 'Visual Studio 17 2022' generates four kinds of releases by default ("Debug", "Release", "MinSizeRel", "RelWithDebInfo") so I added some code to account for this.
  • changed the mode of find_package to CONFIG mode. This will search for SFMLConfig.cmake in the SFML_DIR.
  • added code to copy across the .dll files alongside the executable. Without this cmake runs fine, visual studio project builds fine, but when running there is an error about the dlls not being found.

I haven't yet tested on linux, was hoping you might be able to if you have some spare time.

Let me know of any issues, comments, suggestions and I can fix them up! :)

@alesbe
Copy link
Owner

alesbe commented Nov 28, 2023

Hi @Blargian,

First of all, thanks for your contribution! I made this a while ago and as you said, I had trouble building this project on Windows...

I followed the steps that you provided on your readme:

  • Download SFML for Visual C++ (17) x64
  • Created /build and generate the makefiles with cmake ..
  • Build with cmake -G 'Visual Studio 17 2022' ..

It generates everything inside /build and seems right to me, but it's supposed to generate an executable file? I don't have too much experience with CMake.

Again, thanks for the contribution! If we manage to compile this on Windows easily I will probably maintain this project actively again! :)

@alesbe alesbe added enhancement New feature or request help wanted Extra attention is needed labels Nov 28, 2023
@Blargian
Copy link
Contributor Author

Blargian commented Nov 29, 2023

@alesbe with the generator flag set to Visual Studio 17 2022 cmake will generate a visual studio project and solution files within the build directory. 'build' is maybe a little misleading as a folder name because it doesn't actually build the executable yet with that command, it makes a makefile and project for the selected tool you will use to build. From here you can open the VS solution and build the executable from there - debug / release etc. The executable gets placed into the corresponding 'Debug' or 'Release' folder under build along with the SFML dll's.

If you used another generator like Ninja then you would normally cd build and run make to get the executable. I think you can also do this with visual studio straight from the command line but I just found it easier to work within the IDE.

@alesbe
Copy link
Owner

alesbe commented Nov 29, 2023

Oh! Okay, now I understand. Sorry for the confusion.

I just compiled the project with Visual Studio, and everything works as expected!

This is awesome; thank you so much for the contribution. I didn't know how to create a proper CMakeLists file, but your contribution makes everything easier.

I'm merging this. Thanks! 🙌 ❤️

@alesbe alesbe merged commit 7c536ce into alesbe:main Nov 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants