2016-05-12 12:22:25 +08:00
|
|
|
##############################################################################
|
|
|
|
# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
|
|
|
|
# Produced at the Lawrence Livermore National Laboratory.
|
|
|
|
#
|
|
|
|
# This file is part of Spack.
|
|
|
|
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
|
|
|
# LLNL-CODE-647188
|
|
|
|
#
|
|
|
|
# For details, see https://github.com/llnl/spack
|
|
|
|
# Please also see the LICENSE file for our notice and the LGPL.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU Lesser General Public License (as
|
|
|
|
# published by the Free Software Foundation) version 2.1, February 1999.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
|
|
|
# conditions of the GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
##############################################################################
|
2016-02-01 17:53:27 +08:00
|
|
|
from spack import *
|
|
|
|
|
|
|
|
|
|
|
|
class Opencv(Package):
|
2016-07-13 10:29:04 +08:00
|
|
|
"""OpenCV is released under a BSD license and hence it's free for both
|
|
|
|
academic and commercial use. It has C++, C, Python and Java interfaces and
|
|
|
|
supports Windows, Linux, Mac OS, iOS and Android. OpenCV was designed for
|
|
|
|
computational efficiency and with a strong focus on real-time applications.
|
|
|
|
Written in optimized C/C++, the library can take advantage of multi-core
|
|
|
|
processing. Enabled with OpenCL, it can take advantage of the hardware
|
|
|
|
acceleration of the underlying heterogeneous compute platform. Adopted all
|
|
|
|
around the world, OpenCV has more than 47 thousand people of user community
|
|
|
|
and estimated number of downloads exceeding 9 million. Usage ranges from
|
|
|
|
interactive art, to mines inspection, stitching maps on the web or through
|
|
|
|
advanced robotics.
|
2016-02-01 17:53:27 +08:00
|
|
|
"""
|
2016-07-13 10:29:04 +08:00
|
|
|
|
2016-02-01 17:53:27 +08:00
|
|
|
homepage = 'http://opencv.org/'
|
|
|
|
url = 'https://github.com/Itseez/opencv/archive/3.1.0.tar.gz'
|
|
|
|
|
|
|
|
version('3.1.0', '70e1dd07f0aa06606f1bc0e3fa15abd3')
|
|
|
|
|
2016-07-13 10:29:04 +08:00
|
|
|
variant('shared', default=True,
|
|
|
|
description='Enables the build of shared libraries')
|
|
|
|
variant('debug', default=False,
|
|
|
|
description='Builds a debug version of the libraries')
|
2016-02-01 17:53:27 +08:00
|
|
|
|
|
|
|
variant('eigen', default=True, description='Activates support for eigen')
|
|
|
|
variant('ipp', default=True, description='Activates support for IPP')
|
2016-07-13 10:15:12 +08:00
|
|
|
variant('cuda', default=False, description='Activates support for CUDA')
|
2016-07-14 06:30:28 +08:00
|
|
|
variant('gtk', default=False, description='Activates support for GTK')
|
|
|
|
variant('vtk', default=False, description='Activates support for VTK')
|
|
|
|
variant('qt', default=False, description='Activates support for QT')
|
2016-02-01 17:53:27 +08:00
|
|
|
|
|
|
|
depends_on('zlib')
|
|
|
|
depends_on('libpng')
|
|
|
|
depends_on('libjpeg-turbo')
|
|
|
|
depends_on('libtiff')
|
|
|
|
|
|
|
|
depends_on('python')
|
|
|
|
depends_on('py-numpy')
|
|
|
|
|
|
|
|
depends_on('eigen', when='+eigen')
|
2016-07-13 10:15:12 +08:00
|
|
|
depends_on('cuda', when='+cuda')
|
2016-07-14 06:30:28 +08:00
|
|
|
depends_on('gtkplus', when='+gtk')
|
|
|
|
depends_on('vtk', when='+vtk')
|
|
|
|
depends_on('qt', when='+qt')
|
2016-02-01 17:53:27 +08:00
|
|
|
|
2016-07-13 10:27:21 +08:00
|
|
|
extends('python')
|
|
|
|
|
2016-02-01 17:53:27 +08:00
|
|
|
def install(self, spec, prefix):
|
|
|
|
cmake_options = []
|
|
|
|
cmake_options.extend(std_cmake_args)
|
|
|
|
|
2016-07-14 08:33:37 +08:00
|
|
|
cmake_options.extend([
|
|
|
|
'-DCMAKE_BUILD_TYPE:STRING=%s' % (
|
2016-07-13 10:29:04 +08:00
|
|
|
'Debug' if '+debug' in spec else 'Release'),
|
2016-07-14 08:33:37 +08:00
|
|
|
'-DBUILD_SHARED_LIBS:BOOL=%s' % (
|
2016-07-13 10:29:04 +08:00
|
|
|
'ON' if '+shared' in spec else 'OFF'),
|
2016-07-14 08:33:37 +08:00
|
|
|
'-DENABLE_PRECOMPILED_HEADERS:BOOL=OFF',
|
|
|
|
'-DWITH_IPP:BOOL=%s' % ('ON' if '+ipp' in spec else 'OFF'),
|
|
|
|
'-DWITH_CUDA:BOOL=%s' % ('ON' if '+cuda' in spec else 'OFF'),
|
|
|
|
'-DWITH_QT:BOOL=%s' % ('ON' if '+qt' in spec else 'OFF'),
|
|
|
|
'-DWITH_VTK:BOOL=%s' % ('ON' if '+vtk' in spec else 'OFF')])
|
2016-07-14 06:30:28 +08:00
|
|
|
|
2016-07-16 10:19:23 +08:00
|
|
|
if '+gtk' not in spec:
|
|
|
|
cmake_options.extend(['-DWITH_GTK:BOOL=OFF',
|
|
|
|
'-DWITH_GTK_2_X:BOOL=OFF'])
|
|
|
|
elif '^gtkplus@3:' in spec:
|
2016-07-14 06:30:28 +08:00
|
|
|
cmake_options.extend(['-DWITH_GTK:BOOL=ON',
|
|
|
|
'-DWITH_GTK_2_X:BOOL=OFF'])
|
|
|
|
elif '^gtkplus@2:3' in spec:
|
|
|
|
cmake_options.extend(['-DWITH_GTK:BOOL=OFF',
|
|
|
|
'-DWITH_GTK_2_X:BOOL=ON'])
|
2016-02-01 17:53:27 +08:00
|
|
|
|
2016-07-16 10:21:26 +08:00
|
|
|
python = spec['python']
|
2016-07-14 08:34:40 +08:00
|
|
|
if '^python@3:' in spec:
|
2016-07-16 10:21:26 +08:00
|
|
|
python_exe = join_path(python.prefix.bin, 'python3')
|
|
|
|
cmake_options.extend([
|
|
|
|
'-DBUILD_opencv_python3=ON',
|
|
|
|
'-DPYTHON3_EXECUTABLE=%s' % python_exe,
|
|
|
|
'-DPYTHON3_LIBRARIES=%s' % python.prefix.lib,
|
|
|
|
'-DPYTHON3_INCLUDE_DIR=%s' % python.prefix.include,
|
|
|
|
'-DBUILD_opencv_python2=OFF',
|
|
|
|
'-DPYTHON2_EXECUTABLE=',
|
|
|
|
'-DPYTHON2_LIBRARIES=',
|
|
|
|
'-DPYTHON2_INCLUDE_DIR=',
|
|
|
|
])
|
2016-07-14 08:34:40 +08:00
|
|
|
elif '^python@2:3' in spec:
|
2016-07-16 10:21:26 +08:00
|
|
|
python_exe = join_path(python.prefix.bin, 'python2')
|
|
|
|
cmake_options.extend([
|
|
|
|
'-DBUILD_opencv_python2=ON',
|
|
|
|
'-DPYTHON2_EXECUTABLE=%s' % python_exe,
|
|
|
|
'-DPYTHON2_LIBRARIES=%s' % python.prefix.lib,
|
|
|
|
'-DPYTHON2_INCLUDE_DIR=%s' % python.prefix.include,
|
|
|
|
'-DBUILD_opencv_python3=OFF',
|
|
|
|
'-DPYTHON3_EXECUTABLE=',
|
|
|
|
'-DPYTHON3_LIBRARIES=',
|
|
|
|
'-DPYTHON3_INCLUDE_DIR=',
|
|
|
|
])
|
2016-07-13 10:27:21 +08:00
|
|
|
|
2016-02-01 17:53:27 +08:00
|
|
|
with working_dir('spack_build', create=True):
|
|
|
|
cmake('..', *cmake_options)
|
|
|
|
make('VERBOSE=1')
|
|
|
|
make("install")
|