-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·137 lines (113 loc) · 4.54 KB
/
Copy pathconfigure
File metadata and controls
executable file
·137 lines (113 loc) · 4.54 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
#!/usr/bin/env bash
CXX_STD=CXX17
ITKRCMAKE=`${R_HOME}/bin/Rscript -e 'a<-ITKR:::itkIncludes(); cat(a)'`
ITKRLIB=`${R_HOME}/bin/Rscript -e 'a<-ITKR:::itkLibs(); cat(a)'`
compflags=`${R_HOME}/bin/Rscript -e 'a<-ITKR:::itkCompileFlags(); cat(a)'`
osx_sysroot="" # for Macs, add this to cmake below
if [[ `uname` == 'Darwin' ]] ; then
osx_sysroot=$(xcrun --sdk macosx --show-sdk-path)
fi
ITKDIR=`${R_HOME}/bin/Rscript -e 'a<-ITKR:::itkDir(); cat(a)'`
ITKTAG=`${R_HOME}/bin/Rscript -e 'env = asNamespace("ITKR"); if ("itkTag" %in% names(env)) cat(ITKR::itkTag()) else cat("")'`
if [[ `uname` == 'Darwin' ]] ; then
CMAKE_BUILD_TYPE=Release
fi
if [[ $TRAVIS -eq true ]] ; then
CMAKE_BUILD_TYPE=Release
fi
gitcmd=`which git`
if [[ ! -x $gitcmd ]] ; then # try install git
apt-get install -y git-core
fi
gitcmd=`which git`
if [[ ! -x $gitcmd ]] ; then # try install git
exit 1
fi
cd ./src
# platform-specific Makevars
echo "myantssource=\${PWD}/ants" > Makevars
# echo "ITK = \`\$(R_HOME)/bin/Rscript -e 'ITKR:::itkIncludes()'\`" >> Makevars
echo "ITK=${ITKRCMAKE}" >> Makevars
needVCL_CAN_STATIC_CONST_INIT_FLOAT=0
if [[ ${#CC} -gt 0 ]] ; then # test the requested compiler
temp=$(${CC} --version | grep clang)
if [[ ${#temp} -gt 0 ]] ; then
needVCL_CAN_STATIC_CONST_INIT_FLOAT=1
fi
else # just try gcc directly
temp=$(gcc --version | grep clang)
if [[ ${#temp} -gt 0 ]] ; then
needVCL_CAN_STATIC_CONST_INIT_FLOAT=1
fi
fi
echo $OSTYPE $needVCL_CAN_STATIC_CONST_INIT_FLOAT
if [[ `uname` == 'Darwin' ]] ; then
PKG_CPPFLAGS="${PKG_CPPFLAGS} -isysroot ${osx_sysroot}"
fi
echo "PKG_CPPFLAGS=${PKG_CPPFLAGS} -I\${ITK} -I\${PWD} -I\${myantssource}/Examples/include/ \
-I\${myantssource}/Utilities -I\${myantssource}/Examples/ -I../inst/include/ \
-I\${myantssource}/Tensor/ " >> Makevars
echo "CXX_STD = CXX17" >> Makevars
# echo "myantslib=\${R_LIBS_USER}/libs/lib" >> Makevars
echo "myantslib=\${PWD}/antb/ANTS-build/Examples/" >> Makevars
echo "libants=\`find \${myantslib} -name \"lib*.a\"\`" >> Makevars
# echo "libitk=\`find \\\`\$(R_HOME)/bin/Rscript -e 'ITKR:::itkLibs()'\\\` -name \"lib*.a\"\` " >> Makevars
echo "libitk=\`find ${ITKRLIB} -name \"lib*.a\"\`" >> Makevars
echo "PKG_LIBS=${PKG_LIBS} \${libants} \${libitk} \${libants} \${libitk} \
\${libants} \${libitk} \${libants} \${libitk} \${libants} \${libitk}" >> Makevars
echo ".PHONY: all libs cleaner" >> Makevars
echo "all: \$(SHLIB)" >> Makevars
# echo "all: \$(CHECKER) \$(SHLIB)" >> Makevars
# echo "\$(CHECKER): ; @echo \"Myantssource is \${myantssource}\" && @echo \"PWD is \${PWD}\" && @echo \"ITK is \${ITK}\"" >> Makevars
echo "\$(SHLIB): libs " >> Makevars
echo "libs: ; cd \${PWD}/antb && \$(MAKE) -j 2 && cd \${PWD}/antb/ANTS-build && \$(MAKE) all install && rm -rf ${R_PACKAGE_DIR}/libs/bin && cd \${PWD}" >> Makevars
echo "cleaner: ; cd libs/bin && rm -f antsRegistration antsApplyTransforms antsMotionCorr \
antsAffineInitializer antsApplyTransformsToPoints LabelGeometryMeasures \
antsMotionCorrStats ResampleImage Atropos KellyKapowski DenoiseImage \
N3BiasFieldCorrection N4BiasFieldCorrection sccan antsJointFusion \
ThresholdImage LabelClustersUniquely SurfaceBasedSmoothing" >> Makevars
# get / set up ANTs code
antsgit=https://github.com/ANTsX/ANTs.git
antstag=516d24180390dd3bb18c6a507bc1651b5a183b85 # 2025-05-09 PPD in aat
antsrtag=`git log --pretty=format:'%H' -n 1`
if [[ ! -s ants/CMakeLists.txt ]] ; then
git clone $antsbranch $antsgit ants
fi
#if [[ ! -d ../data/ ]] ; then
# mkdir -p ../data
#fi
cd ants
if [[ -d .git ]]; then
git checkout master
git pull
git checkout $antstag
fi
cd ../
if [[ ! -s antb ]] ; then
mkdir antb
fi
cp ../inst/include/antscore.h ./ants/Examples/include/ants.h
cp -r ants/Examples/include/* ../inst/include/
cp -r ants/Utilities/* ../inst/include/
cp -r ants/Examples/* ../inst/include/
cp -r ants/Tensor/* ../inst/include/
cp -r ants/ImageRegistration/* ../inst/include/
cp -r ants/ImageSegmentation/* ../inst/include/
cp -r ants/Temporary/* ../inst/include
rm -f ants/CITATION.bib
cd ./antb
cmake -DITK_DIR:PATH=${ITKDIR} \
-DCMAKE_C_FLAGS="${CMAKE_C_FLAGS} ${compflags} -DNDEBUG "\
-DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} ${compflags} -DNDEBUG "\
-DCMAKE_OSX_SYSROOT="${osx_sysroot}" \
-DBUILD_SHARED_LIBS=OFF \
-DANTS_INSTALL_LIBS_ONLY=ON \
-DBUILD_ALL_ANTS_APPS=OFF \
-DUSE_SYSTEM_ITK=OFF \
-DBUILD_TESTING=OFF \
-DCOPY_SCRIPT_FILES_TO_BIN_DIR=OFF \
-DCMAKE_INSTALL_PREFIX:PATH=${R_PACKAGE_DIR}/libs/ \
-DCMAKE_BUILD_TYPE:STRING="${CMAKE_BUILD_TYPE}" ../ants
cd ../
# needed for warning
rm -rf ants/.git