aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/opencv.rb
diff options
context:
space:
mode:
authornibbles 2bits2012-08-19 22:48:30 -0700
committerAdam Vandenberg2012-08-21 14:45:36 -0700
commitc50e3c11cded3cf28a1e2e5cfcb8dc2e660d96a6 (patch)
tree1d23a258bd450dbd0f2fec462350342945aeeb02 /Library/Formula/opencv.rb
parent1a97ee2ac8956c050e6d32672f50cfd54257945a (diff)
downloadhomebrew-c50e3c11cded3cf28a1e2e5cfcb8dc2e660d96a6.tar.bz2
opencv: fix --32-bit option, use HB libraries
opencv has a 32bit option meant to work with HB libraries like libtiff, jpeg, and jasper when those are universal. Add CMake flags to stop opencv from trying to build all those from source. Instead let if find the HB libraries. Add CMake flags to stop it building tests. Add a dep on Eigen, which is used to speed up code. OpenCV has it enabled by default. Add a CMake flag to specify that CUDA is OFF. Duplicate the 32bit extra_CFLAGS to extra_CXXFLAGS also. When building 32bit specify `-DCMAKE_OSX_ARCHITECTURES=i386` per the install docs. Switch to an OOS build. Put the source dir last. Use the new `option` DSL. Adjust python includes to support XCode-only installs. Use their new homepage `opencv.org` Tested with clang and llvm from XCode-4.4.1 against HB python and system python on Mt. Lion, all options. Fixes #14237 #13603 Closes #14305. Signed-off-by: Adam Vandenberg <flangy@gmail.com>
Diffstat (limited to 'Library/Formula/opencv.rb')
-rw-r--r--Library/Formula/opencv.rb54
1 files changed, 36 insertions, 18 deletions
diff --git a/Library/Formula/opencv.rb b/Library/Formula/opencv.rb
index c0c0aff9d..7d74e417a 100644
--- a/Library/Formula/opencv.rb
+++ b/Library/Formula/opencv.rb
@@ -9,37 +9,47 @@ def site_package_dir
end
class Opencv < Formula
- homepage 'http://opencv.willowgarage.com/wiki/'
+ homepage 'http://opencv.org/'
url 'http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.2/OpenCV-2.4.2.tar.bz2'
sha1 '96ff27b87e0f028d1d16201afebabec4e0c72367'
depends_on 'cmake' => :build
depends_on 'pkg-config' => :build
+ depends_on 'eigen' => :optional
depends_on 'libtiff' => :optional
depends_on 'jasper' => :optional
depends_on 'tbb' => :optional
depends_on 'qt' if ARGV.include? '--with-qt'
- depends_on 'numpy' => :python
+ depends_on 'numpy' => :python
# Can also depend on ffmpeg, but this pulls in a lot of extra stuff that
# you don't need unless you're doing video analysis, and some of it isn't
- # in Homebrew anyway.
+ # in Homebrew anyway. Will depend on openexr if it's installed.
- def options
- [
- ["--32-bit", "Build 32-bit only."],
- ["--with-qt", "Build qt backend."],
- ["--with-tbb", "Build with TBB support."]
- ]
- end
+ option '32-bit'
+ option 'with-qt', 'Build the Qt4 backend to HighGUI'
+ option 'with-tbb', 'Enable parallel code in OpenCV using Intel TBB'
def install
- args = std_cmake_args
- args << "-DOPENCV_EXTRA_C_FLAGS='-arch i386 -m32'" if ARGV.build_32_bit?
- args << "-DWITH_QT=ON" if ARGV.include? "--with-qt"
- args << "-DWITH_TBB=ON" if ARGV.include? "--with-tbb"
+ args = std_cmake_args + %w[
+ -DWITH_CUDA=OFF
+ -DBUILD_ZLIB=OFF
+ -DBUILD_TIFF=OFF
+ -DBUILD_PNG=OFF
+ -DBUILD_JPEG=OFF
+ -DBUILD_JASPER=OFF
+ -DBUILD_TESTS=OFF
+ -DBUILD_PERF_TESTS=OFF
+ ]
+ if ARGV.build_32_bit?
+ args << "-DCMAKE_OSX_ARCHITECTURES=i386"
+ args << "-DOPENCV_EXTRA_C_FLAGS='-arch i386 -m32'"
+ args << "-DOPENCV_EXTRA_CXX_FLAGS='-arch i386 -m32'"
+ end
+ args << '-DWITH_QT=ON' if build.include? 'with-qt'
+ args << '-DWITH_TBB=ON' if build.include? 'with-tbb'
# The CMake `FindPythonLibs` Module is dumber than a bag of hammers when
# more than one python installation is available---for example, it clings
@@ -54,7 +64,12 @@ class Opencv < Formula
if File.exist? "#{python_prefix}/Python"
# Python was compiled with --framework:
args << "-DPYTHON_LIBRARY='#{python_prefix}/Python'"
- args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/Headers'"
+ if !MacOS::CLT.installed? and python_prefix.start_with? '/System/Library'
+ # For Xcode-only systems, the headers of system's python are inside of Xcode
+ args << "-DPYTHON_INCLUDE_DIR='#{MacOS.sdk_path}/System/Library/Frameworks/Python.framework/Versions/2.7/Headers'"
+ else
+ args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/Headers'"
+ end
else
python_lib = "#{python_prefix}/lib/lib#{which_python}"
if File.exists? "#{python_lib}.a"
@@ -66,9 +81,12 @@ class Opencv < Formula
end
args << "-DPYTHON_PACKAGES_PATH='#{lib}/#{which_python}/site-packages'"
- system 'cmake', '.', *args
- system "make"
- system "make install"
+ args << '..'
+ mkdir 'macbuild' do
+ system 'cmake', *args
+ system "make"
+ system "make install"
+ end
end
def caveats; <<-EOS.undent