Skip to content

Commit

Permalink
enh: Minimum supported Ubuntu version 16.04, use 18.04 for Docker image
Browse files Browse the repository at this point in the history
- Require C++14 compiler.
- Require CMake 3.4 or later.
- Use Ubuntu 18.04 as base Docker image.
- Use VTK 8 in Docker image.
  • Loading branch information
schuhschuh committed Nov 6, 2019
1 parent d007d0c commit 4714f88
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dist: trusty
dist: xenial
sudo: required

language: cpp
Expand All @@ -19,7 +19,7 @@ env:
# versions of VTK for each OS
# - On Ubuntu, use default version installed by apt-get
# - On macOS, build recent VTK version from sources and cache installation
- LINUX_VTK_VERSION=6.0.0
- LINUX_VTK_VERSION=6.2.0
- MACOS_VTK_VERSION=8.1.0
- WITH_CCACHE=ON # speed up MIRTK build itself using ccache
- WITH_ARPACK=OFF # requires time consuming build of gcc on macOS
Expand Down
8 changes: 4 additions & 4 deletions BasisProject.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ============================================================================
# Medical Image Registration ToolKit (MIRTK)
#
# Copyright 2013-2017 Imperial College London
# Copyright 2013-2018 Andreas Schuh
# Copyright 2013-2019 Imperial College London
# Copyright 2013-2019 Andreas Schuh
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -56,11 +56,11 @@ basis_project (
SOVERSION "0" # API yet unstable
AUTHORS "Andreas Schuh"
DESCRIPTION "Medical Image Registration ToolKit"
COPYRIGHT "2013-2018 Imperial College London, Andreas Schuh"
COPYRIGHT "2013-2019 Imperial College London, Andreas Schuh"
LICENSE "Apache License Version 2.0"
CONTACT "Andreas Schuh <[email protected]>"
TEMPLATE "with-basis-submodule/1.0"
LANGUAGES C CXX-11
LANGUAGES C CXX-14

# --------------------------------------------------------------------------
# directories
Expand Down
12 changes: 4 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ============================================================================
# Medical Image Registration ToolKit (MIRTK)
#
# Copyright 2013-2016 Imperial College London
# Copyright 2013-2016 Andreas Schuh
# Copyright 2013-2019 Imperial College London
# Copyright 2013-2019 Andreas Schuh
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -26,7 +26,7 @@

# ----------------------------------------------------------------------------
# Minimum required CMake version
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
cmake_minimum_required(VERSION 3.4 FATAL_ERROR)

# ----------------------------------------------------------------------------
# Include BASIS policies, settings, macros, and functions
Expand Down Expand Up @@ -97,11 +97,7 @@ if (WITH_CCACHE)
message(STATUS "Using ccache for compilation of C++ code")
mark_as_advanced(CCACHE_COMMAND)
# For Unix Makefiles and Ninja generators
if (CMAKE_VERSION VERSION_LESS 3.4)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_COMMAND}")
else ()
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_COMMAND}")
endif ()
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_COMMAND}")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options("-Qunused-arguments")
endif ()
Expand Down
26 changes: 11 additions & 15 deletions Docker/Ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,38 @@
##
## https://hub.docker.com/r/biomedia/ubuntu/

FROM ubuntu:14.04
FROM ubuntu:18.04

MAINTAINER Andreas Schuh <[email protected]>
LABEL Maintainer="Andreas Schuh <[email protected]>"
LABEL Description="Ubuntu with prerequisits for MIRTK installed" Vendor="BioMedIA"

# No. of threads to use for build (--build-arg THREADS=8)
# By default, all available CPUs are used. When a Docker Machine is used,
# set the number of CPUs in the VirtualBox VM Settings.
ARG THREADS

# When VTK_VERSION='', the official libvtk6-dev package is used.
# When VTK_VERSION='', the official libvtk7-dev package is used.
# Note, however, that this results in a Docker image that is about twice
# the size of the image when a custom VTK build without Qt, wrappers,
# and unused VTK modules is used instead!
ARG VTK_VERSION=7.0.0
ARG VTK_VERSION=8.2.0

ARG EIGEN_VERSION=3.2.8
ARG EIGEN_VERSION=3.3.7

ARG CXX_STANDARD=c++14

# Install prerequisites for MIRTK build
#
# The bzindovic/suitesparse-bugfix-1319687 PPA is required for building
# shared libraries which link with the static SuiteSparse libraries due
# to a bug in the official Ubuntu package:
# https://bugs.launchpad.net/ubuntu/+source/suitesparse/+bug/1333214
RUN NUM_CPUS=${THREADS:-`cat /proc/cpuinfo | grep processor | wc -l`} \
&& echo "Maximum number of build threads = $NUM_CPUS" \
&& apt-get update && apt-get install -y --no-install-recommends \
software-properties-common \
&& add-apt-repository -y ppa:bzindovic/suitesparse-bugfix-1319687 \
&& apt-get update && apt-get install -y --no-install-recommends \
wget \
gcc \
g++ \
make \
cmake \
python \
python3 \
freeglut3-dev \
libarpack2-dev \
libboost-math-dev \
Expand Down Expand Up @@ -77,13 +73,13 @@ RUN NUM_CPUS=${THREADS:-`cat /proc/cpuinfo | grep processor | wc -l`} \
&& wget -O archive.tar.bz2 http://bitbucket.org/eigen/eigen/get/${EIGEN_VERSION}.tar.bz2 \
&& tar vxjf archive.tar.bz2 --strip 1 \
&& mv signature_of_eigen3_matrix_library Eigen /usr/include/eigen3/ \
&& mv cmake/FindEigen3.cmake /usr/share/cmake-2.8/Modules/ \
&& mv cmake/FindEigen3.cmake /usr/share/cmake-3.10/Modules/ \
&& cd /usr/src \
&& rm -rf ${EIGEN_SOURCE_DIR}; \
fi \
&& \
if [ -z ${VTK_VERSION} ]; then \
apt-get install -y libvtk6-dev; \
apt-get install -y libvtk7-dev; \
else \
VTK_RELEASE=`echo ${VTK_VERSION} | sed s/\.[0-9]*$//` \
&& cd /usr/src \
Expand All @@ -95,7 +91,7 @@ RUN NUM_CPUS=${THREADS:-`cat /proc/cpuinfo | grep processor | wc -l`} \
&& cmake \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_CXX_FLAGS=-std=c++11 \
-D CMAKE_CXX_STANDARD=${CXX_STANDARD} \
-D VTK_USE_SYSTEM_PNG=ON \
-D VTK_USE_SYSTEM_ZLIB=ON \
-D BUILD_SHARED_LIBS=ON \
Expand Down
17 changes: 9 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
## https://hub.docker.com/r/biomedia/mirtk/

# Pre-made Ubuntu system with all MIRTK dependencies installed
FROM biomedia/ubuntu:mirtk
FROM biomedia/ubuntu:18.04-mirtk

MAINTAINER Andreas Schuh <[email protected]>
LABEL Maintainer="Andreas Schuh <[email protected]>"
LABEL Description="Medical Image Registration ToolKit (MIRTK)" Vendor="BioMedIA"

# Git repository and commit SHA from which this Docker image was built
Expand All @@ -39,12 +39,12 @@ ARG THREADS
ARG BUILD_TESTING=OFF

# Build and install MIRTK
COPY . /usr/src/MIRTK
RUN ls /usr/src/MIRTK \
COPY . /usr/src/mirtk
RUN ls /usr/src/mirtk \
&& NUM_CPUS=${THREADS:-`cat /proc/cpuinfo | grep processor | wc -l`} \
&& echo "Maximum number of build threads = $NUM_CPUS" \
&& mkdir /usr/src/MIRTK/Build \
&& cd /usr/src/MIRTK/Build \
&& mkdir /usr/src/mirtk/Build \
&& cd /usr/src/mirtk/Build \
&& cmake \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D CMAKE_BUILD_TYPE=Release \
Expand All @@ -64,6 +64,7 @@ RUN ls /usr/src/MIRTK \
-D MODULE_DrawEM=ON \
-D MODULE_Mapping=ON \
-D MODULE_Scripting=ON \
-D MODULE_Viewer=ON \
-D WITH_ARPACK=ON \
-D WITH_FLANN=ON \
-D WITH_MATLAB=OFF \
Expand All @@ -78,10 +79,10 @@ RUN ls /usr/src/MIRTK \
&& if [ ${BUILD_TESTING} = ON ]; then make -j $NUM_CPUS && make test; fi \
&& make -j $NUM_CPUS install \
&& cd /usr/src \
&& rm -rf /usr/src/MIRTK
&& rm -rf /usr/src/mirtk

# Make "mirtk" the default executable for application containers
ENTRYPOINT ["python", "/usr/local/bin/mirtk"]
ENTRYPOINT ["python3", "/usr/local/bin/mirtk"]
CMD ["help"]

# Assume user data volume to be mounted at /data
Expand Down
2 changes: 1 addition & 1 deletion Documentation/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ the Cross-platform Make tool named CMake_ is needed. The minimum required versio
for Linux and OS X is 2.8.12, while version 3.4 or newer is needed on Windows.

For the compilation of the MIRTK source code, a C++ compiler with support for the
`C++11`_ standard is required. On Windows, the minimum required Visual Studio compiler
`C++14`_ standard is required. On Windows, the minimum required Visual Studio compiler
version is 18.0. A compatible compiler is shipped with Visual Studio 2013 or newer.
For Unix operation systems, we recommend the use of the `GNU Compiler Collection`_ (GCC).

Expand Down
33 changes: 30 additions & 3 deletions Scripts/install_depends.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ norm_option_value()
fi
}

CXX_STANDARD=c++14
TRAVIS=`norm_option_value "$TRAVIS" OFF`
TESTING=`norm_option_value "$TESTING" OFF`
WITH_ARPACK=`norm_option_value "$WITH_ARPACK" OFF`
Expand Down Expand Up @@ -65,6 +66,10 @@ if [ $os = linux ] || [ $os = Linux ]; then
[ $WITH_FLANN = OFF ] || deps=(${deps[@]} libflann-dev)
[ $WITH_ARPACK = OFF ] || deps=(${deps[@]} libarpack2-dev)

if [ -f /etc/lsb-release ]; then
source /etc/lsb-release
fi

if [ $WITH_UMFPACK = ON ]; then
# see https://bugs.launchpad.net/ubuntu/+source/suitesparse/+bug/1333214
# sudo add-apt-repository -y ppa:bzindovic/suitesparse-bugfix-1319687 || exit 1
Expand All @@ -75,9 +80,30 @@ if [ $os = linux ] || [ $os = Linux ]; then
if [ -n "$LINUX_VTK_VERSION" ]; then
VTK_VERSION="$LINUX_VTK_VERSION"
fi
if [ -z "$VTK_VERSION" ] || [ $VTK_VERSION = '6.0.0' ]; then
if [ "$DISTRIB_ID" = "Ubuntu" ]; then
if [ "$DISTRIB_CODENAME" = "trusty" ]; then
if [ -z "$VTK_VERSION" ] || [ $VTK_VERSION = '6.0.0' ]; then
deps=(${deps[@]} libvtk6-dev)
VTK_VERSION=''
fi
elif [ "$DISTRIB_CODENAME" = "xenial" ]; then
if [ -z "$VTK_VERSION" ] || [ $VTK_VERSION = '6.2.0' ]; then
deps=(${deps[@]} libvtk6-dev)
VTK_VERSION=''
fi
elif [ "$DISTRIB_CODENAME" = "bionic" ]; then
if [ $VTK_VERSION = '6.3.0' ]; then
deps=(${deps[@]} libvtk6-dev)
VTK_VERSION=''
elif [ -z "$VTK_VERSION" ] || [ $VTK_VERSION = '7.1.1' ]; then
deps=(${deps[@]} libvtk7-dev)
VTK_VERSION=''
fi
elif [ -z "$VTK_VERSION" ]; then
deps=(${deps[@]} libvtk7-dev)
fi
elif [ -z "$VTK_VERSION" ]; then
deps=(${deps[@]} libvtk6-dev)
VTK_VERSION=''
fi
if [ $WITH_FLTK = ON ]; then
deps=(${deps[@]} libxi-dev libxmu-dev libxinerama-dev libxcursor-dev libcairo-dev libfltk1.3-dev)
Expand Down Expand Up @@ -143,7 +169,7 @@ if [ $os = osx ] || [ $os = Darwin ]; then
run git clone --depth=1 https://github.com/google/googletest.git /tmp/gtest-source
mkdir /tmp/gtest-build && cd /tmp/gtest-build
[ $? -eq 0 ] || exit 1
run cmake -DCMAKE_CXX_FLAGS=-std=c++11 -DBUILD_GMOCK=OFF -DBUILD_GTEST=ON ../gtest-source
run cmake -DCMAKE_CXX_STANDARD=$CXX_STANDARD -DBUILD_GMOCK=OFF -DBUILD_GTEST=ON ../gtest-source
run make -j $cpu_cores
run sudo make install
cd || exit 1
Expand Down Expand Up @@ -195,6 +221,7 @@ if [ $WITH_VTK = ON ] && [ -n "$VTK_VERSION" ]; then
[ $? -eq 0 ] || exit 1
echo "Configuring VTK $VTK_VERSION..."
cmake_args=("${cmake_args[@]}"
-DCMAKE_CXX_STANDARD=$CXX_STANDARD
-DVTK_Group_StandAlone=OFF
-DVTK_Group_Rendering=OFF
-DModule_vtkCommonCore=ON
Expand Down

0 comments on commit 4714f88

Please sign in to comment.