Skip to content

Conversation

@andrewfb
Copy link
Collaborator

CMake Build System Improvements for Windows and macOS

Summary

This PR is a little bit of grab-bag of CMake updates and improvements.

Key Changes

Windows CMake Improvements

  • Added ANGLE (OpenGL ES via Direct3D) support with CINDER_GL_ANGLE option
  • Added D3D11 renderer to CMake builds
  • ANGLE DLLs are automatically copied to output directory when building apps
  • Fixed MSVC runtime library selection: static CRT (/MT) for static builds, dynamic CRT (/MD) for DLL builds

macOS GLFW High-Density Display Fix

  • Fixed retina display support that was broken after GLFW migration
  • Window::getContentScale() now correctly returns content scale for GLFW windows
  • WindowImplGlfw sets GLFW_COCOA_RETINA_FRAMEBUFFER hint based on app settings
  • RendererImplGlfwGl::defaultResize() now correctly uses framebuffer size for viewport but window size for matrices

Sample Build Organization

Created samples/_AllSamples/CMakeLists.txt as a standalone project for building all samples. The root CMakeLists.txt now delegates to _AllSamples when CINDER_BUILD_ALL_SAMPLES=ON.

By default, all sample outputs go to a centralized <build-dir>/bin directory:

build/
  bin/
    BasicApp.app
    Earthquake.app
    _opengl-Cube.app
    ...

To instead build each sample to its own directory (useful when working on individual samples), pass -DCINDER_SAMPLES_INLINE_BUILD=ON:

samples/
  BasicApp/
    proj/cmake/build/Debug/
      BasicApp.app
  Earthquake/
    proj/cmake/build/Debug/
      Earthquake.app
  ...

The inline layout places outputs next to each sample's source, making it easy to find and run individual samples during development. However, CMake's clean target only removes files (not directories), so .app bundle folders will remain as empty shells after cleaning.

Platform-specific skip lists automatically exclude incompatible samples (D3D11 on Mac, Metal on Windows, etc.).

New ci_require_platform() Macro

  • Allows samples to declare platform requirements at the top of their CMakeLists.txt
  • Gracefully skips configuration on unsupported platforms
  • Example: ci_require_platform( MSW ) for Windows-only samples

macOS Info.plist Handling

  • Removed Xcode-specific plist file usage
  • All samples now use CMake-generated Info.plist with MACOSX_BUNDLE_* properties
  • Added plutil post-build command to set NSHighResolutionCapable=false (using CMAKE_SYSTEM_NAME for portability) for most samples
  • HighDensityDisplay sample sets NSHighResolutionCapable=true as it specifically tests retina

Various Sample Bug Fixes

  • Fixed CanvasUi and CanvasUiMinimap crash: moved ImGui::Initialize() before setWindowSize() to prevent draw calls before initialization
  • Fixed Cairo-based samples on MSW by adding libpng.lib dependency
  • Fixed Metal samples to properly compile .mm files
  • Fixed ObjLoader sample resource path

Usage

Build all samples (centralized output):

mkdir build && cd build
cmake -DCINDER_BUILD_ALL_SAMPLES=ON ..
cmake --build .
# Outputs in build/bin/

Build all samples (inline output):

mkdir build && cd build
cmake -DCINDER_BUILD_ALL_SAMPLES=ON -DCINDER_SAMPLES_INLINE_BUILD=ON ..
cmake --build .
# Outputs in each sample's proj/cmake/build/ directory

Build from _AllSamples directly:

cd samples/_AllSamples
mkdir build && cd build
cmake ..
cmake --build .

@andrewfb andrewfb merged commit a4788c0 into cinder:master Jan 14, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant