summaryrefslogtreecommitdiff
path: root/cmake/distclean.sh
blob: 0124dd12e7c05e487157029c4571fb7e38dc3eef (plain)
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
#!/bin/sh
# CMake doesn't provide the equiv of "distclean" which makes it impossible to
# properly clean up after it when you build in-tree.  This script emulates it.
# It assumes it's run in the dir you want to clean.

usage() {
	cat <<-EOF
Usage: $0 [--automake]

Clean all the cmake generated output files.

Options:
  --automake  Do not clean files autotools also creates
EOF
	exit ${1:-0}
}

AUTOMAKE="false"
while [ $# -ne 0 ]; do
	case $1 in
	-h|--help)  usage ;;
	--automake) AUTOMAKE="true" ;;
	*) usage 1 ;;
	esac
	shift
done

set -x

find . -maxdepth 3 \
	'(' \
		-name CMakeCache.txt -o \
		-name CMakeFiles -o \
		-name CTestTestfile.cmake -o \
		-name cmake_install.cmake \
	')' \
	-exec rm -rf {} +
rm -rf \
	Bin Testing \
	CPackConfig.cmake CPackSourceConfig.cmake \
	DartConfiguration.tcl

if [ "${AUTOMAKE}" = "false" ]; then
	find . -maxdepth 3 '!' -wholename './windows/*' -a -name Makefile -exec rm -rf {} +
	rm -f src/config.h
fi