2022-07-02 04:00:56 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2023-06-05 13:38:37 +00:00
|
|
|
if [[ -z "${DEPS_PREFIX}" ]]; then
|
|
|
|
echo "DEPS_PREFIX is not set."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Using build dependencies from: ${DEPS_PREFIX}"
|
|
|
|
|
2022-07-02 04:00:56 +00:00
|
|
|
if [ "${COMPILER}" = "clang" ]; then
|
2023-06-05 13:38:37 +00:00
|
|
|
if [[ -z "${CLANG_PATH}" ]] || [[ -z "${CLANGXX_PATH}" ]]; then
|
|
|
|
echo "CLANG_PATH or CLANGXX_PATH is not set."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2022-07-02 04:00:56 +00:00
|
|
|
echo "Using clang toolchain"
|
2023-06-05 13:38:37 +00:00
|
|
|
cat > "clang-toolchain.cmake" << EOF
|
|
|
|
set(CMAKE_C_COMPILER "${CLANG_PATH}")
|
|
|
|
set(CMAKE_CXX_COMPILER "${CLANGXX_PATH}")
|
2022-07-02 04:00:56 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS_INIT "-fuse-ld=lld")
|
|
|
|
set(CMAKE_MODULE_LINKER_FLAGS_INIT "-fuse-ld=lld")
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-fuse-ld=lld")
|
|
|
|
EOF
|
2023-06-05 13:38:37 +00:00
|
|
|
ADDITIONAL_CMAKE_ARGS="$ADDITIONAL_CMAKE_ARGS -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_TOOLCHAIN_FILE=clang-toolchain.cmake"
|
2022-07-02 04:00:56 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Additional CMake Args - ${ADDITIONAL_CMAKE_ARGS}"
|
|
|
|
|
|
|
|
# Generate CMake into ./build
|
|
|
|
# DISABLE_ADVANCE_SIMD is needed otherwise we end up doing -march=native.
|
|
|
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
cmake \
|
|
|
|
-B build \
|
|
|
|
-G Ninja \
|
|
|
|
$ADDITIONAL_CMAKE_ARGS \
|
|
|
|
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
|
|
|
-DCMAKE_BUILD_TYPE=Release \
|
2023-01-02 03:13:12 +00:00
|
|
|
-DX11_API=ON \
|
2022-07-02 04:00:56 +00:00
|
|
|
-DWAYLAND_API=ON \
|
2023-01-02 03:13:12 +00:00
|
|
|
-DENABLE_SETCAP=OFF \
|
2023-06-05 13:38:37 +00:00
|
|
|
-DCMAKE_PREFIX_PATH="${DEPS_PREFIX}" \
|
2022-07-02 04:00:56 +00:00
|
|
|
-DDISABLE_ADVANCE_SIMD=TRUE
|
|
|
|
|