forked from alanlivio/ps-sh-helpers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmake.bash
79 lines (69 loc) · 2.08 KB
/
cmake.bash
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
function cmake_configure_debug() {
if test -e CMakeLists.txt; then
cmake -B _build-Debug-$WSL_DISTRO_NAME$OS -G Ninja -DCMAKE_EXPORT_COMPILE_programs:BOOL=TRUE -DSTATIC_LINKING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug "$@"
else
cmake .. -G Ninja -DCMAKE_EXPORT_COMPILE_programs:BOOL=TRUE -DSTATIC_LINKING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Debug "$@"
fi
}
function cmake_configure_release() {
if test -e CMakeLists.txt; then
cmake -B _build-Release-$WSL_DISTRO_NAME$OS -G Ninja -DCMAKE_EXPORT_COMPILE_programs:BOOL=TRUE -DSTATIC_LINKING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release "$@"
else
cmake .. -G Ninja -DCMAKE_EXPORT_COMPILE_programs:BOOL=TRUE -DSTATIC_LINKING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release "$@"
fi
}
function cmake_build() {
cmake --build . --target all
}
function cmake_clean() {
cmake --build . --target clean
}
function cmake_build_target() {
: ${1?"Usage: ${FUNCNAME[0]} <target>"}
cmake --build . --target $1
}
function cmake_check() {
cmake --build . --target check
}
function cmake_install() {
case $OSTYPE in
linux*)
sudo cmake --install . --prefix /usr
;;
msys*)
cmake --install .
;;
*)
sudo cmake --install .
;;
esac
}
function cmake_uninstall() {
local manifest="install_manifest.txt"
if test -e $manifest; then
while IFS= read -r i; do
local file=${i%$'\r'}
if test -e "$file"; then
log_msg "uninstall $file"
sudo rm "$file"
fi
done <$manifest
else
log_error "$manifest does not exist" && return 1
fi
}
function cmake_clean_retain_objs() {
if test -d CMakeFiles; then
find . -maxdepth 1 -not -name '.' -not -name CMakeFiles -exec rm -rf {} \;
else
log_error "there is no CMakeFiles dir" && return 1
fi
}
function cmake_test_all() {
ctest
}
function cmake_test_target() {
: ${1?"Usage: ${FUNCNAME[0]} <target>"}
cmake --build . --target $1
ctest -R $1
}