summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToyohisa Kameyama <kameyama@riken.jp>2020-05-12 23:39:19 +0900
committerGitHub <noreply@github.com>2020-05-12 09:39:19 -0500
commit7813e4146459f9460f0e6c0d6809d055130e903b (patch)
treeb0d87885ab76f34684565a05966f16e5461e4d31
parentd1a5dc792ea9828433a207818ab5805a5bd0a2f0 (diff)
downloadspack-7813e4146459f9460f0e6c0d6809d055130e903b.tar.gz
spack-7813e4146459f9460f0e6c0d6809d055130e903b.tar.bz2
spack-7813e4146459f9460f0e6c0d6809d055130e903b.tar.xz
spack-7813e4146459f9460f0e6c0d6809d055130e903b.zip
caffe: fixed build error (#16520)
* opencv 3.2 requires cmake 3.11 or older. caffe dependency is changed. * revert opencv variant to caffe. backport to opencv errors.
-rw-r--r--var/spack/repos/builtin/packages/caffe/package.py2
-rwxr-xr-xvar/spack/repos/builtin/packages/opencv/opencv3.2_cmake.patch84
-rwxr-xr-xvar/spack/repos/builtin/packages/opencv/opencv3.2_ffmpeg.patch107
-rwxr-xr-xvar/spack/repos/builtin/packages/opencv/opencv3.2_python3.7.patch22
-rwxr-xr-xvar/spack/repos/builtin/packages/opencv/opencv3.2_regacyvtk.patch119
-rwxr-xr-xvar/spack/repos/builtin/packages/opencv/opencv3.2_vtk.patch20
-rw-r--r--var/spack/repos/builtin/packages/opencv/package.py9
7 files changed, 362 insertions, 1 deletions
diff --git a/var/spack/repos/builtin/packages/caffe/package.py b/var/spack/repos/builtin/packages/caffe/package.py
index e07f545f73..7df83b1d53 100644
--- a/var/spack/repos/builtin/packages/caffe/package.py
+++ b/var/spack/repos/builtin/packages/caffe/package.py
@@ -40,7 +40,7 @@ class Caffe(CMakePackage):
depends_on('protobuf')
depends_on('glog')
depends_on('gflags')
- depends_on('hdf5')
+ depends_on('hdf5 +hl +cxx')
# Optional dependencies
depends_on('opencv@3.2.0+core+highgui+imgproc', when='+opencv')
diff --git a/var/spack/repos/builtin/packages/opencv/opencv3.2_cmake.patch b/var/spack/repos/builtin/packages/opencv/opencv3.2_cmake.patch
new file mode 100755
index 0000000000..c479fb450e
--- /dev/null
+++ b/var/spack/repos/builtin/packages/opencv/opencv3.2_cmake.patch
@@ -0,0 +1,84 @@
+commit dd7f88bd68f95e56437035cc95d4af482482fcc2
+Author: Alexander Alekhin <alexander.alekhin@intel.com>
+Date: Thu Jun 7 12:32:48 2018 +0300
+
+ python: support standalone Python bindings build
+
+ - requires OpenCV source directory
+ - requires OpenCV binary directory with built modules and 'python_bindings_generator' target
+
+diff --git a/cmake/OpenCVDetectPython.cmake b/cmake/OpenCVDetectPython.cmake
+index 6dec76ff66..b6c7a2535c 100644
+--- a/cmake/OpenCVDetectPython.cmake
++++ b/cmake/OpenCVDetectPython.cmake
+@@ -27,6 +27,12 @@ function(find_python preferred_version min_version library_env include_dir_env
+ debug_library include_path include_dir include_dir2 packages_path
+ numpy_include_dirs numpy_version)
+ if(NOT ${found})
++ if(" ${executable}" STREQUAL " PYTHON_EXECUTABLE")
++ set(__update_python_vars 0)
++ else()
++ set(__update_python_vars 1)
++ endif()
++
+ ocv_check_environment_variables(${executable})
+ if(${executable})
+ set(PYTHON_EXECUTABLE "${${executable}}")
+@@ -47,7 +53,7 @@ if(NOT ${found})
+ endforeach()
+ endif()
+
+- string(REGEX MATCH "^[0-9]+" _preferred_version_major ${preferred_version})
++ string(REGEX MATCH "^[0-9]+" _preferred_version_major "${preferred_version}")
+
+ find_host_package(PythonInterp "${preferred_version}")
+ if(NOT PYTHONINTERP_FOUND)
+@@ -56,7 +62,7 @@ if(NOT ${found})
+
+ if(PYTHONINTERP_FOUND)
+ # Check if python major version is correct
+- if(${_preferred_version_major} EQUAL ${PYTHON_VERSION_MAJOR})
++ if("${_preferred_version_major}" STREQUAL "" OR "${_preferred_version_major}" STREQUAL "${PYTHON_VERSION_MAJOR}")
+ # Copy outputs
+ set(_found ${PYTHONINTERP_FOUND})
+ set(_executable ${PYTHON_EXECUTABLE})
+@@ -65,7 +71,9 @@ if(NOT ${found})
+ set(_version_minor ${PYTHON_VERSION_MINOR})
+ set(_version_patch ${PYTHON_VERSION_PATCH})
+ endif()
++ endif()
+
++ if(__update_python_vars)
+ # Clear find_host_package side effects
+ unset(PYTHONINTERP_FOUND)
+ unset(PYTHON_EXECUTABLE CACHE)
+@@ -109,7 +117,8 @@ if(NOT ${found})
+ set(_library_release ${PYTHON_LIBRARY_RELEASE})
+ set(_include_dir ${PYTHON_INCLUDE_DIR})
+ set(_include_dir2 ${PYTHON_INCLUDE_DIR2})
+-
++ endif()
++ if(__update_python_vars)
+ # Clear find_package side effects
+ unset(PYTHONLIBS_FOUND)
+ unset(PYTHON_LIBRARIES)
+@@ -160,7 +169,7 @@ if(NOT ${found})
+ unset(_path)
+ endif()
+
+- set(_numpy_include_dirs ${${numpy_include_dirs}})
++ set(_numpy_include_dirs "${${numpy_include_dirs}}")
+
+ if(NOT _numpy_include_dirs)
+ if(CMAKE_CROSSCOMPILING)
+@@ -222,6 +231,10 @@ if(NOT ${found})
+ endif()
+ endfunction(find_python)
+
++if(OPENCV_PYTHON_SKIP_DETECTION)
++ return()
++endif()
++
+ find_python(2.7 "${MIN_VER_PYTHON2}" PYTHON2_LIBRARY PYTHON2_INCLUDE_DIR
+ PYTHON2INTERP_FOUND PYTHON2_EXECUTABLE PYTHON2_VERSION_STRING
+ PYTHON2_VERSION_MAJOR PYTHON2_VERSION_MINOR PYTHON2LIBS_FOUND
diff --git a/var/spack/repos/builtin/packages/opencv/opencv3.2_ffmpeg.patch b/var/spack/repos/builtin/packages/opencv/opencv3.2_ffmpeg.patch
new file mode 100755
index 0000000000..d7786308d8
--- /dev/null
+++ b/var/spack/repos/builtin/packages/opencv/opencv3.2_ffmpeg.patch
@@ -0,0 +1,107 @@
+commit b1d208891b9f6ae3968730b120a5d0dcbba679d0
+Author: Jonathan Viney <jonathan.viney@gmail.com>
+Date: Sun Nov 19 07:08:41 2017 +1300
+
+ Merge pull request #10011 from jviney:master
+
+ Fix build with FFmpeg master. Some deprecated APIs have been removed. (#10011)
+
+ * Fix build with FFmpeg master.
+
+ * ffmpeg: update AVFMT_RAWPICTURE support removal
+
+diff --git a/modules/videoio/src/cap_ffmpeg_impl.hpp b/modules/videoio/src/cap_ffmpeg_impl.hpp
+index 5f51e65134..46461483a7 100644
+--- a/modules/videoio/src/cap_ffmpeg_impl.hpp
++++ b/modules/videoio/src/cap_ffmpeg_impl.hpp
+@@ -149,6 +149,10 @@ extern "C" {
+ #define AV_PIX_FMT_GRAY16BE PIX_FMT_GRAY16BE
+ #endif
+
++#ifndef PKT_FLAG_KEY
++#define PKT_FLAG_KEY AV_PKT_FLAG_KEY
++#endif
++
+ #if LIBAVUTIL_BUILD >= (LIBAVUTIL_VERSION_MICRO >= 100 \
+ ? CALC_FFMPEG_VERSION(52, 38, 100) : CALC_FFMPEG_VERSION(52, 13, 0))
+ #define USE_AV_FRAME_GET_BUFFER 1
+@@ -1570,7 +1574,11 @@ static AVStream *icv_add_video_stream_FFMPEG(AVFormatContext *oc,
+ // some formats want stream headers to be seperate
+ if(oc->oformat->flags & AVFMT_GLOBALHEADER)
+ {
++#if LIBAVCODEC_BUILD > CALC_FFMPEG_VERSION(56, 35, 0)
++ c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
++#else
+ c->flags |= CODEC_FLAG_GLOBAL_HEADER;
++#endif
+ }
+ #endif
+
+@@ -1598,23 +1606,24 @@ static int icv_av_write_frame_FFMPEG( AVFormatContext * oc, AVStream * video_st,
+ #endif
+ int ret = OPENCV_NO_FRAMES_WRITTEN_CODE;
+
+- if (oc->oformat->flags & AVFMT_RAWPICTURE) {
++#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(57, 0, 0)
++ if (oc->oformat->flags & AVFMT_RAWPICTURE)
++ {
+ /* raw video case. The API will change slightly in the near
+ futur for that */
+ AVPacket pkt;
+ av_init_packet(&pkt);
+
+-#ifndef PKT_FLAG_KEY
+-#define PKT_FLAG_KEY AV_PKT_FLAG_KEY
+-#endif
+-
+ pkt.flags |= PKT_FLAG_KEY;
+ pkt.stream_index= video_st->index;
+ pkt.data= (uint8_t *)picture;
+ pkt.size= sizeof(AVPicture);
+
+ ret = av_write_frame(oc, &pkt);
+- } else {
++ }
++ else
++#endif
++ {
+ /* encode the image */
+ AVPacket pkt;
+ av_init_packet(&pkt);
+@@ -1772,7 +1781,9 @@ void CvVideoWriter_FFMPEG::close()
+ /* write the trailer, if any */
+ if(ok && oc)
+ {
+- if( (oc->oformat->flags & AVFMT_RAWPICTURE) == 0 )
++#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(57, 0, 0)
++ if (!(oc->oformat->flags & AVFMT_RAWPICTURE))
++#endif
+ {
+ for(;;)
+ {
+@@ -2071,7 +2082,11 @@ bool CvVideoWriter_FFMPEG::open( const char * filename, int fourcc,
+
+ outbuf = NULL;
+
+- if (!(oc->oformat->flags & AVFMT_RAWPICTURE)) {
++
++#if LIBAVFORMAT_BUILD < CALC_FFMPEG_VERSION(57, 0, 0)
++ if (!(oc->oformat->flags & AVFMT_RAWPICTURE))
++#endif
++ {
+ /* allocate output buffer */
+ /* assume we will never get codec output with more than 4 bytes per pixel... */
+ outbuf_size = width*height*4;
+@@ -2376,7 +2391,11 @@ AVStream* OutputMediaStream_FFMPEG::addVideoStream(AVFormatContext *oc, CV_CODEC
+ // some formats want stream headers to be seperate
+ if (oc->oformat->flags & AVFMT_GLOBALHEADER)
+ {
+- c->flags |= CODEC_FLAG_GLOBAL_HEADER;
++ #if LIBAVCODEC_BUILD > CALC_FFMPEG_VERSION(56, 35, 0)
++ c->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
++ #else
++ c->flags |= CODEC_FLAG_GLOBAL_HEADER;
++ #endif
+ }
+ #endif
+
diff --git a/var/spack/repos/builtin/packages/opencv/opencv3.2_python3.7.patch b/var/spack/repos/builtin/packages/opencv/opencv3.2_python3.7.patch
new file mode 100755
index 0000000000..d96011330d
--- /dev/null
+++ b/var/spack/repos/builtin/packages/opencv/opencv3.2_python3.7.patch
@@ -0,0 +1,22 @@
+commit 0c4328fbf3da0da57a91b2133578c5100370b867
+Author: ilovezfs <ilovezfs@icloud.com>
+Date: Tue Jul 3 06:31:39 2018 +0000
+
+ Python 3.7 compatability
+
+ The result of PyUnicode_AsUTF8() is now of type const char * rather of
+ char *.
+
+diff --git a/modules/python/src2/cv2.cpp b/modules/python/src2/cv2.cpp
+index e16fcbacf2..5a6bf7ef62 100644
+--- a/modules/python/src2/cv2.cpp
++++ b/modules/python/src2/cv2.cpp
+@@ -916,7 +916,7 @@ bool pyopencv_to(PyObject* obj, String& value, const char* name)
+ (void)name;
+ if(!obj || obj == Py_None)
+ return true;
+- char* str = PyString_AsString(obj);
++ const char* str = PyString_AsString(obj);
+ if(!str)
+ return false;
+ value = String(str);
diff --git a/var/spack/repos/builtin/packages/opencv/opencv3.2_regacyvtk.patch b/var/spack/repos/builtin/packages/opencv/opencv3.2_regacyvtk.patch
new file mode 100755
index 0000000000..f5341c62fa
--- /dev/null
+++ b/var/spack/repos/builtin/packages/opencv/opencv3.2_regacyvtk.patch
@@ -0,0 +1,119 @@
+commit 235889ddbb1aaa4f0dfaee730f42a8476c0e50f0
+Author: jasjuang <jasjuang@gmail.com>
+Date: Thu Dec 21 01:33:25 2017 -0800
+
+ handle legacy VTK functions
+
+diff --git a/modules/viz/src/clouds.cpp b/modules/viz/src/clouds.cpp
+index 48d057d2a8..ab8fd43e40 100644
+--- a/modules/viz/src/clouds.cpp
++++ b/modules/viz/src/clouds.cpp
+@@ -77,7 +77,9 @@ cv::viz::WCloud::WCloud(cv::InputArray cloud, cv::InputArray colors, cv::InputAr
+ vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
+ VtkUtils::SetInputData(mapper, cloud_source->GetOutput());
+ mapper->SetScalarModeToUsePointData();
++#if VTK_MAJOR_VERSION < 8
+ mapper->ImmediateModeRenderingOff();
++#endif
+ mapper->SetScalarRange(0, 255);
+ mapper->ScalarVisibilityOn();
+
+@@ -117,7 +119,9 @@ cv::viz::WPaintedCloud::WPaintedCloud(InputArray cloud)
+
+ vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
+ VtkUtils::SetInputData(mapper, vtkPolyData::SafeDownCast(elevation->GetOutput()));
++#if VTK_MAJOR_VERSION < 8
+ mapper->ImmediateModeRenderingOff();
++#endif
+ mapper->ScalarVisibilityOn();
+ mapper->SetColorModeToMapScalars();
+
+@@ -143,7 +147,9 @@ cv::viz::WPaintedCloud::WPaintedCloud(InputArray cloud, const Point3d& p1, const
+
+ vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
+ VtkUtils::SetInputData(mapper, vtkPolyData::SafeDownCast(elevation->GetOutput()));
++#if VTK_MAJOR_VERSION < 8
+ mapper->ImmediateModeRenderingOff();
++#endif
+ mapper->ScalarVisibilityOn();
+ mapper->SetColorModeToMapScalars();
+
+@@ -182,7 +188,9 @@ cv::viz::WPaintedCloud::WPaintedCloud(InputArray cloud, const Point3d& p1, const
+
+ vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
+ VtkUtils::SetInputData(mapper, vtkPolyData::SafeDownCast(elevation->GetOutput()));
++#if VTK_MAJOR_VERSION < 8
+ mapper->ImmediateModeRenderingOff();
++#endif
+ mapper->ScalarVisibilityOn();
+ mapper->SetColorModeToMapScalars();
+ mapper->SetLookupTable(color_transfer);
+@@ -211,7 +219,9 @@ cv::viz::WCloudCollection::WCloudCollection()
+ vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
+ mapper->SetInputConnection(append_filter->GetOutputPort());
+ mapper->SetScalarModeToUsePointData();
++#if VTK_MAJOR_VERSION < 8
+ mapper->ImmediateModeRenderingOff();
++#endif
+ mapper->SetScalarRange(0, 255);
+ mapper->ScalarVisibilityOn();
+
+@@ -416,7 +426,9 @@ cv::viz::WMesh::WMesh(const Mesh &mesh)
+
+ vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
+ mapper->SetScalarModeToUsePointData();
++#if VTK_MAJOR_VERSION < 8
+ mapper->ImmediateModeRenderingOff();
++#endif
+ VtkUtils::SetInputData(mapper, polydata);
+
+ vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
+@@ -468,7 +480,9 @@ cv::viz::WWidgetMerger::WWidgetMerger()
+ vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
+ mapper->SetInputConnection(append_filter->GetOutputPort());
+ mapper->SetScalarModeToUsePointData();
++#if VTK_MAJOR_VERSION < 8
+ mapper->ImmediateModeRenderingOff();
++#endif
+ mapper->SetScalarRange(0, 255);
+ mapper->ScalarVisibilityOn();
+
+diff --git a/modules/viz/src/widget.cpp b/modules/viz/src/widget.cpp
+index 0473c274bc..b324a4e26c 100644
+--- a/modules/viz/src/widget.cpp
++++ b/modules/viz/src/widget.cpp
+@@ -91,7 +91,9 @@ cv::viz::Widget cv::viz::Widget::fromPlyFile(const String &file_name)
+
+ vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New();
+ mapper->SetInputConnection( reader->GetOutputPort() );
++#if VTK_MAJOR_VERSION < 8
+ mapper->ImmediateModeRenderingOff();
++#endif
+
+ vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
+ actor->GetProperty()->SetInterpolationToFlat();
+@@ -113,7 +115,11 @@ void cv::viz::Widget::setRenderingProperty(int property, double value)
+ case POINT_SIZE: actor->GetProperty()->SetPointSize(float(value)); break;
+ case OPACITY: actor->GetProperty()->SetOpacity(value); break;
+ case LINE_WIDTH: actor->GetProperty()->SetLineWidth(float(value)); break;
++#if VTK_MAJOR_VERSION < 8
+ case IMMEDIATE_RENDERING: actor->GetMapper()->SetImmediateModeRendering(int(value)); break;
++#else
++ case IMMEDIATE_RENDERING: std::cerr << "this property has no effect" << std::endl; break;
++#endif
+ case AMBIENT: actor->GetProperty()->SetAmbient(float(value)); break;
+ case LIGHTING:
+ {
+@@ -191,8 +197,11 @@ double cv::viz::Widget::getRenderingProperty(int property) const
+ case POINT_SIZE: value = actor->GetProperty()->GetPointSize(); break;
+ case OPACITY: value = actor->GetProperty()->GetOpacity(); break;
+ case LINE_WIDTH: value = actor->GetProperty()->GetLineWidth(); break;
++#if VTK_MAJOR_VERSION < 8
+ case IMMEDIATE_RENDERING: value = actor->GetMapper()->GetImmediateModeRendering(); break;
+-
++#else
++ case IMMEDIATE_RENDERING: std::cerr << "this property has no effect" << std::endl; break;
++#endif
+ case FONT_SIZE:
+ {
+ vtkTextActor* text_actor = vtkTextActor::SafeDownCast(actor);
diff --git a/var/spack/repos/builtin/packages/opencv/opencv3.2_vtk.patch b/var/spack/repos/builtin/packages/opencv/opencv3.2_vtk.patch
new file mode 100755
index 0000000000..e5eecd7092
--- /dev/null
+++ b/var/spack/repos/builtin/packages/opencv/opencv3.2_vtk.patch
@@ -0,0 +1,20 @@
+commit d810c73396ec7931addf3e7f75b17daf4e184bf4
+Author: Adam Rankin <adam.rankin@gmail.com>
+Date: Sun Mar 11 22:28:18 2018 -0400
+
+ Update precomp.hpp
+
+ Enabling build of visualization module when using VTK 9 (current HEAD of d5bbb9e99bbc6d11d2196c48bfd8f33508554551)
+
+diff --git a/modules/viz/src/precomp.hpp b/modules/viz/src/precomp.hpp
+index 369db191d3..dc5a5db1ea 100644
+--- a/modules/viz/src/precomp.hpp
++++ b/modules/viz/src/precomp.hpp
+@@ -104,6 +104,7 @@
+ #include <vtkMath.h>
+ #include <vtkExtractEdges.h>
+ #include <vtkFrustumSource.h>
++#include <vtkTexture.h>
+ #include <vtkTextureMapToPlane.h>
+ #include <vtkPolyDataNormals.h>
+ #include <vtkAlgorithmOutput.h>
diff --git a/var/spack/repos/builtin/packages/opencv/package.py b/var/spack/repos/builtin/packages/opencv/package.py
index 0e5bca7907..c589e7fdd2 100644
--- a/var/spack/repos/builtin/packages/opencv/package.py
+++ b/var/spack/repos/builtin/packages/opencv/package.py
@@ -121,6 +121,12 @@ class Opencv(CMakePackage, CudaPackage):
# the current development branch of OpenCV. See #8461 for more information.
patch('dnn_cuda.patch', when='@3.3.0:3.4.1+cuda+dnn')
+ patch('opencv3.2_cmake.patch', when='@3.2')
+ patch('opencv3.2_vtk.patch', when='@3.2+vtk')
+ patch('opencv3.2_regacyvtk.patch', when='@3.2+vtk')
+ patch('opencv3.2_ffmpeg.patch', when='@3.2+videoio')
+ patch('opencv3.2_python3.7.patch', when='@3.2+python')
+
depends_on('eigen', when='+eigen')
depends_on('zlib', when='+zlib')
depends_on('libpng', when='+png')
@@ -147,6 +153,9 @@ class Opencv(CMakePackage, CudaPackage):
conflicts('cuda@10:', when='+cudacodec')
conflicts('cuda', when='~contrib', msg='cuda support requires +contrib')
+ # IPP is provided x86_64 only
+ conflicts('+ipp', when="arch=aarch64:")
+
extends('python', when='+python')
def cmake_args(self):