forked from ahmadia/homebrew-science
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopencascade.rb
89 lines (74 loc) · 3.46 KB
/
opencascade.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
85
86
87
88
89
class Opencascade < Formula
homepage "http://www.opencascade.org/"
url "http://files.opencascade.com/OCCT/OCC_6.8.0_release/opencascade-6.8.0.tgz"
sha1 "fe359a12e110e9136adac2db1539026be6cc579e"
bottle do
cellar :any
revision 1
sha256 "156c57d3345600ba9911dfbe9844bb36cd86e55b07669562c2010e222c411e63" => :yosemite
sha256 "b8b1ebb93e0bb650a0984ce684659ac188685ebdf0426811bd7353edd2cb1c60" => :mavericks
sha256 "47555cbfe72c5929b303becec9fb555271fc4a0887f672f04370eede0b4ebeeb" => :mountain_lion
end
conflicts_with "oce", :because => "OCE is a fork for patches/improvements/experiments over OpenCascade"
option "without-opencl", "Build without OpenCL support"
option "without-extras", "Don't install documentation (~725MB) or samples (~40MB)"
option "with-tests", "Install tests (~55MB)"
depends_on "cmake" => :build
depends_on "freetype"
depends_on "qt"
depends_on "freeimage" => :recommended
depends_on "gl2ps" => :recommended
depends_on "tbb" => :recommended
depends_on :macos => :snow_leopard
def install
# setting DYLD causes many issues; all tests work fine without; suppress
inreplace "env.sh", "export DYLD_LIBRARY_PATH", "export OCCT_DYLD_LIBRARY_PATH"
cmake_args = std_cmake_args
cmake_args << "-DCMAKE_PREFIX_PATH:PATH=#{HOMEBREW_PREFIX}"
cmake_args << "-DCMAKE_INCLUDE_PATH:PATH=#{HOMEBREW_PREFIX}/lib"
cmake_args << "-DCMAKE_FRAMEWORK_PATH:PATH=#{HOMEBREW_PREFIX}/Frameworks"
cmake_args << "-DINSTALL_DIR:PATH=#{prefix}"
cmake_args << "-D3RDPARTY_DIR:PATH=#{HOMEBREW_PREFIX}"
cmake_args << "-D3RDPARTY_TCL_DIR:PATH=/usr"
cmake_args << "-D3RDPARTY_TK_INCLUDE_DIR:PATH=/usr/include"
cmake_args << "-DINSTALL_TESTS:BOOL=ON" if build.with? "tests"
cmake_args << "-D3RDPARTY_TBB_DIR:PATH=#{HOMEBREW_PREFIX}" if build.with? "tbb"
# must specify, otherwise finds old ft2config.h in /usr/X11R6
cmake_args << "-D3RDPARTY_FREETYPE_INCLUDE_DIR:PATH=#{HOMEBREW_PREFIX}/include/freetype2"
%w[freeimage gl2ps opencl tbb].each do |feature|
cmake_args << "-DUSE_#{feature.upcase}:BOOL=ON" if build.with? feature
end
opencl_path = Pathname.new "/System/Library/Frameworks/OpenCL.framework/Versions/Current"
if build.with?("opencl") && opencl_path.exist?
cmake_args << "-D3RDPARTY_OPENCL_INCLUDE_DIR:PATH=#{opencl_path}/Headers"
cmake_args << "-D3RDPARTY_OPENCL_DLL:FILEPATH=#{opencl_path}/Libraries/libcl2module.dylib"
# link against the Apple built-in OpenCL Framework
# inreplace "adm/cmake/TKOpenGL/CMakeLists.txt", "list( APPEND TKOpenGl_USED_LIBS OpenCL )", <<-EOF.undent
# find_library(FRAMEWORKS_OPENCL NAMES OpenCL)
# list( APPEND TKOpenGl_USED_LIBS ${FRAMEWORKS_OPENCL} )
# EOF
end
system "cmake", ".", *cmake_args
system "make", "install"
if build.with? "extras"
# 6.7.1 now installs samples/tcl by default, must move back before moving all
mv prefix/"samples/tcl", "samples/tcl"
rmdir prefix/"samples"
prefix.install "doc", "samples"
end
# add symlinks to be able to compile against OpenCascade
loc = "#{prefix}/mac64/clang"
include.install_symlink Dir["#{prefix}/inc/*"]
bin.install_symlink Dir["#{loc}/bin/*"]
lib.install_symlink Dir["#{loc}/lib/*"]
end
def caveats; <<-EOF.undent
Some apps will require this enviroment variable:
CASROOT=#{opt_prefix}
EOF
end
test do
ENV["CASROOT"] = opt_prefix
"1\n"==`#{bin}/DRAWEXE -c \"pload ALL\"`
end
end