1
1
#! /usr/bin/env bash
2
2
3
- # This script is intended to be run from an Ubuntu 18.04 Docker image.
4
- # Since it uses `apt-get` to install dependencies required by the examples,
5
- # it may also run on other versions of Ubuntu, or other Debian-derived distros.
6
- # It will definitely not run without `apt-get` installed!
3
+ # This script is intended to be run from an Ubuntu Docker image (or other Debian-derived distros).
4
+ # It uses `apt-get` to install dependencies required by the examples,
7
5
8
6
set -euo pipefail
9
7
10
- DEFAULT_BUILD_DIR=" build"
11
- BUILD_DIR=" ${DEFAULT_BUILD_DIR} "
12
- SCRIPT_NAME=$( basename $0 )
13
- PROJECT_DIRNAME=$( dirname $( readlink -f $0 ) )
14
- USAGE=" Usage: ${SCRIPT_NAME} [options]...
15
-
16
- Options:
17
- -h, --help Print this message
18
- -b, --build-dir BUILD_DIR Build examples in BUILD_DIR instead of default '${DEFAULT_BUILD_DIR} '
19
- --all Build all the examples available
20
- --fltk Build fltk example
21
- --gtkmm Build gtkmm example
22
- --imgui Build imgui example
23
- --nana Build nana example
24
- --qt Build qt example
25
- --sdl Build sdl example
26
- "
27
-
28
- function build_fltk() {
8
+ function install_fltk() {
29
9
apt-get install -y --no-install-recommends libfltk1.3-dev libgl1-mesa-dev fluid
30
- BUILD_DIR=" ${1:- build-fltk} "
31
- mkdir -p " ${BUILD_DIR} "
32
- cmake -S " ${PROJECT_DIRNAME} " -B " ${BUILD_DIR} " -DCPP_STARTER_USE_FLTK=ON
33
- cmake --build " ${BUILD_DIR} " -j
34
10
}
35
11
36
- function build_gtkmm () {
12
+ function install_gtkmm () {
37
13
apt-get install -y --no-install-recommends pkg-config libgtkmm-3.0-dev
38
- BUILD_DIR=" ${1:- build-gtkmm} "
39
- mkdir -p " ${BUILD_DIR} "
40
- cmake -S " ${PROJECT_DIRNAME} " -B " ${BUILD_DIR} " -DCPP_STARTER_USE_GTKMM=ON
41
- cmake --build " ${BUILD_DIR} " -j
42
14
}
43
15
44
- function build_imgui () {
16
+ function install_imgui () {
45
17
apt-get install -y --no-install-recommends pkg-config libgl1-mesa-dev
46
- BUILD_DIR=" ${1:- build-imgui} "
47
- mkdir -p " ${BUILD_DIR} "
48
- cmake -S " ${PROJECT_DIRNAME} " -B " ${BUILD_DIR} " -DCPP_STARTER_USE_IMGUI=ON
49
- cmake --build " ${BUILD_DIR} " -j
50
18
}
51
19
52
- function build_nana () {
20
+ function install_nana () {
53
21
# CMakeLists.txt is 'supposed' to install all of these automatically, but for
54
22
# some reason it doesn't always work. Installing them manually does work.
55
23
apt-get install -y --no-install-recommends libjpeg8-dev libpng-dev \
56
24
libasound2-dev alsa-utils alsa-oss libx11-dev libxft-dev libxcursor-dev
57
- BUILD_DIR=" ${1:- build-nana} "
58
- mkdir -p " ${BUILD_DIR} "
59
25
# Note: Nana's headers trigger the -Wshadow warning, and cannot be compiled with -Werror.
60
26
# Supposedly, this is fixed in the develop-1.8 branch, but I cannot confirm.
61
- cmake -S " ${PROJECT_DIRNAME} " -B " ${BUILD_DIR} " -DCPP_STARTER_USE_NANA=ON -DWARNINGS_AS_ERRORS=FALSE
62
- cmake --build " ${BUILD_DIR} " -j
63
27
}
64
28
65
- function build_qt () {
29
+ function install_qt () {
66
30
apt-get install -y --no-install-recommends qt5-default qtbase5-dev
67
- BUILD_DIR=" ${1:- build-qt} "
68
- mkdir -p " ${BUILD_DIR} "
69
- cmake -S " ${PROJECT_DIRNAME} " -B " ${BUILD_DIR} " -DCPP_STARTER_USE_QT=ON
70
- cmake --build " ${BUILD_DIR} " -j
71
31
}
72
32
73
- function build_sdl () {
33
+ function install_sdl () {
74
34
pip install mako
75
- BUILD_DIR=" ${1:- build-sdl} "
76
- mkdir -p " ${BUILD_DIR} "
77
- cmake -S " ${PROJECT_DIRNAME} " -B " ${BUILD_DIR} " -DCPP_STARTER_USE_SDL=ON
78
- cmake --build " ${BUILD_DIR} " -j
79
- }
80
-
81
- function build_all() {
82
- build_fltk
83
- build_gtkmm
84
- build_imgui
85
- build_nana
86
- build_qt
87
- build_sdl
88
35
}
89
36
90
- # Parse the available options
91
- PARSED_OPTIONS=$( getopt -n " $0 " -o h: --long " fltk,gtkmm,imgui,nana,qt,sdl,all,help,build:" -- " $@ " )
92
- eval set -- " ${PARSED_OPTIONS} "
37
+ # call the above functions to install the required dependencies. As an example for qt:
38
+ # install_qt
93
39
94
- # Handle all the options
95
- while true ;
96
- do
97
- case " $1 " in
98
- --help|-h)
99
- echo " ${USAGE} "
100
- shift ;;
101
- --build-dir|-b)
102
- if [ -n " $2 " ];
103
- then
104
- BUILD_DIR=" $2 "
105
- echo " Using BUILD_DIR='${BUILD_DIR} '"
106
- fi
107
- shift 2;;
108
- --all)
109
- build_all $BUILD_DIR
110
- shift ;;
111
- --fltk)
112
- build_fltk $BUILD_DIR
113
- shift ;;
114
- --gtkmm)
115
- build_gtkmm $BUILD_DIR
116
- shift ;;
117
- --imgui)
118
- build_imgui $BUILD_DIR
119
- shift ;;
120
- --nana)
121
- build_nana $BUILD_DIR
122
- shift ;;
123
- --qt)
124
- build_qt $BUILD_DIR
125
- shift ;;
126
- --sdl)
127
- build_sdl $BUILD_DIR
128
- shift ;;
129
- --)
130
- shift
131
- break ;;
132
- esac
133
- done
40
+ # build with:
41
+ cmake -S . -B " ./build"
42
+ cmake --build " ./build"
0 commit comments