]> Creatis software - cpPlugins.git/blob - third_party_installers/cpPlugins_Install_VTK.sh
59c3b8afbc5326e4634037f974739307a3d577ff
[cpPlugins.git] / third_party_installers / cpPlugins_Install_VTK.sh
1 #!/bin/bash
2
3 ## Some configuration variables
4 number_of_processes="-j4"
5
6 ## Locate cmake executable
7 cmake_exec="/usr/bin/cmake"
8 if [ ! -x $cmake_exec ]; then
9     cmake_exec="/usr/local/bin/cmake"
10 fi
11 if [ ! -x $cmake_exec ]; then
12     cmake_exec="${HOME}/local/bin/cmake"
13 fi
14 if [ ! -x $cmake_exec ]; then
15     echo "$0: modify this script to put the correct location of cmake."
16     exit 1
17 fi
18
19 ## Locate qmake executable
20 cmake_exec="/usr/bin/qmake"
21 if [ ! -x $cmake_exec ]; then
22     cmake_exec="/usr/local/bin/qmake"
23 fi
24 if [ ! -x $cmake_exec ]; then
25     cmake_exec="${HOME}/local/bin/qmake"
26 fi
27 if [ ! -x $cmake_exec ]; then
28     echo "$0: modify this script to put the correct location of qmake."
29     exit 1
30 fi
31
32 ## Check input parameters and process inputs (if needed)
33 if [ "$#" -eq 1 ]; then
34     valid_extensions=("zip" "tar" "tar.gz" "tar.bz2")
35     actual_ext=""
36     for ext in ${valid_extensions[@]}; do
37         if [ `basename $1 $ext` != $1 ]; then
38             actual_ext=$ext
39         fi
40     done
41     if [ "x$actual_ext" == "x" ]; then
42         echo "$0: Invalid file type."
43         exit 1
44     fi
45     canonical_path=`readlink -e $1`
46     source_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`
47     build_dir=`dirname $canonical_path`/`basename $1 .$actual_ext`-build
48     echo -n "Cleaning directories... "
49     rm -rf $source_dir
50     rm -rf $build_dir
51     echo "done."
52     echo -n "Creating directories... "
53     mkdir -p $source_dir
54     mkdir -p $build_dir
55     echo "done."
56     echo -n "Extracting sources... "
57     if [ "$actual_ext" == "zip" ]; then
58         echo unzip $canonical_path
59     elif [ "$actual_ext" == "tar" ]; then
60         tar xf $canonical_path -C $source_dir --strip-components=1
61     elif [ "$actual_ext" == "tar.gz" ]; then
62         tar xzf $canonical_path -C $source_dir --strip-components=1
63     elif [ "$actual_ext" == "tar.bz2" ]; then
64         tar xjf $canonical_path -C $source_dir --strip-components=1
65     else
66         echo "$0: Invalid file type."
67         exit 1
68     fi
69     echo "done!"
70 elif [ "$#" -eq 2 ]; then
71     source_dir=`dirname $1`
72     build_dir=`dirname $2`
73 else
74     echo "Usage: [vtk_package] or [vtk_source_dir vtk_build_dir]" 
75 fi
76
77 echo "Given source dir : \"$source_dir\""
78 echo "Given build dir  : \"$build_dir\""
79
80 echo "Configuring sources... "
81 cd $build_dir
82 $cmake_exec \
83     -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \
84     -DBUILD_DOCUMENTATION:BOOL=OFF \
85     -DBUILD_EXAMPLES:BOOL=OFF \
86     -DBUILD_SHARED_LIBS:BOOL=ON \
87     -DBUILD_TESTING:BOOL=OFF \
88     -DCMAKE_BUILD_TYPE:STRING=MinSizeRel \
89     -DModule_vtkGUISupportQt:BOOL=ON \
90     -DModule_vtkGUISupportQtOpenGL:BOOL=ON \
91     -DModule_vtkGUISupportQtSQL:BOOL=OFF \
92     -DModule_vtkGUISupportQtWebkit:BOOL=OFF \
93     -DCMAKE_INSTALL_PREFIX:PATH=${HOME}/local \
94     ${source_dir}
95 echo "Configuring sources... done."
96
97 echo "Compiling sources..."
98 cd $build_dir
99 make $number_of_processes
100 echo "Compiling sources... done."
101
102 echo "Installing package..."
103 cd $build_dir
104 make -j install
105 echo "Installing package... done."
106
107 ## eof - $RCSfile$