glm.rb 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. class Glm < Formula
  2. desc "C++ mathematics library for graphics software"
  3. homepage "https://glm.g-truc.net/"
  4. url "https://github.com/g-truc/glm/archive/refs/tags/1.0.0.tar.gz"
  5. sha256 "e51f6c89ff33b7cfb19daafb215f293d106cd900f8d681b9b1295312ccadbd23"
  6. # GLM is licensed under The Happy Bunny License or MIT License
  7. license "MIT"
  8. head "https://github.com/g-truc/glm.git", branch: "master"
  9. livecheck do
  10. url :stable
  11. strategy :github_latest
  12. end
  13. bottle do
  14. sha256 cellar: :any, arm64_sonoma: "8d177748719b95658993ecd43fa12655701a17c90265b21f276cca23692d370e"
  15. sha256 cellar: :any, arm64_ventura: "2c98bea16ad38d1bfe8aa6c5e53c80902ab810a64ae3fc07737f7fbd68307031"
  16. sha256 cellar: :any, arm64_monterey: "0b88a03a507fc6a844fd031fec6a01ac1564b9dda9e32165c923ff74374f931d"
  17. sha256 cellar: :any, sonoma: "5bf46f03e749fc17cb2db89b6e8d00e021246806ebafcdd4ed4fc677b533bc3a"
  18. sha256 cellar: :any, ventura: "ac194c8b7d6d568639ee2a7611c06127003ac1315ac2e9a86fb53ce2ddc5536d"
  19. sha256 cellar: :any, monterey: "324b50967d56d320c4d47f4f23ac205a8f813b1b7ec16e0278df6f78d77f378c"
  20. sha256 cellar: :any_skip_relocation, x86_64_linux: "e2aa9340b302c688c807ce9d93aa1b6303e8f018e0bce74d4cd678185caa2559"
  21. end
  22. depends_on "cmake" => :build
  23. depends_on "doxygen" => :build
  24. def install
  25. args = %w[
  26. -DGLM_BUILD_TESTS=OFF
  27. -DBUILD_SHARED_LIBS=ON
  28. ]
  29. system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args
  30. system "cmake", "--build", "build"
  31. system "cmake", "--install", "build"
  32. include.install "glm"
  33. lib.install "cmake"
  34. (lib/"pkgconfig/glm.pc").write <<~EOS
  35. prefix=#{prefix}
  36. includedir=${prefix}/include
  37. Name: GLM
  38. Description: OpenGL Mathematics
  39. Version: #{version.to_s.match(/\d+\.\d+\.\d+/)}
  40. Cflags: -I${includedir}
  41. EOS
  42. cd "doc" do
  43. system "doxygen", "man.doxy"
  44. man.install "html"
  45. end
  46. doc.install Dir["doc/*"]
  47. end
  48. test do
  49. (testpath/"test.cpp").write <<~EOS
  50. #include <glm/vec2.hpp>// glm::vec2
  51. int main()
  52. {
  53. std::size_t const VertexCount = 4;
  54. std::size_t const PositionSizeF32 = VertexCount * sizeof(glm::vec2);
  55. glm::vec2 const PositionDataF32[VertexCount] =
  56. {
  57. glm::vec2(-1.0f,-1.0f),
  58. glm::vec2( 1.0f,-1.0f),
  59. glm::vec2( 1.0f, 1.0f),
  60. glm::vec2(-1.0f, 1.0f)
  61. };
  62. return 0;
  63. }
  64. EOS
  65. system ENV.cxx, "-I#{include}", testpath/"test.cpp", "-o", "test"
  66. system "./test"
  67. end
  68. end