28 lines
574 B
Bash
Executable File
28 lines
574 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
if [[ $# != 1 ]]; then
|
|
echo "usage: $0 BUILD_DIR" >&2
|
|
exit 2
|
|
fi
|
|
|
|
cache=$(realpath -e -- "$1/CMakeCache.txt")
|
|
compiler=
|
|
while IFS= read -r line; do
|
|
case $line in
|
|
CMAKE_CXX_COMPILER:FILEPATH=* | CMAKE_CXX_COMPILER:STRING=*)
|
|
[[ -z $compiler ]] || {
|
|
echo "duplicate CMAKE_CXX_COMPILER entries in $cache" >&2
|
|
exit 2
|
|
}
|
|
compiler=${line#*=}
|
|
;;
|
|
esac
|
|
done <"$cache"
|
|
|
|
[[ $compiler == /* && -x $compiler ]] || {
|
|
echo "CMake cache has no executable absolute C++ compiler: $cache" >&2
|
|
exit 2
|
|
}
|
|
realpath -e -- "$compiler"
|