-
Notifications
You must be signed in to change notification settings - Fork 449
/
buildURDF.sh
153 lines (125 loc) · 5.55 KB
/
buildURDF.sh
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
153
#!/bin/bash
# -------------------------------------------------------------------------------------------------------
# Bash script for building and installing URDF parser dependencies
# - Place in an arbitrary temporary directory.
# - Specify the locations for the URDF sources OR indicate that these should be downloaded.
# - Specify the install directory.
# - Run the script (sh ./buildURDF.sh).
# - The install directory will contain subdirectories for all necessary dependencies.
#
# Notes:
# - The script accepts 1 optional argument to override the install directory.
# -------------------------------------------------------------------------------------------------------
DOWNLOAD=ON
URDF_INSTALL_DIR="$HOME/Packages/urdf"
BUILDDEBUG=OFF
BUILDSYSTEM="Ninja Multi-Config"
if [ ${DOWNLOAD} = OFF ]
then
TINYXML2_SOURCE_DIR="$HOME/Sources/tinyxml2"
CONSOLE_BRIDGE_SOURCE_DIR="$HOME/Sources/console_bridge"
URDFDOM_HEADERS_SOURCE_DIR="$HOME/Sources/urdfdom_headers"
URDFDOM_SOURCE_DIR="$HOME/Sources/urdfdom"
fi
# ------------------------------------------------------------------------
# Allow overriding installation directory through command line argument
if [ $# -eq 1 ]
then
URDF_INSTALL_DIR=$1
fi
# ------------------------------------------------------------------------
if [ ${DOWNLOAD} = ON ]
then
echo "Download sources from GitHub"
rm -rf download_urdf
mkdir download_urdf
echo " ... tinyxml2"
git clone "https://github.com/leethomason/tinyxml2.git" "download_urdf/tinyxml2"
TINYXML2_SOURCE_DIR="download_urdf/tinyxml2"
echo " ... console_bridge"
git clone "https://github.com/ros/console_bridge.git" "download_urdf/console_bridge"
CONSOLE_BRIDGE_SOURCE_DIR="download_urdf/console_bridge"
echo " ... urdfdom_headers"
git clone "https://github.com/ros/urdfdom_headers.git" "download_urdf/urdfdom_headers"
URDFDOM_HEADERS_SOURCE_DIR="download_urdf/urdfdom_headers"
echo " ... urdfdom"
git clone "https://github.com/ros/urdfdom.git" "download_urdf/urdfdom"
URDFDOM_SOURCE_DIR="download_urdf/urdfdom"
else
echo "Using provided source directories"
fi
echo -e "\nSources in:"
echo " " ${TINYXML2_SOURCE_DIR}
echo " " ${CONSOLE_BRIDGE_SOURCE_DIR}
echo " " ${URDFDOM_HEADERS_SOURCE_DIR}
echo " " ${URDFDOM_SOURCE_DIR}
# ------------------------------------------------------------------------
rm -rf ${URDF_INSTALL_DIR}
mkdir ${URDF_INSTALL_DIR}
# --- tinyxml2 -------------------------------------------------------------
#
# Note that tinixml2 cannot be built with "Ninja Multi-Config".
# Only configure and build a Release tinixml2 library.
# Pass "-fPIC" to allow linking in a shared library.
#
echo -e "\n------------------------ Configure tinyxml2\n"
rm -rf build_tinyxml2
cmake -E env CXXFLAGS="-fPIC" cmake -G "Ninja" -B build_tinyxml2 -S ${TINYXML2_SOURCE_DIR} \
-DCMAKE_BUILD_TYPE="Release" \
-Dtinyxml2_INSTALL_CMAKEDIR:PATH="CMake"
echo -e "\n------------------------ Build and install tinyxml2\n"
cmake --build build_tinyxml2
cmake --install build_tinyxml2 --prefix ${URDF_INSTALL_DIR}
# --- console_bridge ----------------------------------------------------------------
echo -e "\n------------------------ Configure console_bridge\n"
rm -rf build_console_bridge
cmake -G "${BUILDSYSTEM}" -B build_console_bridge -S ${CONSOLE_BRIDGE_SOURCE_DIR} \
-DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_DEBUG_POSTFIX=_d \
-DCMAKE_RELWITHDEBINFO_POSTFIX=_rd
echo -e "\n------------------------ Build and install console_bridge\n"
cmake --build build_console_bridge --config Release
cmake --install build_console_bridge --config Release --prefix ${URDF_INSTALL_DIR}
if [ ${BUILDDEBUG} = ON ]
then
cmake --build build_console_bridge --config Debug
cmake --install build_console_bridge --config Debug --prefix ${URDF_INSTALL_DIR}
else
echo "No Debug build of console_bridge"
fi
# --- urdfdom_headers ---------------------------------------------------------
echo -e "\n------------------------ Configure urdfdom_headers\n"
rm -rf build_urdfdom_headers
cmake -G "${BUILDSYSTEM}" -B build_urdfdom_headers -S ${URDFDOM_HEADERS_SOURCE_DIR} \
-DCMAKE_DEBUG_POSTFIX=_d \
-DCMAKE_RELWITHDEBINFO_POSTFIX=_rd
echo -e "\n------------------------ Build and install urdfdom_headers\n"
cmake --build build_urdfdom_headers --config Release
cmake --install build_urdfdom_headers --config Release --prefix ${URDF_INSTALL_DIR}
if [ ${BUILDDEBUG} = ON ]
then
cmake --build build_urdfdom_headers --config Debug
cmake --install build_urdfdom_headers --config Debug --prefix ${URDF_INSTALL_DIR}
else
echo "No Debug build of urdfdom_headers"
fi
# --- urdfdom -----------------------------------------------------------
echo -e "\n------------------------ Configure urdfdom\n"
rm -rf build_urdfdom
cmake -G "${BUILDSYSTEM}" -B build_urdfdom -S ${URDFDOM_SOURCE_DIR} \
-DCMAKE_DEBUG_POSTFIX=_d \
-DCMAKE_RELWITHDEBINFO_POSTFIX=_rd \
-Dconsole_bridge_DIR:PATH=${URDF_INSTALL_DIR}/lib/console_bridge/cmake \
-Durdfdom_headers_DIR:PATH=${URDF_INSTALL_DIR}/lib/urdfdom_headers/cmake \
-DTINYXML2_INCLUDE_DIR:PATH=${URDF_INSTALL_DIR}/include \
-DTinyXML2_DIR:PATH=${URDF_INSTALL_DIR}/CMake
echo -e "\n------------------------ Build and install urdfdom\n"
cmake --build build_urdfdom --config Release
cmake --install build_urdfdom --config Release --prefix ${URDF_INSTALL_DIR}
if [ ${BUILDDEBUG} = ON ]
then
cmake --build build_urdfdom --config Debug
cmake --install build_urdfdom --config Debug --prefix ${URDF_INSTALL_DIR}
else
echo "No Debug build of urdfdom"
fi