-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure
executable file
·92 lines (81 loc) · 1.91 KB
/
configure
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
#!/bin/sh
set -e
PREFIX=$PWD/local
CUDA_HOME=/usr/local/cuda
BUILD_EXAMPLES=0
BUILD_CUDA_EXAMPLES=0
BUILD_TESTS=0
BUILD_BENCHMARKS=0
VERBOSE=0
parse_args() {
for i in "$@"; do
case $i in
--prefix=*)
PREFIX="${i#*=}"
;;
--examples)
BUILD_EXAMPLES=1
;;
--cuda-examples)
BUILD_CUDA_EXAMPLES=1
;;
--tests)
BUILD_TESTS=1
;;
--benchmarks)
BUILD_BENCHMARKS=1
;;
--deb)
BUILD_DEB=1
;;
--verbose)
VERBOSE=1
;;
*)
echo "unknown argument $i"
exit 1
;;
esac
done
}
CMAKE_FLAGS=
add_cmake_flag() {
echo "Using $1=$2"
CMAKE_FLAGS="$CMAKE_FLAGS -D$1=$2"
}
add_cmake_flags() {
add_cmake_flag CMAKE_INSTALL_PREFIX ${PREFIX}
add_cmake_flag CMAKE_BUILD_TYPE Release
add_cmake_flag CMAKE_EXPORT_COMPILE_COMMANDS ${VERBOSE}
add_cmake_flag CMAKE_VERBOSE_MAKEFILE ${VERBOSE}
add_cmake_flag BUILD_BENCHMARKS ${BUILD_BENCHMARKS}
add_cmake_flag BUILD_CUDA_EXAMPLES ${BUILD_CUDA_EXAMPLES}
add_cmake_flag BUILD_EXAMPLES ${BUILD_EXAMPLES}
add_cmake_flag BUILD_TESTS ${BUILD_TESTS}
if [ "$BUILD_DEB" = 1 ]; then
add_cmake_flag BUILD_DEB $BUILD_DEB
fi
if [ ${BUILD_CUDA_EXAMPLES} -eq 1 ]; then
add_cmake_flag CMAKE_CUDA_COMPILER $CUDA_HOME/bin/nvcc
add_cmake_flag CUDA_TOOLKIT_ROOT_DIR $CUDA_HOME
fi
if [ ! -z ${GTEST_GIT_URL} ]; then
add_cmake_flag GTEST_GIT_URL ${GTEST_GIT_URL}
fi
}
build='.build'
gen_make() {
echo "build:"
echo "\t\$(MAKE) -C $build"
echo "install: build"
echo "\t\$(MAKE) -C $build install"
echo "%:"
echo "\t\$(MAKE) -C $build \$@"
}
W=$PWD
parse_args $@
add_cmake_flags
mkdir -p $build
cd $build
cmake $W ${CMAKE_FLAGS}
gen_make >$W/Makefile