Repository navigation
Expand file tree
/
Copy pathconfigure
More file actions
executable file
·132 lines (111 loc) · 4.52 KB
/
Copy pathconfigure
File metadata and controls
executable file
·132 lines (111 loc) · 4.52 KB
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
129
130
131
132
#!/bin/bash
#
# Configure ocpp-cs — wraps cmake with sensible defaults.
# libapostol is a git submodule; no external downloads needed.
#
# Usage: ./configure [OPTIONS]
set -e
PROJECT_NAME=ocpp-cs
BUILD_TYPE=Release
WITH_POSTGRESQL=ON
WITH_SSL=ON
WITH_CURL=OFF
APP_NAME=cs
# --- Helpers --------------------------------------------------------------
display_heading_message() { echo; echo "********************** $* **********************"; echo; }
display_message() { echo "$@"; }
display_help()
{
display_message "Usage: ./configure [OPTION]..."
display_message ""
display_message "Build options:"
display_message " --release Release build (default)"
display_message " --debug Debug build"
display_message " --update Reconfigure without deleting the build directory"
display_message " --build-dir=<path> Location of build files (default: cmake-build-{type})"
display_message ""
display_message "Feature flags:"
display_message " --with-postgresql Enable PostgreSQL / libpq support (default: on)"
display_message " --without-postgresql Disable PostgreSQL support"
display_message " --without-ssl Disable OpenSSL support (default: on)"
display_message " --with-curl Enable libcurl support (default: off)"
display_message " --with-tests Enable unit tests (Catch2)"
display_message ""
display_message " --help Display this help"
display_message ""
}
display_configuration()
{
display_message "Configuration"
display_message "--------------------------------------------------------------------"
display_message "PROJECT_NAME : $PROJECT_NAME"
display_message "BUILD_TYPE : $BUILD_TYPE"
display_message "BUILD_DIR : $BUILD_DIR"
display_message "WITH_POSTGRESQL : $WITH_POSTGRESQL"
display_message "WITH_SSL : $WITH_SSL"
display_message "WITH_CURL : $WITH_CURL"
display_message "BUILD_TESTING : $BUILD_TESTING"
display_message "APP_NAME : $APP_NAME"
display_message "--------------------------------------------------------------------"
}
make_configuration()
{
if ! [[ $BUILD_UPDATE ]]; then
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
fi
display_heading_message "Configuring: $PROJECT_NAME"
cmake \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DWITH_POSTGRESQL="$WITH_POSTGRESQL" \
-DWITH_SSL="$WITH_SSL" \
-DWITH_CURL="$WITH_CURL" \
-DBUILD_TESTING="$BUILD_TESTING" \
-DAPP_NAME="$APP_NAME" \
-B "$BUILD_DIR" .
display_message ""
echo -e "********************** \e[32;1mSUCCESS\e[0m **********************"
echo -e "\e[32m-- To build $PROJECT_NAME run:\e[0m"
display_message "--------------------------------------------------------------------"
echo -e "\e[1m\$ cmake --build $BUILD_DIR --parallel \$(nproc)\e[0m"
display_message "--------------------------------------------------------------------"
echo -e "\e[32m-- To install $PROJECT_NAME run:\e[0m"
display_message "--------------------------------------------------------------------"
echo -e "\e[1m\$ sudo cmake --install $BUILD_DIR\e[0m"
display_message "--------------------------------------------------------------------"
}
# --- Parse options --------------------------------------------------------
BUILD_TESTING=OFF
for OPTION in "$@"; do
case $OPTION in
(--help) DISPLAY_HELP=yes ;;
(--release) BUILD_TYPE=Release ;;
(--debug) BUILD_TYPE=Debug ;;
(--update) BUILD_UPDATE=yes ;;
(--with-postgresql) WITH_POSTGRESQL=ON ;;
(--without-postgresql) WITH_POSTGRESQL=OFF ;;
(--without-ssl) WITH_SSL=OFF ;;
(--with-curl) WITH_CURL=ON ;;
(--with-tests) BUILD_TESTING=ON ;;
(--build-dir=*) BUILD_DIR="${OPTION#*=}" ;;
esac
done
if ! [[ $BUILD_DIR ]]; then
if [[ $BUILD_TYPE == Debug ]]; then
BUILD_DIR=cmake-build-debug
else
BUILD_DIR=cmake-build-release
fi
fi
# --- Run ------------------------------------------------------------------
if [[ $DISPLAY_HELP ]]; then
display_help
else
# libapostol — git submodule
if [[ -d .git ]]; then
display_heading_message "Updating submodules"
git submodule update --init --remote
fi
display_configuration
make_configuration
fi