-
Notifications
You must be signed in to change notification settings - Fork 1
/
config
executable file
·82 lines (73 loc) · 2 KB
/
config
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
#!/bin/bash
function print_prompt
{
cat << CONFEOF
Usage: $0 [OPTION]... [VAR=VALUE]...
Configuration:
--help display this help and exit
--debug build for debug
--build-test build test programs
--build-dir=DIR build directory
--prefix=PREFIX install prefix
--cmake-modules=DIR directory of cmake modules file exist
--find-root-path=DIR root dir for search dependencies libs
Dependencies:
--gtest=DIR specify gtest install dir
Cross Compile:
--toolchain=DIR toolchain install dir
--cross-prefix=PREFIX compiler name prefix
CONFEOF
}
builddir="build"
cmake_modules_dir="cmake"
CMAKE_ARGS=
for conf_opt
do
case $conf_opt in
*=?*) conf_optarg=`expr "X$conf_opt" : '[^=]*=\(.*\)'` ;;
*) conf_optarg= ;;
esac
case $conf_opt in
--help)
print_prompt
exit 0
;;
--debug)
CMAKE_ARGS=(${CMAKE_ARGS[@]} -DBUILD_DEBUG=ON)
;;
--build-test)
CMAKE_ARGS=(${CMAKE_ARGS[@]} -DBUILD_TEST=ON)
;;
--build-dir=*)
builddir=$conf_optarg
;;
--prefix=*)
CMAKE_ARGS=(${CMAKE_ARGS[@]} -DCMAKE_INSTALL_PREFIX=$conf_optarg)
;;
--cmake-modules=*)
cmake_modules_dir=$conf_optarg
;;
--gtest=*)
CMAKE_ARGS=(${CMAKE_ARGS[@]} -DgtestPrefix=$conf_optarg)
;;
--toolchain=*)
CMAKE_ARGS=(${CMAKE_ARGS[@]} -DTOOLCHAIN_HOME=$conf_optarg)
CROSS_COMPILE=yes
;;
--cross-prefix=*)
CMAKE_ARGS=(${CMAKE_ARGS[@]} -DCROSS_PREFIX=$conf_optarg)
;;
--find-root-path=*)
CMAKE_ARGS=(${CMAKE_ARGS[@]} -DCMAKE_FIND_ROOT_PATH=$conf_optarg)
;;
esac
done
CMAKE_ARGS=(${CMAKE_ARGS[@]} -DCUSTOM_CMAKE_MODULES=$cmake_modules_dir)
CUR_DIR=`pwd`
if [ x$CROSS_COMPILE = x"yes" ]; then
CMAKE_ARGS=(${CMAKE_ARGS[@]} -DCMAKE_TOOLCHAIN_FILE=$cmake_modules_dir/toolchain.cmake)
fi
mkdir -p $builddir
cd $builddir
cmake $CUR_DIR \
${CMAKE_ARGS[@]}