aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula
diff options
context:
space:
mode:
authorCharlie Sharpsteen2011-09-21 14:35:13 -0700
committerCharlie Sharpsteen2011-09-21 16:03:26 -0700
commita8e828546bd3d3c1ecc5ed4b62303fc97ff38954 (patch)
tree906be106300ce3620306e9bdb07cab1238bec281 /Library/Formula
parentdf7cd48bf08a375df23660ee2cd848e2bd9df6e2 (diff)
downloadhomebrew-a8e828546bd3d3c1ecc5ed4b62303fc97ff38954.tar.bz2
OpenCV: Fix Python support
OpenCV relies on the CMake FindPythonLibs module which get pwned pretty hard if more than one Python installation is available. Copied some code from the VTK formula that straightens things out manually. Also added a numpy dependency. Fixes #7740.
Diffstat (limited to 'Library/Formula')
-rw-r--r--Library/Formula/opencv.rb34
1 files changed, 31 insertions, 3 deletions
diff --git a/Library/Formula/opencv.rb b/Library/Formula/opencv.rb
index 6ee9a569a..274e520ce 100644
--- a/Library/Formula/opencv.rb
+++ b/Library/Formula/opencv.rb
@@ -21,6 +21,8 @@ class Opencv < Formula
depends_on 'jasper' => :optional
depends_on 'tbb' => :optional
+ 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.
@@ -36,9 +38,35 @@ class Opencv < Formula
end
def install
- makefiles = "cmake -G 'Unix Makefiles' -DCMAKE_INSTALL_PREFIX:PATH=#{prefix} ."
- makefiles += " -DOPENCV_EXTRA_C_FLAGS='-arch i386 -m32'" if ARGV.include? '--build32'
- system makefiles
+ args = std_cmake_parameters.split
+ args << " -DOPENCV_EXTRA_C_FLAGS='-arch i386 -m32'" if ARGV.include? '--build32'
+
+ # The CMake `FindPythonLibs` Module is dumber than a bag of hammers when
+ # more than one python installation is available---for example, it clings
+ # to the Header folder of the system Python Framework like a drowning
+ # sailor.
+ #
+ # This code was cribbed from the VTK formula and uses the output to
+ # `python-config` to do the job FindPythonLibs should be doing in the first
+ # place.
+ python_prefix = `python-config --prefix`.strip
+ # Python is actually a library. The libpythonX.Y.dylib points to this lib, too.
+ if File.exist? "#{python_prefix}/Python"
+ # Python was compiled with --framework:
+ args << "-DPYTHON_LIBRARY='#{python_prefix}/Python'"
+ args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/Headers'"
+ else
+ python_lib = "#{python_prefix}/lib/lib#{which_python}"
+ if File.exists? "#{python_lib}.a"
+ args << "-DPYTHON_LIBRARY='#{python_lib}.a'"
+ else
+ args << "-DPYTHON_LIBRARY='#{python_lib}.dylib'"
+ end
+ args << "-DPYTHON_INCLUDE_DIR='#{python_prefix}/include/#{which_python}'"
+ end
+
+ system 'cmake', '.', *args
+ interactive_shell
system "make"
system "make install"
end