forked from lotia/homebrew-versions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glfw3.rb
84 lines (73 loc) · 2.61 KB
/
glfw3.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
class Glfw3 < Formula
desc "Multi-platform library for OpenGL applications"
homepage "http://www.glfw.org/"
url "https://github.com/glfw/glfw/archive/3.1.2.tar.gz"
sha256 "6ac642087682aaf7f8397761a41a99042b2c656498217a1c63ba9706d1eef122"
bottle do
cellar :any
sha256 "c3f721491e4a3f07c1493f4fa2f90569df29d07b0e40c66ad74b7e5733030494" => :el_capitan
sha256 "8dfe6bdaa7e9d51c231dc2253ff058e1bf1414ca7d886962604fd9769e55bd9d" => :yosemite
sha256 "8913519230f28552e88591460316a97dd8f942bdb552de5ca7e2a68702b9e045" => :mavericks
end
option :universal
option "without-shared-library", "Build static library only (defaults to building dylib only)"
option "with-examples", "Build examples"
option "with-tests", "Build test programs"
depends_on "cmake" => :build
deprecated_option "build-examples" => "with-examples"
deprecated_option "static" => "without-shared-library"
deprecated_option "build-tests" => "with-tests"
# make library name consistent
patch :DATA
def install
ENV.universal_binary if build.universal?
args = std_cmake_args + %W[
-DGLFW_USE_CHDIR=TRUE
-DGLFW_USE_MENUBAR=TRUE
]
args << "-DGLFW_BUILD_UNIVERSAL=TRUE" if build.universal?
args << "-DBUILD_SHARED_LIBS=TRUE" if build.with? "shared-library"
args << "-DGLFW_BUILD_EXAMPLES=TRUE" if build.with? "examples"
args << "-DGLFW_BUILD_TESTS=TRUE" if build.with? "tests"
args << "."
system "cmake", *args
system "make", "install"
libexec.install Dir["examples/*"] if build.with? "examples"
libexec.install Dir["tests/*"] if build.with? "tests"
end
test do
(testpath/"test.c").write <<-EOS.undent
#define GLFW_INCLUDE_GLU
#include <GLFW/glfw3.h>
#include <stdlib.h>
int main()
{
if (!glfwInit())
exit(EXIT_FAILURE);
glfwTerminate();
return 0;
}
EOS
system ENV.cc, "-I#{include}", "-L#{lib}", "-lglfw3",
testpath/"test.c", "-o", "test"
system "./test"
end
end
__END__
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8f0d665..9a12f74 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -466,12 +466,7 @@ endforeach()
#--------------------------------------------------------------------
# Choose library output name
#--------------------------------------------------------------------
-if (BUILD_SHARED_LIBS AND UNIX)
- # On Unix-like systems, shared libraries can use the soname system.
- set(GLFW_LIB_NAME glfw)
-else()
- set(GLFW_LIB_NAME glfw3)
-endif()
+set(GLFW_LIB_NAME glfw3)
#--------------------------------------------------------------------
# Create generated files