-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure.sh
More file actions
executable file
·136 lines (125 loc) · 4.06 KB
/
configure.sh
File metadata and controls
executable file
·136 lines (125 loc) · 4.06 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
133
134
135
136
#!/usr/bin/env bash
# configure.sh — Configure the SkolemFC build
#
# Usage:
# ./configure.sh [OPTIONS] [-- EXTRA_CMAKE_ARGS]
#
# Options:
# -D, --auto-download Let CMake clone all dependencies automatically
# (default: use local deps/ submodules)
# --build-dir DIR Build directory (default: build)
# --build-type TYPE CMake build type: Debug, Release, RelWithDebInfo,
# MinSizeRel (default: RelWithDebInfo)
# --debug Shorthand for --build-type Debug
# --static Compile a statically linked executable
# -h, --help Show this help message and exit
#
# Examples:
# ./configure.sh # standard release build
# ./configure.sh --debug # debug build
# ./configure.sh --static # static release build
# ./configure.sh --static --debug # static debug build
# ./configure.sh -D # auto-download all deps
# ./configure.sh -- -DFOO=BAR # pass extra flags to cmake
#
# After running configure.sh, build with:
# cd build && make -j$(nproc) # Linux
# cd build && make -j$(sysctl -n hw.logicalcpu) # macOS
set -e
# --------------------------------------------------------------------------
# Defaults
# --------------------------------------------------------------------------
AUTO_DOWNLOAD=OFF
BUILD_DIR="build"
BUILD_TYPE="RelWithDebInfo"
STATIC=OFF
EXTRA_ARGS=()
# --------------------------------------------------------------------------
# Argument parsing
# --------------------------------------------------------------------------
while [[ $# -gt 0 ]]; do
case "$1" in
-D|--auto-download)
AUTO_DOWNLOAD=ON
shift
;;
--build-dir)
BUILD_DIR="$2"
shift 2
;;
--build-type)
BUILD_TYPE="$2"
shift 2
;;
--debug)
BUILD_TYPE="Debug"
shift
;;
--static)
STATIC=ON
shift
;;
-j)
# Just consume — user can pass -j to make separately
shift 2
;;
-h|--help)
sed -n '/^# configure.sh/,/^[^#]/{ /^[^#]/q; s/^# \{0,1\}//p }' "$0"
exit 0
;;
--)
shift
EXTRA_ARGS=("$@")
break
;;
*)
echo "Unknown option: $1" >&2
echo "Run '$0 --help' for usage." >&2
exit 1
;;
esac
done
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# --------------------------------------------------------------------------
# Check submodule state when not auto-downloading
# --------------------------------------------------------------------------
if [[ "$AUTO_DOWNLOAD" == "OFF" ]]; then
if [[ ! -f "$SCRIPT_DIR/deps/louvain-community/CMakeLists.txt" ]]; then
echo ""
echo "ERROR: Local dependency submodules are not initialised."
echo ""
echo "Either:"
echo " 1. Initialise submodules and retry:"
echo " git submodule update --init"
echo " $0"
echo ""
echo " 2. Or let the build system clone all dependencies automatically:"
echo " $0 -D"
echo ""
exit 1
fi
echo "Using local deps/ submodules."
else
echo "AUTO_DOWNLOAD=ON — dependencies will be cloned into ${BUILD_DIR}/deps/"
fi
# --------------------------------------------------------------------------
# Create build directory and run cmake
# --------------------------------------------------------------------------
mkdir -p "$SCRIPT_DIR/$BUILD_DIR"
cd "$SCRIPT_DIR/$BUILD_DIR"
cmake_args=(
-DCMAKE_BUILD_TYPE="$BUILD_TYPE"
-DAUTO_DOWNLOAD="$AUTO_DOWNLOAD"
)
if [[ "$STATIC" == "ON" ]]; then
cmake_args+=(-DSTATICCOMPILE=ON)
fi
cmake_args+=("${EXTRA_ARGS[@]}")
cmake_args+=("$SCRIPT_DIR")
echo ""
echo "Running: cmake ${cmake_args[*]}"
echo ""
cmake "${cmake_args[@]}"
echo ""
echo "Configuration complete. To build:"
echo " cd $BUILD_DIR && make -j\$(nproc)"