SFML / cmake-sfml-project

Repository template for SFML projects using CMake
Other
315 stars 197 forks source link

Add Nix-shell script #48

Closed Firefnix closed 2 months ago

Firefnix commented 2 months ago

Add Nix-shell script for Nix / NixOS users

Tested on NixOS unstable. The usual commands to compile with cmake work, except that I had to require the X11 lib in CMakeLists.txt by adding

find_package(X11 REQUIRED)

Feel free to add a line about this in CMakeLists.txt too, as it seems required for Linux-based systems (even those running on Wayland-based environments). I did not include anything about this in this branch as it is beyond its scope I think.

As a reminder, to activate the nix-shell (just like you would with a Python virtualenv), just do nix-shell in the project's root directory. In this shell, you can then build with

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build

as you would on any other Linux distro.

ChrisThrasher commented 2 months ago

I appreciate this PR but I think it's outside the scope of this template.

ChrisThrasher commented 2 months ago

Tested on NixOS unstable. The usual commands to compile with cmake work, except that I had to require the X11 lib in CMakeLists.txt by adding

  find_package(X11 REQUIRED)

Do you still have to do this when compiling SFML on its own in NixOS? Our build scripts have a fair bit of OS-specific branches for dealing with platform APIs like X11 and perhaps we're not properly handing the NixOS case.

eXpl0it3r commented 2 months ago

We don't want to provide OS specific build scripts. Maybe we can extend the readme for other distributions than Debian or Ubuntu for installing dependencies.

You shouldn't be needing to explicitly search for X11, unless you write X11 code in your own application. If you need to do that currently, it seems like an issue within SFML's CMake scripts, feel free to open an issue on the main repo with more details provided.