Skip to content

Instantly share code, notes, and snippets.

@kjelloh
Created November 29, 2022 09:13
Show Gist options
  • Save kjelloh/94749bc7ac2081bb1e9703abdc95dd8c to your computer and use it in GitHub Desktop.
Save kjelloh/94749bc7ac2081bb1e9703abdc95dd8c to your computer and use it in GitHub Desktop.
macOS VSCode tasks.json for system clang++, Brew and macPorts installed Clang-15 and Gcc-12 builds (as of 221129)
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-std=c++20",
"-g",
"${file}",
"-o",
"${workspaceFolder}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: /usr/bin/clang++"
},
{
"type": "cppbuild",
"label": "macOS C/C++: Brew installed g++-12 build cratchit",
"command": "/usr/local/Cellar/gcc/12.2.0/bin/g++-12",
"args": [
"--sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk",
"-fdiagnostics-color=always",
"-std=c++20",
"-g",
"${file}",
"-o",
"${workspaceFolder}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: /usr/local/Cellar/gcc/12.2.0/bin/g++-12"
},
{
"type": "cppbuild",
"label": "macOS C/C++: macPorts installed g++-12 build cratchit",
"command": "/opt/local/bin/g++-mp-12",
"args": [
"--sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk",
"-fdiagnostics-color=always",
"-std=c++20",
"-g",
"${file}",
"-o",
"${workspaceFolder}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: /opt/local/bin/g++-mp-12"
},
{
"type": "cppbuild",
"label": "macOS C/C++: Brew installed clang-15 build cratchit",
"command": "/usr/local/Cellar/llvm/15.0.3/bin/clang++",
"args": [
"-fdiagnostics-color=always",
"-fexperimental-library",
"-L/usr/local/Cellar/llvm/15.0.3/lib/c++/",
"-std=c++20",
"-g",
"${file}",
"-o",
"${workspaceFolder}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: /usr/local/Cellar/llvm/15.0.3/bin/clang++"
},
{
"type": "cppbuild",
"label": "macOS C/C++: macPorts installed clang-15 build cratchit",
"command": "/opt/local/libexec/llvm-15/bin/clang++",
"args": [
"--sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk",
"-fexperimental-library",
"-L/opt/local/libexec/llvm-15/lib/",
"-fdiagnostics-color=always",
"-std=c++20",
"-g",
"${file}",
"-o",
"${workspaceFolder}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "compiler: /opt/local/libexec/llvm-15/bin/clang++"
}
]
}
@kjelloh
Copy link
Author

kjelloh commented Nov 29, 2022

I don't like to fight the "magic" of tool chains and VSCode applying all kinds of "intelligent" finding of files. Nor do I like having "magic" settings to my user profile that prohibits me from sharing tool-chains with others (my user profile settings is easily forgotten and is not provided when sharing). So here I provide a hard-coded tasks.json that anyone on macOS having installed clang-15 or gcc-12 using Brew or macPorts should be able to use out-if-the-box :). Please comment if you find anything that is still broken?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment