Created
February 15, 2023 16:21
-
-
Save exoosh/c734665e6f53a81d23cae8677f834dc9 to your computer and use it in GitHub Desktop.
Detecting most recent Clang tools (Bash)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function detect_newest # Function to detect newest clang-based tool (they have a numeric suffix -<version>) | |
{ | |
local PFX=${1:-clang++} | |
for v in "" -{32..1}; do test -n "$(which -- $PFX$v)" && { echo "$PFX$v"; break; }; done | |
} | |
[[ -z "$CXX" ]] && CXX=$(detect_newest clang++) | |
[[ -z "$CC" ]] && CC=$(detect_newest clang) | |
[[ -n "$CXX" ]] || { echo -e "${cR}FATAL:${cZ} ${cW}CXX${cZ} not detected."; } | |
[[ -n "$CC" ]] || { echo -e "${cR}FATAL:${cZ} ${cW}CC${cZ} not detected."; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment