-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure.sh
executable file
·77 lines (68 loc) · 1.7 KB
/
configure.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
#!/bin/sh
usage="\
Usage: $0 [OPTION]...
--builddir The build directory
--debug Build with symbols
"
append_cache_entry () {
CMakeCacheEntries="$CMakeCacheEntries -D $1:$2=$3"
}
# set defaults
tool=cmake
sourcedir="$( cd "$( dirname "$0" )" && pwd )"
builddir=build
buildtype=Release
CMakeCacheEntries=""
# parse arguments
while [ $# -ne 0 ]; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case "$1" in
--help|-h)
echo "${usage}" 1>&2
exit 1
;;
--builddir=*)
builddir=$optarg
;;
--define=*)
CMakeCacheEntries="$CMakeCacheEntries -D$optarg"
;;
--debug)
buildtype=Debug
;;
--debugrelease)
buildtype=RelWithDebInfo
;;
--prefix=*)
append_cache_entry CMAKE_INSTALL_PREFIX PATH $optarg
;;
--test)
append_cache_entry ENABLE_TESTS BOOL true
;;
*)
echo "Invalid option '$1'. Try $0 --help to see available options."
exit 1
;;
esac
shift
done
if [ -d $builddir ]; then
# If build directory exists, check if it has a CMake cache
if [ -f $builddir/CMakeCache.txt ]; then
# If the CMake cache exists, delete it so that this configuration
# is not tainted by a previous one
rm -f $builddir/CMakeCache.txt
fi
else
# Create build directory
mkdir -p $builddir
fi
echo "Build Directory : $builddir"
echo "Source Directory: $sourcedir"
cd $builddir
$tool \
-DCMAKE_BUILD_TYPE="$buildtype" \
$CMakeCacheEntries "$sourcedir"