forked from pablospe/cmake-example-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_example_external.sh
executable file
·77 lines (59 loc) · 1.81 KB
/
build_example_external.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
#!/bin/bash
# This script can be called from anywhere and allows to build out of source.
# Determine script absolute path
SCRIPT_ABS_PATH=$(readlink -f ${BASH_SOURCE[0]})
SCRIPT_ABS_PATH=$(dirname ${SCRIPT_ABS_PATH})
# switch to script path
cd ${SCRIPT_ABS_PATH}
# Choose build type
BUILD_TYPE=Release
BUILD_TYPE=Debug
# Choose build type
BUILD_DIR=_build
# Choose install folder
INSTALL_DIR=_install
# Options summary
echo ""
echo "BUILD_TYPE =" ${BUILD_TYPE}
echo "BUILD_DIR =" ${SCRIPT_ABS_PATH}/example_external/${BUILD_DIR}/
echo "INSTALL_DIR =" ${SCRIPT_ABS_PATH}/example_external/${INSTALL_DIR}/
echo ""
# ------------------------------
# example_external (for testing)
# ------------------------------
printf "\n\n ----- example_external ----- \n\n"
# clean
# rm -fr example_external/${BUILD_DIR}
SO=`uname`
if [[ $SO == "Linux" ]]; then
echo "Running on Linux"
# cmake
cmake \
-S ${SCRIPT_ABS_PATH}/example_external/ \
-B ${SCRIPT_ABS_PATH}/example_external/${BUILD_DIR} \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DFoo_DIR="${SCRIPT_ABS_PATH}/${INSTALL_DIR}/lib/cmake/Foo/"
# compile
cmake \
--build ${SCRIPT_ABS_PATH}/example_external/${BUILD_DIR} \
-j 8
else
echo "Running on Windows"
# cmake
cmake \
-S ${SCRIPT_ABS_PATH}/example_external/ \
-B ${SCRIPT_ABS_PATH}/example_external/${BUILD_DIR} \
-DFoo_DIR="${SCRIPT_ABS_PATH}/${INSTALL_DIR}/lib/cmake/Foo/"
# compile
cmake \
--build ${SCRIPT_ABS_PATH}/example_external/${BUILD_DIR} \
--config ${BUILD_TYPE} \
-j 8
fi
# run
BIN_PATH=${SCRIPT_ABS_PATH}/example_external/${BUILD_DIR}
echo ${BIN_PATH}/${BUILD_TYPE}/
if [ -d "${BIN_PATH}/${BUILD_TYPE}" ]; then # multi-config generator
BIN_PATH=${BIN_PATH}/${BUILD_TYPE}
fi
${BIN_PATH}/bar