Theme Catppuccin
Make yourself at homeCatppuccin

A softer light for long learning sessions.

Appearance

Loading your preference…

Dark palette

Choose a dark palette to try it.

Light uses Latte. Your choices stay in this browser.

Back to your source shelf

Inside the companion

Metal · Copper Orchard

Connect a Cocoa window to a C++ Metal renderer and verify GPU results.

Project files 7

Connect C++ to the Apple frameworks

Build the Metal probes and window bridge with Clang and optional metal-cpp headers.

30 lines CMakeLists.txt
cmake_minimum_required(VERSION 3.24)
project(copper_orchard_probe LANGUAGES CXX OBJCXX)
if(NOT APPLE)
  message(FATAL_ERROR "Copper Orchard requires macOS and the Apple SDK")
endif()
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_OBJCXX_STANDARD 23)
set(CMAKE_OBJCXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_OBJCXX_EXTENSIONS OFF)
add_executable(orchard-probe orchard_probe.mm)
target_compile_options(orchard-probe PRIVATE -fobjc-arc -Wall -Wextra -Wpedantic)
target_link_libraries(orchard-probe PRIVATE "-framework Foundation" "-framework Metal")
set(METAL_CPP_INCLUDE_DIR "" CACHE PATH "Path containing Foundation/ and Metal/ metal-cpp headers")
if(METAL_CPP_INCLUDE_DIR)
  add_executable(orchard-cpp-device metal_cpp_device.cpp)
  target_include_directories(orchard-cpp-device SYSTEM PRIVATE "${METAL_CPP_INCLUDE_DIR}")
  target_compile_options(orchard-cpp-device PRIVATE -Wall -Wextra -Wpedantic)
  target_link_libraries(orchard-cpp-device PRIVATE "-framework Foundation" "-framework Metal")
  add_executable(orchard-window orchard_window.mm window_renderer.cpp)
  target_include_directories(orchard-window SYSTEM PRIVATE "${METAL_CPP_INCLUDE_DIR}")
  target_compile_options(orchard-window PRIVATE -Wall -Wextra -Wpedantic -Wconversion -Wshadow
    "$<$<COMPILE_LANGUAGE:OBJCXX>:-fobjc-arc>")
  target_link_libraries(orchard-window PRIVATE "-framework Cocoa" "-framework MetalKit"
    "-framework Foundation" "-framework Metal" "-framework QuartzCore")
endif()
enable_testing()
add_test(NAME bounded-compute COMMAND orchard-probe)

This is the file included with the course. Copy and download give you its complete source.

Taking your work offline? Download all course companions