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


edit this page