18 echo "An error occurred. Exiting..." >&2
25 ## -- Download function
30 sum=`dirname $file`/sum.txt
31 mkdir -p `dirname $file`
32 if [ ! -f $sum ] ; then
33 echo >&2 "*** Receiving $url ***"
35 if [ -f $file ] ; then
41 ## -- Decompress function
45 if [ -f $file ] ; then
46 echo >&2 "*** Decompressing $file ***"
47 mkdir -p `dirname $file`/src
48 mkdir -p `dirname $file`/bin
49 tar xf $file -C `dirname $file`/src --strip-components=1
56 if [[ "$platform" == 'Darwin' ]]; then
60 ## -- Download information
61 boost_url="https://downloads.sourceforge.net/project/boost/boost/$boost_version/boost_`echo $boost_version | sed 's/\./\_/g'`.tar.bz2"
62 qt5_short_version=`echo $qt5_version | sed 's/\.[^.]*$//'`
63 qt5_url="https://download.qt.io/official_releases/qt/$qt5_short_version/$qt5_version/submodules/qtbase-opensource-src-$qt5_version.tar.xz"
64 qt5extras_url="https://download.qt.io/official_releases/qt/$qt5_short_version/$qt5_version/submodules/qt${qt5extras_id}extras-opensource-src-$qt5_version.tar.xz"
65 qt5tools_url="https://download.qt.io/official_releases/qt/$qt5_short_version/$qt5_version/submodules/qttools-opensource-src-$qt5_version.tar.xz"
66 cmake_short_version=`echo $cmake_version | sed 's/\.[^.]*$//'`
67 cmake_url="https://www.cmake.org/files/v$cmake_short_version/cmake-$cmake_version.tar.gz"
68 vtk_short_version=`echo $vtk_version | sed 's/\.[^.]*$//'`
69 vtk_url="https://www.vtk.org/files/release/$vtk_short_version/VTK-$vtk_version.tar.gz"
70 itk_short_version=`echo $itk_version | sed 's/\.[^.]*$//'`
71 itk_url="https://downloads.sourceforge.net/project/itk/itk/$itk_short_version/InsightToolkit-$itk_version.tar.xz"
73 ## -- Command line options
74 while [[ "$#" -gt 1 ]]; do
96 ## -- Check command line options
98 [ -z "$prefix" ] ; then
99 (>&2 echo "Usage: $0 -prefix [dir] [-build_dir [dir]] [-cores [n]]")
103 ## -- Complete optional parameters
104 if [ -z "$cores" ] ; then
107 if [ -z "$build_dir" ] ; then
108 build_dir="$HOME/.tmp"
113 download $build_dir/boost/boost.tar.bz2 $boost_url
114 download $build_dir/qt5/qt5.tar.xz $qt5_url
115 download $build_dir/qt5extras/qt5extras.tar.xz $qt5extras_url
116 download $build_dir/qt5tools/qt5tools.tar.xz $qt5tools_url
117 download $build_dir/cmake/cmake.tar.gz $cmake_url
118 download $build_dir/vtk/vtk.tar.gz $vtk_url
119 download $build_dir/itk/itk.tar.xz $itk_url
121 ## -- Decompress files
122 decompress $build_dir/boost/boost.tar.bz2
123 decompress $build_dir/qt5/qt5.tar.xz
124 decompress $build_dir/qt5extras/qt5extras.tar.xz
125 decompress $build_dir/qt5tools/qt5tools.tar.xz
126 decompress $build_dir/cmake/cmake.tar.gz
127 decompress $build_dir/vtk/vtk.tar.gz
128 decompress $build_dir/itk/itk.tar.xz
130 ## -- Configure, build and install boost
131 cd $build_dir/boost/src
133 ./b2 -a -q -j $cores \
135 cxxflags="-std=c++11" \
139 ## -- Configure, build and install Qt5
140 cd $build_dir/qt5/bin
141 $build_dir/qt5/src/configure \
142 -prefix $prefix -shared -confirm-license -opensource -release \
143 -c++std c++11 -opengl desktop \
144 -nomake examples -nomake tests -no-harfbuzz \
145 -qt-xcb -qt-xkbcommon -qt-pcre
149 ## -- Configure, build and install Qt5Extras
150 cd $build_dir/qt5extras/bin
151 $prefix/bin/qmake $build_dir/qt5extras/src
155 ## -- Configure, build and install Qt5Tools
156 cd $build_dir/qt5tools/bin
157 $prefix/bin/qmake $build_dir/qt5tools/src
161 ## -- Configure, build and install CMake
162 cd $build_dir/cmake/bin
163 $build_dir/cmake/src/bootstrap --parallel=$cores --prefix=$prefix --no-qt-gui
167 ## -- Configure, build and install VTK
168 cd $build_dir/vtk/bin
170 -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
171 -DVTK_USE_CXX11_FEATURES:BOOL=ON \
172 -DBUILD_SHARED_LIBS:BOOL=ON \
173 -DCMAKE_BUILD_TYPE:STRING=Release \
174 -DCMAKE_INSTALL_PREFIX:PATH=$prefix \
175 -DBUILD_DOCUMENTATION:BOOL=OFF \
176 -DBUILD_EXAMPLES:BOOL=OFF \
177 -DBUILD_TESTING:BOOL=OFF \
178 -DVTK_Group_Qt:BOOL=ON \
179 -DVTK_QT_VERSION:STRING=5 \
180 -DQt5_DIR:PATH=$prefix/lib/cmake/Qt5 \
181 -DVTK_Group_Qt:BOOL=ON \
182 -DCMAKE_MACOSX_RPATH:BOOL=ON \
185 use_vtk=`make -j -k -s install | grep UseVTK | sed 's/.*: //'`
187 ## -- Configure, build and install VTK
188 cd $build_dir/itk/bin
190 -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
191 -DBUILD_SHARED_LIBS:BOOL=ON \
192 -DCMAKE_BUILD_TYPE:STRING=Release \
193 -DCMAKE_INSTALL_PREFIX:PATH=$prefix \
194 -DBUILD_DOCUMENTATION:BOOL=OFF \
195 -DBUILD_EXAMPLES:BOOL=OFF \
196 -DBUILD_TESTING:BOOL=OFF \
197 -DVTK_DIR:PATH=`dirname $use_vtk` \
198 -DModule_ITKReview:BOOL=ON \
199 -DModule_ITKVtkGlue:BOOL=ON \
200 -DCMAKE_MACOSX_RPATH:BOOL=ON \