-
Notifications
You must be signed in to change notification settings - Fork 2
/
getlibs.sh
executable file
·153 lines (145 loc) · 6.92 KB
/
getlibs.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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/usr/bin/env bash
#set -euxo pipefail
set -euo pipefail
if [ $# -eq 0 ] ; then
echo "Script $0 compiles and installs dependent libraries for a set of targets specified as arguments."
echo "Possible arguments:"
echo " linux64 win64 macos64"
echo "The script is sensitive to CMake environment variables like:"
echo " CMAKE_TOOLCHAIN_FILE CMAKE_BUILD_TYPE CMAKE_PREFIX_PATH"
machine=$(uname -m)
kernel=$(uname -s)
targets=${machine,,}-${kernel,,}
echo "Guessing target: $targets"
else
targets="$@"
fi
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -z "${CMAKE_BUILD_TYPE+x}" ]; then
export CMAKE_BUILD_TYPE=Release
elif [ "$CMAKE_BUILD_TYPE" != Release ]; then
echo "WARNING: building libs with CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE"
fi
for target in $targets ; do
echo "GETLIBS for $target"
BUILD_TARGET=$target
SOURCES="$PROJECT_DIR/local/sources"
mkdir -p "$SOURCES"
PREFIX="$PROJECT_DIR/local/${BUILD_TARGET}"
# export CMAKE_PREFIX_PATH="$PREFIX"
export CMAKE_INSTALL_PREFIX="$PREFIX"
## XXHASH
NAME=xxHash
VERSION=0.8.2
LIBRARY="${NAME}-${VERSION}"
ARCHIVE="$LIBRARY.tgz"
SHA256=baee0c6afd4f03165de7a4e67988d16f0f2b257b51d0e3cb91909302a26a79c4
SOURCE="${SOURCES}/$LIBRARY"
BUILD="${PREFIX}/build-$LIBRARY"
if [ -r "${CMAKE_INSTALL_PREFIX}/include/xxhash.h" ]; then
echo "$LIBRARY is already installed in $CMAKE_INSTALL_PREFIX"
else
pushd "$SOURCES"
[ -r "${ARCHIVE}" ] || curl -sL "https://github.com/Cyan4973/xxHash/archive/refs/tags/v$VERSION.tar.gz" -o "${ARCHIVE}"
if [ -n "$(command -v sha256sum)" ]; then echo "$SHA256 $ARCHIVE" | sha256sum --check ; fi
[ -d "$SOURCE" ] || tar xf "${ARCHIVE}"
popd
echo "Building $LIBRARY in $BUILD from $SOURCE"
echo " CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE:-(unset)}"
echo " CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-(unset)}"
echo " CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH:-(unset)}"
echo " CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:-(unset)}"
cmake -S "$SOURCE/cmake_unofficial" -B "$BUILD" -DBUILD_SHARED_LIBS=OFF
cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE
cmake --install "$BUILD" --config $CMAKE_BUILD_TYPE --prefix "${CMAKE_INSTALL_PREFIX}"
rm -Rf "$BUILD"
rm -Rf "$SOURCE"
fi
## BOOST
NAME=boost
VERSION=1.86.0
LIBRARY="${NAME}-${VERSION}"
ARCHIVE="${LIBRARY}-cmake.tar.xz"
SHA256=2c5ec5edcdff47ff55e27ed9560b0a0b94b07bd07ed9928b476150e16b0efc57
SOURCE="${SOURCES}/${LIBRARY}"
BUILD="${PREFIX}/build-${LIBRARY}"
if [ -r "${CMAKE_INSTALL_PREFIX}/include/boost/math/distributions/arcsine.hpp" ] ; then
echo "$LIBRARY is already installed in $CMAKE_INSTALL_PREFIX"
else
pushd "$SOURCES"
[ -r "$ARCHIVE" ] || curl -sL "https://github.com/boostorg/boost/releases/download/${LIBRARY}/${LIBRARY}-cmake.tar.xz" -o "$ARCHIVE"
if [ -n "$(command -v sha256sum)" ]; then echo "$SHA256 $ARCHIVE" | sha256sum --check ; fi
[ -d "$SOURCE" ] || tar xf "$ARCHIVE"
popd
echo "Building $LIBRARY in $BUILD from $SOURCE"
echo " CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE:-(unset)}"
echo " CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-(unset)}"
echo " CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH:-(unset)}"
echo " CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:-(unset)}"
cmake -S "$SOURCE" -B "$BUILD" -DBUILD_SHARED_LIBS=OFF \
-DBOOST_INCLUDE_LIBRARIES="headers;math" -DBOOST_ENABLE_MPI=OFF -DBOOST_ENABLE_PYTHON=OFF \
-DBOOST_RUNTIME_LINK=static -DBUILD_TESTING=OFF -DBOOST_USE_STATIC_LIBS=ON -DBOOST_USE_DEBUG_LIBS=ON \
-DBOOST_USE_RELEASE_LIBS=ON -DBOOST_USE_STATIC_RUNTIME=ON -DBOOST_INSTALL_LAYOUT=system -DBOOST_ENABLE_CMAKE=ON
cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE
cmake --install "$BUILD" --config $CMAKE_BUILD_TYPE --prefix "${CMAKE_INSTALL_PREFIX}"
rm -Rf "$BUILD"
rm -Rf "$SOURCE"
fi
## DOCTEST
NAME=doctest
VERSION=2.4.11
LIBRARY="${NAME}-${VERSION}"
ARCHIVE="$LIBRARY.tgz"
SHA256=632ed2c05a7f53fa961381497bf8069093f0d6628c5f26286161fbd32a560186
SOURCE="${SOURCES}/$LIBRARY"
BUILD="${PREFIX}/build-$LIBRARY"
if [ -r "${CMAKE_INSTALL_PREFIX}/include/doctest/doctest.h" ]; then
echo "$LIBRARY is already installed in $CMAKE_INSTALL_PREFIX"
else
pushd "${SOURCES}"
[ -r "${ARCHIVE}" ] || curl -sL "https://github.com/doctest/doctest/archive/refs/tags/v$VERSION.tar.gz" -o "${ARCHIVE}"
if [ -n "$(command -v sha256sum)" ]; then echo "$SHA256 $ARCHIVE" | sha256sum --check ; fi
[ -d "${SOURCE}" ] || tar xf "${ARCHIVE}"
popd
echo "Building $LIBRARY in $BUILD from $SOURCE"
echo " CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE:-(unset)}"
echo " CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-(unset)}"
echo " CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH:-(unset)}"
echo " CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:-(unset)}"
cmake -S "$SOURCE" -B "$BUILD" -DDOCTEST_WITH_TESTS=OFF -DDOCTEST_WITH_MAIN_IN_STATIC_LIB=ON
cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE
cmake --install "$BUILD" --config $CMAKE_BUILD_TYPE --prefix "${CMAKE_INSTALL_PREFIX}"
rm -Rf "$BUILD"
rm -Rf "$SOURCE"
fi
## Google Benchmark
NAME=benchmark
VERSION=1.9.0 # v1.8.2 fails with "-lrt not found" on win64
LIBRARY="${NAME}-${VERSION}"
ARCHIVE="${LIBRARY}.tar.gz"
SHA256=35a77f46cc782b16fac8d3b107fbfbb37dcd645f7c28eee19f3b8e0758b48994
SOURCE="${SOURCES}/${LIBRARY}"
BUILD="${PREFIX}/build-${LIBRARY}"
if [ -r "${CMAKE_INSTALL_PREFIX}/include/benchmark/benchmark.h" ] ; then
echo "$LIBRARY is already installed in $CMAKE_INSTALL_PREFIX"
else
pushd "$SOURCES"
[ -r "$ARCHIVE" ] || curl -sL "https://github.com/google/benchmark/archive/refs/tags/v${VERSION}.tar.gz" -o "$ARCHIVE"
if [ -n "$(command -v sha256sum)" ]; then echo "$SHA256 $ARCHIVE" | sha256sum --check ; fi
[ -d "$LIBRARY" ] || tar -xf "$ARCHIVE"
popd
echo "Building $LIBRARY in $BUILD from $SOURCE"
echo " CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE:-(unset)}"
echo " CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-(unset)}"
echo " CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH:-(unset)}"
echo " CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX:-(unset)}"
cmake -S "$SOURCE" -B "$BUILD" -DBUILD_SHARED_LIBS=OFF \
-DBENCHMARK_ENABLE_TESTING=OFF -DBENCHMARK_ENABLE_EXCEPTIONS=ON -DBENCHMARK_ENABLE_LTO=OFF \
-DBENCHMARK_USE_LIBCXX=OFF -DBENCHMARK_ENABLE_WERROR=ON -DBENCHMARK_FORCE_WERROR=OFF
cmake --build "$BUILD" --config $CMAKE_BUILD_TYPE
cmake --install "$BUILD" --config $CMAKE_BUILD_TYPE --prefix "${CMAKE_INSTALL_PREFIX}"
rm -Rf "$BUILD"
rm -Rf "$SOURCE"
fi
echo "GETLIBS $target success!"
done