diff --git a/Formula/o/opencv.rb b/Formula/o/opencv.rb index 175e27307bfde..91e11d3b1efdc 100644 --- a/Formula/o/opencv.rb +++ b/Formula/o/opencv.rb @@ -91,9 +91,6 @@ def install # Avoid Accelerate.framework ENV["OpenBLAS_HOME"] = Formula["openblas"].opt_prefix - # Reset PYTHONPATH, workaround for https://github.com/Homebrew/homebrew-science/pull/4885 - ENV.delete("PYTHONPATH") - # Remove bundled libraries to make sure formula dependencies are used libdirs = %w[ffmpeg libjasper libjpeg libjpeg-turbo libpng libtiff libwebp openexr openjpeg protobuf tbb zlib] libdirs.each { |l| rm_r(buildpath/"3rdparty"/l) } @@ -138,11 +135,6 @@ def install -DPYTHON3_EXECUTABLE=#{which(python3)} ] - args += [ - "-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON", # https://github.com/protocolbuffers/protobuf/issues/12292 - "-Dprotobuf_MODULE_COMPATIBLE=ON", # https://github.com/protocolbuffers/protobuf/issues/1931 - ] - args += if OS.mac? # Requires closed-source, pre-built Orbbec SDK on macOS ["-DWITH_OBSENSOR=OFF"] @@ -189,14 +181,22 @@ def install test do (testpath/"test.cpp").write <<~CPP + #include + #include #include #include int main() { std::cout << CV_VERSION << std::endl; + cv::Mat img = cv::imread("#{test_fixtures("test.jpg")}", cv::IMREAD_COLOR); + if (img.empty()) { + std::cerr << "Could not read test.jpg fixture" << std::endl; + return 1; + } return 0; } CPP - system ENV.cxx, "-std=c++17", "test.cpp", "-I#{include}/opencv4", "-o", "test" + system ENV.cxx, "-std=c++17", "test.cpp", "-I#{include}/opencv4", "-o", "test", + "-L#{lib}", "-lopencv_core", "-lopencv_imgcodecs" assert_equal version.to_s, shell_output("./test").strip output = shell_output("#{python3} -c 'import cv2; print(cv2.__version__)'")