/
prepare_cmake.sh
executable file
·129 lines (84 loc) · 2.6 KB
/
prepare_cmake.sh
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#! /bin/bash
ScriptPath=$0
Dir=$(cd $(dirname "$ScriptPath"); pwd)
Basename=$(basename "$ScriptPath")
CMakePath=$Dir/_build
CmakeVerboseMakefile=0
Configuration=Release
RunMake=0
# STLSoftDirEnvVar=${STLSOFT}
STLSoftDirGiven=
# ##########################################################
# command-line handling
while [[ $# -gt 0 ]]; do
case $1 in
-d|--debug-configuration)
Configuration=Debug
;;
-m|--run-make)
RunMake=1
;;
-s|--stlsoft-root-dir)
shift
STLSoftDirGiven=$1
;;
-v|--cmake-verbose-makefile)
CmakeVerboseMakefile=1
;;
--help)
cat << EOF
xTests is a small, lightweight, portable, simple unit- and component-test framework suitable for exercising C and C++ libraries
Copyright (c) 2023 Synesis Information Systems
Creates/reinitialises the CMake build script(s)
$ScriptPath [ ... flags/options ... ]
Flags/options:
behaviour:
-d
--debug-configuration
uses Debug configuration. Default is to use Release
-m
--run-make
runs make after a successful running of CMake
-s <dir>
--stlsoft-root-dir <dir>
specifies the STLSoft root-directory, which will be passed to CMake
as the variable STLSOFT, and which will override the environment
variable STLSOFT (if present)
-v
--cmake-verbose-makefile
configures CMake to run verbosely (by setting CMAKE_VERBOSE_MAKEFILE
to be ON)
standard flags:
--help
displays this help and terminates
EOF
exit 0
;;
*)
>&2 echo "$ScriptPath: unrecognised argument '$1'; use --help for usage"
exit 1
;;
esac
shift
done
# ##########################################################
# main()
mkdir -p $CMakePath || exit 1
cd $CMakePath
echo "Executing CMake"
if [ $CmakeVerboseMakefile -eq 0 ]; then CmakeVerboseMakefileFlag="OFF" ; else CmakeVerboseMakefileFlag="ON" ; fi
if [ -z $STLSoftDirGiven ]; then CmakeSTLSoftVariable="" ; else CmakeSTLSoftVariable="-DSTLSOFT=$STLSoftDirGiven/" ; fi
cmake -DCMAKE_VERBOSE_MAKEFILE:BOOL=$CmakeVerboseMakefileFlag -DCMAKE_BUILD_TYPE=$Configuration $CmakeSTLSoftVariable .. || (cd ->/dev/null ; exit 1)
status=0
if [ $RunMake -ne 0 ]; then
echo "Executing make"
make
status=$?
fi
cd ->/dev/null
if [ $CmakeVerboseMakefile -ne 0 ]; then
echo -e "contents of $CMakePath:"
ls -al $CMakePath
fi
exit $status
# ############################## end of file ############################# #