-
Notifications
You must be signed in to change notification settings - Fork 36
/
configure
executable file
·83 lines (70 loc) · 1.8 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
#!/bin/sh
set -e
. ./auto/cmake
CUDA_HOME=/usr/local/cuda
CUDA_ARCHITECTURES="61" # FIXME: detect
HAVE_CUDA=0
if [ -f $CUDA_HOME/include/cuda_runtime.h ]; then
HAVE_CUDA=1
fi
ENABLE_CUDA=${HAVE_CUDA}
BUILD_TORCH_EXTENSION=1 # FIXME: disable by default
parse_args() {
for i in "$@"; do
case $i in
--enable-trace)
ENABLE_TRACE=1
;;
--enable-torch)
BUILD_TORCH_EXTENSION=1
;;
--lib)
BUILD_LIB=1
;;
--tests)
BUILD_TESTS=1
;;
--benchmarks)
BUILD_BENCHMARKS=1
;;
-v)
VERBOSE=1
;;
*)
echo "unknown argument $i"
exit 1
;;
esac
done
}
config() {
PYTHON=$(which python3)
mkdir -p srcs/cmake/generated
$PYTHON ./srcs/config/config.py >srcs/cmake/generated/torch.cmake
cat srcs/cmake/generated/torch.cmake
}
add_cmake_prefixes() {
add_cmake_prefix $HOME/local/gtest
}
add_cmake_flags() {
if [ ${ENABLE_CUDA} -eq 1 ]; then
add_cmake_flag ENABLE_CUDA ${ENABLE_CUDA}
add_cmake_flag CUDA_TOOLKIT_ROOT_DIR $CUDA_HOME
add_cmake_flag CMAKE_CUDA_COMPILER $CUDA_HOME/bin/nvcc
fi
add_cmake_flag BUILD_TORCH_EXTENSION ${BUILD_TORCH_EXTENSION}
add_cmake_flag BUILD_LIB ${BUILD_LIB}
add_cmake_flag BUILD_TESTS ${BUILD_TESTS}
add_cmake_flag BUILD_BENCHMARKS ${BUILD_TESTS}
add_cmake_flag CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}
add_cmake_flag QUIVER_ENABLE_TRACE $ENABLE_TRACE
add_cmake_flag CMAKE_VERBOSE_MAKEFILE ${VERBOSE}
add_cmake_flag CMAKE_EXPORT_COMPILE_COMMANDS ${VERBOSE}
add_cmake_flag CUDA_ARCHITECTURES ${CUDA_ARCHITECTURES}
}
main() {
config
parse_args $@
config_cmake
}
main $@