diff --git a/Formula/s/sfml@2.rb b/Formula/s/sfml@2.rb new file mode 100644 index 0000000000000..504ad190fbf10 --- /dev/null +++ b/Formula/s/sfml@2.rb @@ -0,0 +1,63 @@ +class SfmlAT2 < Formula + desc "Multi-media library with bindings for multiple languages" + homepage "https://www.sfml-dev.org/" + url "https://www.sfml-dev.org/files/SFML-2.6.2-sources.zip" + sha256 "19d6dbd9c901c74441d9888c13cb1399f614fe8993d59062a72cfbceb00fed04" + license "Zlib" + + keg_only :versioned_formula + + depends_on "cmake" => :build + depends_on "doxygen" => :build + depends_on "flac" + depends_on "freetype" + depends_on "libogg" + depends_on "libvorbis" + + on_linux do + depends_on "libx11" + depends_on "libxcursor" + depends_on "libxrandr" + depends_on "mesa" + depends_on "mesa-glu" + depends_on "openal-soft" + depends_on "systemd" + end + + def install + # Fix "fatal error: 'os/availability.h' file not found" on 10.11 and + # "error: expected function body after function declarator" on 10.12 + # Requires the CLT to be the active developer directory if Xcode is installed + ENV["SDKROOT"] = MacOS.sdk_path if OS.mac? && MacOS.version <= :high_sierra + + # Always remove the "extlibs" to avoid install_name_tool failure + # (https://github.com/Homebrew/homebrew/pull/35279) but leave the + # headers that were moved there in https://github.com/SFML/SFML/pull/795 + rm_r(Dir["extlibs/*"] - ["extlibs/headers"]) + + args = %W[ + -DCMAKE_INSTALL_RPATH=#{lib} + -DSFML_MISC_INSTALL_PREFIX=#{share}/SFML + -DSFML_INSTALL_PKGCONFIG_FILES=TRUE + -DSFML_BUILD_DOC=TRUE + ] + args << "-DSFML_USE_SYSTEM_DEPS=ON" if OS.linux? + + system "cmake", "-S", ".", "-B", "build", *std_cmake_args, *args + system "cmake", "--build", "build" + system "cmake", "--install", "build" + end + + test do + (testpath/"test.cpp").write <<~CPP + #include "Time.hpp" + int main() { + sf::Time t1 = sf::milliseconds(10); + return 0; + } + CPP + system ENV.cxx, "-I#{include}/SFML/System", testpath/"test.cpp", + "-L#{lib}", "-lsfml-system", "-o", "test" + system "./test" + end +end