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

First Light

Make your first CPU image, rasterize triangles, and trace an allocation budget.

Project files 15

Connect the CPU targets

Renderer, rasterizer, memory experiment, and their test targets.

47 lines CMakeLists.txt
cmake_minimum_required(VERSION 3.25)
project(PrismStudio VERSION 0.1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(PRISM_SANITIZERS "Enable address and undefined behavior sanitizers" OFF)

add_library(prism_core src/scene.cpp src/renderer.cpp src/raster_lab.cpp src/memory_lab.cpp)
target_include_directories(prism_core PUBLIC include)
target_compile_features(prism_core PUBLIC cxx_std_23)
function(prism_warnings target)
  if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
    target_compile_options(${target} PRIVATE -Wall -Wextra -Wpedantic -Wconversion -Wshadow)
  endif()
endfunction()
prism_warnings(prism_core)
if(PRISM_SANITIZERS AND CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
  target_compile_options(prism_core PUBLIC -fsanitize=address,undefined -fno-omit-frame-pointer)
  target_link_options(prism_core PUBLIC -fsanitize=address,undefined)
endif()

add_executable(prism-render src/main.cpp)
target_link_libraries(prism-render PRIVATE prism_core)
add_executable(prism-memory src/memory_main.cpp)
target_link_libraries(prism-memory PRIVATE prism_core)
add_executable(prism-raster src/raster_main.cpp)
target_link_libraries(prism-raster PRIVATE prism_core)
foreach(target prism-render prism-memory prism-raster)
  prism_warnings(${target})
endforeach()

include(CTest)
if(BUILD_TESTING)
  add_executable(prism-tests tests/prism_tests.cpp)
  target_link_libraries(prism-tests PRIVATE prism_core)
  prism_warnings(prism-tests)
  add_test(NAME prism-native-contracts COMMAND prism-tests)
  add_test(NAME prism-memory-experiment COMMAND prism-memory)
  add_test(NAME prism-cli-help COMMAND prism-render --help)
  add_test(NAME prism-cli-invalid-arguments COMMAND prism-render)
  set_tests_properties(prism-cli-invalid-arguments PROPERTIES WILL_FAIL TRUE)
  add_test(NAME prism-cli-output-failure COMMAND prism-render
    "${CMAKE_CURRENT_BINARY_DIR}/nonexistent-output-directory/image.ppm")
  set_tests_properties(prism-cli-output-failure PROPERTIES WILL_FAIL TRUE)
  add_test(NAME prism-raster-help COMMAND prism-raster --help)
endif()

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

Taking your work offline? Download all course companions