-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAutoCompileLatestITK.script
More file actions
executable file
·153 lines (152 loc) · 4.18 KB
/
AutoCompileLatestITK.script
File metadata and controls
executable file
·153 lines (152 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
if [ $# != 3 ] && [ $# != 5 ]
then
echo "Usage: $0 ITKSourceRootDir ITKInstallRootDir [VTKSourceRootDir VTKInstallRootDir] ON/OFF"
echo "ON/OFF: Build shared libraries"
exit 2
fi
ITKSourceRootDir=$1
echo "ITKSourceRootDir: $ITKSourceRootDir"
ITKInstallRootDir=$2
echo "ITKInstallRootDir: $ITKInstallRootDir"
scriptDIR="$( cd "$( dirname "$0" )" && pwd )"
if [ ! -e "$scriptDIR/ConfigurationVariables.script" ]
then
echo "ConfigurationVariables.script not found. It should be there:"
echo "$scriptDIR/ConfigurationVariables.script"
exit 1
fi
source $scriptDIR/ConfigurationVariables.script
if [ ! -e "$scriptDIR/../Resources/CompileEnvironment.script" ]
then
echo "CompileEnvironment.script not found. It should be there:"
echo "$scriptDIR/../Resources/CompileEnvironment.script"
exit 1
fi
source $scriptDIR/../Resources/CompileEnvironment.script
currentDir=`pwd`
echo "Current directory: ${currentDir}"
#Check if VTK directories are specified
if [ $# == 5 ]
then
VTKSourceRootDir="$3"
echo "VTKSourceRootDir: $VTKSourceRootDir"
VTKInstallRootDir="$4"
echo "VTKInstallRootDir: $VTKInstallRootDir"
itkVTKGlueOption="-DModule_ITKVtkGlue:BOOL=ON "
#Check VTK tag
VTKSourceDir=VTK-Auto
cd $VTKSourceRootDir/$VTKSourceDir
#get last tag
tag=`git describe --abbrev=0 --tags`
echo "Last tag (VTK): $tag"
VTKtagNum=${tag#"v"}
echo "Last tag #(VTK): $VTKtagNum"
#If Release Candidate, do nothing
if [ "`echo $tag |grep rc`" != "" ]
then
echo "Current latest tag is a release candidate"
exit 1
fi
#If tag is not already compiled on the system, exit
#ITK needs VTK if VTK options are given
VTKInstallDir=$VTKInstallRootDir/VTK_$VTKtagNum
if [ ! -d $VTKInstallDir ]
then
echo "VTK tag ($tag) is not compiled. You requested to build ITK with VTK."
exit 3
fi
tagMinor=${VTKtagNum:0:3}
echo "VTK Tag# Major.Minor: $tagMinor"
#Build ITK either in shared or static libraries
shared=$5
else
itkVTKGlueOption=""
#Build ITK either in shared or static libraries
shared=$3
fi
#Download ITK
ITKSourceDir=ITK-Auto
cd $ITKSourceRootDir
if [ ! -d $ITKSourceDir ]
then
git clone http://itk.org/ITK.git $ITKSourceDir
cd $ITKSourceDir
else
cd $ITKSourceDir
git fetch --all
git reset --hard origin/master
fi
#get last tag
tag=`git describe --abbrev=0 --tags`
echo "Last tag: $tag"
#If Release Candidate, do not compile
if [ "`echo $tag |grep rc`" != "" ]
then
echo "Current latest tag is a release candidate"
exit 1
fi
#Build ITK either in shared or static libraries
echo "Shared: $shared"
if [ $shared == ON ]
then
suff="dyn"
else
suff="stat"
fi
echo "Suffix: $suff"
#Find VTK Config Dir
if [ $# == 5 ]
then
VTKConfigDIR=`find $VTKInstallDir -name VTK_${VTKtagNum}_linux64_${suff}\*_Release`
VTKConfigDIR=${VTKConfigDIR}/lib/cmake/vtk-${tagMinor}
echo "VTKConfigDir=$VTKConfigDIR"
fi
#If tag is already compiled on the system, do not compile
git checkout tags/$tag
ITKInstallDir=$ITKInstallRootDir/ITK$tag/ITK${tag}_THL64_${suff}_${CMAKE_BUILD_TYPE}
echo "Install Dir: $ITKInstallDir"
if [ -d $ITKInstallDir ]
then
echo "ITK tag ($tag) already compiled"
exit 1
fi
tagNum=${tag#"v"}
echo "Tag#: $tagNum"
echo "cmake: ${CMAKE}"
echo "Build testing: ${BUILD_TESTING}"
echo "cmake_build_type: ${CMAKE_BUILD_TYPE}"
nbThreads=8
echo "#Threads: ${nbThreads}"
#Check if build directory exists.
#Removes if and recreate it
ITKBuildDir=$ITKSourceRootDir/InsightToolkit-Auto-${tagNum}-build
echo "ITK Build Directory: $ITKBuildDir"
if [ $ITKBuildDir ]
then
rm -rf $ITKBuildDir
fi
mkdir $ITKBuildDir
cd $ITKBuildDir
#Configure ITK
echo "Configure ITK"
CC=$CC CXX=$CXX $CMAKE \
-DBUILD_TESTING:BOOL=${BUILD_TESTING} \
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} \
-DCMAKE_INSTALL_PREFIX:PATH=$ITKInstallDir \
-DBUILD_SHARED_LIBS:BOOL=$shared \
-DModule_ITKIODCMTK:BOOL=ON \
-DModule_ITKIOPhilipsREC=ON \
-DModule_ITKIOMINC=ON \
-DModule_MGHIO:BOOL=ON \
-DITKV3_COMPATIBILITY:BOOL=OFF \
-DModule_ITKReview:BOOL=ON \
-DVTK_DIR:PATH=${VTKConfigDIR} \
${itkVTKGlueOption} \
../$ITKSourceDir
#Compile and install ITK
echo "Compilation"
make -j ${nbThreads}
make install -j ${nbThreads}
cd $currentDir
exit 0