# LLVM 22 MacPorts CMake setup

> Source: <https://gist.github.com/SXHRYU/9dd013344f0ea33ae69e977dbe52455e>
> Published: 2026-05-22 15:03:46+00:00

launch.json

      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.
      
Learn more about bidirectional Unicode characters

 
    Show hidden characters

{

    "version": "0.2.0",

    "configurations": [

        {

            "name": "Run",

            "type": "lldb",

            "request": "launch",

            "program": "build/<progname>",

            "args": [],

            "cwd": "${workspaceFolder}",

        },

        {

            "name": "<progname> compile+run",

            "type": "lldb",

            "request": "launch",

            "program": "${workspaceFolder}/build/<progname>",

            "args": [],

            "cwd": "${workspaceFolder}",

            "preLaunchTask": "cmake",

        },

    ]

}

Makefile

      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.
      
Learn more about bidirectional Unicode characters

 
    Show hidden characters

cmake-configure:

	rm -rf build && cmake --toolchain toolchain.cmake -S . -B build

cmake-build:

	cmake --build build -v

tasks.json

      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.
      
Learn more about bidirectional Unicode characters

 
    Show hidden characters

{

    "tasks": [

        {

            "label": "cmake-configure",

            "type": "shell",

            "command": "make",

            "args": [

                "cmake-configure",

            ],

            "presentation": {

                "close": true,

                "reveal": "never",

                "showReuseMessage": false,

                "echo": false,

            },

        },

        {

            "label": "cmake-build",

            "type": "shell",

            "command": "make",

            "args": [

                "cmake-build",

            ],

            "presentation": {

                "close": true,

                "reveal": "never",

                "showReuseMessage": false,

                "echo": false,

            },

        },

        {

            "label": "cmake",

            "type": "shell",

            "dependsOn": [

                "cmake-configure",

                "cmake-build",

            ],

            "dependsOrder": "sequence",

            "presentation": {

                "close": true,

                "reveal": "never",

                "showReuseMessage": false,

                "echo": false,

            },

        }

    ],

    "version": "2.0.0"

}

toolchain.cmake

      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.
      
Learn more about bidirectional Unicode characters

 
    Show hidden characters

# минимальная настройка, чтобы завести проект на шайтан-машине

# Mac Mini 2014 MacOS Monterey 12.7.6

# cmake --toolchain toolchain.cmake -S . -B build

set(CMAKE_CXX_COMPILER /opt/local/libexec/llvm-22/bin/clang++)

set(CMAKE_CXX_STANDARD 23)

set(CMAKE_CXX_STANDARD_REQUIRED On)

set(CMAKE_CXX_EXTENSIONS Off)

set(CMAKE_OSX_DEPLOYMENT_TARGET 13.3)

set(CMAKE_EXPORT_COMPILE_COMMANDS On)

add_compile_options(

    -stdlib=libc++

    -nostdinc++

    "-isystem/usr/local/include"

    "-isystem/opt/local/libexec/llvm-22/include/c++/v1"

    "-isystem/opt/local/libexec/llvm-22/lib/clang/22/include"

)

add_link_options(

    -stdlib=libc++

    "-Wl,-rpath,/opt/local/libexec/llvm-22/lib/libc++"

    "-Wl,-rpath,/opt/local/libexec/llvm-22/lib/libunwind"

    "-L/opt/local/libexec/llvm-22/lib/libc++"

    "-L/opt/local/libexec/llvm-22/lib/libunwind"

)
