forked from pablospe/cmake-example-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_win.sh
executable file
·51 lines (39 loc) · 1.08 KB
/
build_win.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
#!/bin/bash
# This script can be called from anywhere and allows to build out of source.
# Note: it is assumed Git for Windows is installed (https://gitforwindows.org/).
# 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}
# Build type
BUILD_TYPE=Release
# BUILD_TYPE=Debug
# Build folder
BUILD_DIR=_build
# Installation folder
INSTALL_DIR=_install
# Library type
BUILD_SHARED_LIBS=OFF # Static
# BUILD_SHARED_LIBS=ON # Shared
# Options summary
echo ""
echo "BUILD_TYPE =" ${BUILD_TYPE}
echo "BUILD_DIR =" ${SCRIPT_ABS_PATH}/${BUILD_DIR}/
echo "INSTALL_DIR =" ${SCRIPT_ABS_PATH}/${INSTALL_DIR}/
echo "BUILD_SHARED_LIBS =" ${BUILD_SHARED_LIBS}
echo ""
# clean
# rm -fr ${BUILD_DIR} ${INSTALL_DIR}
# cmake
cmake \
-S . \
-B ${BUILD_DIR} \
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} \
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}"
# compile & install
cmake \
--build ${BUILD_DIR} \
--config ${BUILD_TYPE} \
--target install \
-j 8