#!/bin/bash
set -e  # exit on first error
UBUNTU_VERSION=`lsb_release --release | cut -f2`
SRC_PREFIX_PATH="/usr/local/src/"


install_dependencies() {
    apt-get update -qq
    apt-get install -qq -y cmake \
                           libgoogle-glog-dev \
                           libatlas-base-dev \
                           libeigen3-dev \
                           libsuitesparse-dev
}

install_suitesparse_fix() {
    add-apt-repository ppa:bzindovic/suitesparse-bugfix-1319687 -y
    apt-get update -qq
    apt-get install -qq libsuitesparse-dev
}

install_ceres_solver() {
    # clone ceres solver
    mkdir -p $SRC_PREFIX_PATH
    cd $SRC_PREFIX_PATH
    git clone https://github.com/ceres-solver/ceres-solver.git

    # go into ceres-solver repo and prepare for build
    cd ceres-solver
    mkdir build
    cd build
    cmake ..

    # compile and install
    make
    make test
    make install
}


# MAIN
if [ $UBUNTU_VERSION == "16.04" ]; then
    install_dependencies
    install_ceres_solver

elif [ $UBUNTU_VERSION == "14.04" ]; then
    install_dependencies
    install_suitesparse_fix
    install_ceres_solver
fi

#!/bin/bash
set -e  # exit on first error
UBUNTU_VERSION=`lsb_release --release | cut -f2`
SRC_PREFIX_PATH="/usr/local/src/"
CERES_VERSION=1.12.0


install_dependencies() {
    apt-get update -qq
    apt-get install -qq -y cmake \
                           libgoogle-glog-dev \
                           libatlas-base-dev \
                           libeigen3-dev \
                           libsuitesparse-dev
}

install_suitesparse_fix() {
    add-apt-repository ppa:bzindovic/suitesparse-bugfix-1319687 -y
    apt-get update -qq
    apt-get install -qq libsuitesparse-dev
}

install_ceres_solver() {
    # clone ceres solver
    mkdir -p $SRC_PREFIX_PATH
    cd $SRC_PREFIX_PATH
    git clone https://github.com/ceres-solver/ceres-solver.git

    # go into ceres-solver repo and prepare for build
    cd ceres-solver
    git checkout tags/${CERES_VERSION}
    mkdir build
    cd build
    cmake ..

    # compile and install
    make
    make test
    make install
}


# MAIN
if [ $UBUNTU_VERSION == "16.04" ]; then
    install_dependencies
    install_ceres_solver

elif [ $UBUNTU_VERSION == "14.04" ]; then
    install_dependencies
    install_suitesparse_fix
    install_ceres_solver
fi

Install script: use ceres release 1.12.0
Install script: use ceres release 1.12.0

Currently we are pulling and building master, which sometimes causes issues.

The CERES_VERSION variable will have to be updated when we want to install a
newer release. (It is possible to check out the latest tag, but that includes
release candidate tags, so would need more logic, etc)
