#!/bin/bash

package=cmake
version=-3.0.0

progname=$0

source ../cascade-make/lib/cascade-lib.bash GEXTOPENCV ../.. $*

prefix=$GEXTOPENCV_INSTALLED

opt_run_untar $force_untar $auto_untar $package $version
opt_run_configure $force_config $auto_config $package $version $prefix

# Only compile if necessary - we don't edit these source files.
if type -p cmake; then
  echo "found cmake in PATH"
  _CMAKE=cmake
elif [[ -x "$GEXTOPENCV_INSTALLED/linux/bin/cmake" ]]; then
  echo "found cmake in openCV/linux/bin"
  _CMAKE="$GEXTOPENCV_INSTALLED/linux/bin/cmake"
fi

if [[ "$_CMAKE" ]]; then
  _VERSION=$("$_CMAKE" --version 2>&1 | sed 's/.*cmake version \([0-9]*\.[0-9]*\.[0-9]*\).*/\1/;1q')
  echo "cmake version $_VERSION"
fi

if [[ ! "$_CMAKE" ]]; then
  opt_run_make $compile   $package $version
  opt_run_make $install   $package $version "install"
else
  echo "$package$version already available => no need to recompile"
fi

opt_run_make $clean     $package $version "clean"
opt_run_make $distclean $package $version "distclean"

opt_run_tarclean $tarclean $package $version





