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