setting up cpp development on macos

Installing Git

Xcode

Apple ships a binary package of Git with Xcode. For me when I try and run g++ or gcc I instantly get the popup to install the command line tools

Homebrew

Install homebrew if you don't already have it, then:

brew install git
brew install git

Install Conan

Follow the guide on the conan official documentation, for me most of the time I use pipx because at least for me on mac when I installed it on mac using just pip then it wasn't on the path so I just decided to do it through pipx.

Adding a Profile

Once Conan is installed create a profile:

conan profile detect

Install CMake

brew install cmake

Note that Im usually doing this on outdated macos systems and this part takes like 1 hour to build cmake.

monitor system resources

brew install btop

Setting up SSH Connection

Generate a new SSH Key

Run the command below with your GitHub email:

ssh-keygen -t ed25519 -C "your_email@example.com"

GitHub

Clone Target Repo

git clone --recurse-submodules -j8 git://github.com/foo/bar.git

Note: -j8 is an optional performance optimization that became available in version 2.8, and fetches up to 8 submodules at a time in parallel — see man git-clone.

Installing and Building Files

On a fresh pull from GitHub, run the following in the root directory:

conan install . --build=missing

Use CMake to build the files with:

cmake --preset conan-release
cmake --build --preset conan-release

Now you can run the build:

./mwe_mac-example

Shoutout to Mich for putting this together


On old macs brew doesn't work, so use macports

  
    sudo port install python311
    sudo port select --set python python311

    sudo port install py311-pip
    sudo port select --set pip pip311

    
    sudo port install pipx
    pipx ensurepath
    pipx install conan

    sudo port install cmake

    
    sudo port install neovim
    sudo port install btop
    sudo port install kitty
  

edit this page