{"slug": "llvm-22-macports-cmake-setup", "title": "LLVM 22 MacPorts CMake setup", "summary": "The article provides a CMake setup configuration for LLVM 22 on macOS using MacPorts, including a `toolchain.cmake` file that specifies the LLVM 22 compiler path, C++23 standard, and required include/link directories. It also includes `launch.json` and `tasks.json` configurations for debugging and building projects with LLDB and CMake tasks in VS Code.", "body_md": "launch.json\n\n      This file contains hidden or 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.\n      \nLearn more about bidirectional Unicode characters\n\n \n    Show hidden characters\n\n{\n\n    \"version\": \"0.2.0\",\n\n    \"configurations\": [\n\n        {\n\n            \"name\": \"Run\",\n\n            \"type\": \"lldb\",\n\n            \"request\": \"launch\",\n\n            \"program\": \"build/<progname>\",\n\n            \"args\": [],\n\n            \"cwd\": \"${workspaceFolder}\",\n\n        },\n\n        {\n\n            \"name\": \"<progname> compile+run\",\n\n            \"type\": \"lldb\",\n\n            \"request\": \"launch\",\n\n            \"program\": \"${workspaceFolder}/build/<progname>\",\n\n            \"args\": [],\n\n            \"cwd\": \"${workspaceFolder}\",\n\n            \"preLaunchTask\": \"cmake\",\n\n        },\n\n    ]\n\n}\n\nMakefile\n\n      This file contains hidden or 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.\n      \nLearn more about bidirectional Unicode characters\n\n \n    Show hidden characters\n\ncmake-configure:\n\n\trm -rf build && cmake --toolchain toolchain.cmake -S . -B build\n\ncmake-build:\n\n\tcmake --build build -v\n\ntasks.json\n\n      This file contains hidden or 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.\n      \nLearn more about bidirectional Unicode characters\n\n \n    Show hidden characters\n\n{\n\n    \"tasks\": [\n\n        {\n\n            \"label\": \"cmake-configure\",\n\n            \"type\": \"shell\",\n\n            \"command\": \"make\",\n\n            \"args\": [\n\n                \"cmake-configure\",\n\n            ],\n\n            \"presentation\": {\n\n                \"close\": true,\n\n                \"reveal\": \"never\",\n\n                \"showReuseMessage\": false,\n\n                \"echo\": false,\n\n            },\n\n        },\n\n        {\n\n            \"label\": \"cmake-build\",\n\n            \"type\": \"shell\",\n\n            \"command\": \"make\",\n\n            \"args\": [\n\n                \"cmake-build\",\n\n            ],\n\n            \"presentation\": {\n\n                \"close\": true,\n\n                \"reveal\": \"never\",\n\n                \"showReuseMessage\": false,\n\n                \"echo\": false,\n\n            },\n\n        },\n\n        {\n\n            \"label\": \"cmake\",\n\n            \"type\": \"shell\",\n\n            \"dependsOn\": [\n\n                \"cmake-configure\",\n\n                \"cmake-build\",\n\n            ],\n\n            \"dependsOrder\": \"sequence\",\n\n            \"presentation\": {\n\n                \"close\": true,\n\n                \"reveal\": \"never\",\n\n                \"showReuseMessage\": false,\n\n                \"echo\": false,\n\n            },\n\n        }\n\n    ],\n\n    \"version\": \"2.0.0\"\n\n}\n\ntoolchain.cmake\n\n      This file contains hidden or 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.\n      \nLearn more about bidirectional Unicode characters\n\n \n    Show hidden characters\n\n# минимальная настройка, чтобы завести проект на шайтан-машине\n\n# Mac Mini 2014 MacOS Monterey 12.7.6\n\n# cmake --toolchain toolchain.cmake -S . -B build\n\nset(CMAKE_CXX_COMPILER /opt/local/libexec/llvm-22/bin/clang++)\n\nset(CMAKE_CXX_STANDARD 23)\n\nset(CMAKE_CXX_STANDARD_REQUIRED On)\n\nset(CMAKE_CXX_EXTENSIONS Off)\n\nset(CMAKE_OSX_DEPLOYMENT_TARGET 13.3)\n\nset(CMAKE_EXPORT_COMPILE_COMMANDS On)\n\nadd_compile_options(\n\n    -stdlib=libc++\n\n    -nostdinc++\n\n    \"-isystem/usr/local/include\"\n\n    \"-isystem/opt/local/libexec/llvm-22/include/c++/v1\"\n\n    \"-isystem/opt/local/libexec/llvm-22/lib/clang/22/include\"\n\n)\n\nadd_link_options(\n\n    -stdlib=libc++\n\n    \"-Wl,-rpath,/opt/local/libexec/llvm-22/lib/libc++\"\n\n    \"-Wl,-rpath,/opt/local/libexec/llvm-22/lib/libunwind\"\n\n    \"-L/opt/local/libexec/llvm-22/lib/libc++\"\n\n    \"-L/opt/local/libexec/llvm-22/lib/libunwind\"\n\n)", "url": "https://wpnews.pro/news/llvm-22-macports-cmake-setup", "canonical_source": "https://gist.github.com/SXHRYU/9dd013344f0ea33ae69e977dbe52455e", "published_at": "2026-05-22 15:03:46+00:00", "updated_at": "2026-05-22 16:09:50.132142+00:00", "lang": "en", "topics": ["developer-tools", "open-source"], "entities": ["LLVM", "MacPorts", "CMake", "LLDB"], "alternates": {"html": "https://wpnews.pro/news/llvm-22-macports-cmake-setup", "markdown": "https://wpnews.pro/news/llvm-22-macports-cmake-setup.md", "text": "https://wpnews.pro/news/llvm-22-macports-cmake-setup.txt", "jsonld": "https://wpnews.pro/news/llvm-22-macports-cmake-setup.jsonld"}}