Skip to content

Reorganize C++ samples to match other languages (cleanup only, no functionality changes)#727

Open
Wayne-Ch wants to merge 2 commits into
mainfrom
Wayne-Ch/fix-cpp-sample-layout
Open

Reorganize C++ samples to match other languages (cleanup only, no functionality changes)#727
Wayne-Ch wants to merge 2 commits into
mainfrom
Wayne-Ch/fix-cpp-sample-layout

Conversation

@Wayne-Ch
Copy link
Copy Markdown
Collaborator

Summary

Repo cleanup. Every other language SDK keeps its samples under samples/<lang>/; only C++ inlined them under sdk/cpp/sample/. This moves both C++ samples to samples/cpp/ to match.

Language Samples location before Samples location after
Python samples/python/ unchanged
JS samples/js/ unchanged
Rust samples/rust/ unchanged
C# samples/cs/ unchanged
C++ sdk/cpp/sample/ (unique) samples/cpp/ (consistent)

What moved

From To
sdk/cpp/sample/main.cpp samples/cpp/sdk-quickstart/main.cpp
sdk/cpp/sample/web-server-responses-vision/* samples/cpp/web-server-responses-vision/*

What did NOT change

  • No SDK API edits, no .cpp/.h source edits in sdk/cpp/
  • The customer-facing SDK zip still bundles the vision sample (install path updated); cmake --install produces a byte-identical layout
  • Target name CppSdkSample kept (renaming would be a behavior change)
  • Vision sample preserved end-to-end
  • Small local workaround added in both samples' CMakeLists.txt to re-derive FL_*_DLL_DIR before the post-build DLL copy — fixes a pre-existing standalone-build latency without touching the SDK helper itself

Risk / follow-ups

  • External blog or doc links pointing to sdk/cpp/sample/... will break. Recommend a quick docs sweep.
  • Consider promoting FL_CORE_DLL_DIR / FL_ORT_DLL_DIR / FL_ORTGENAI_DLL_DIR to CACHE vars in sdk/cpp/CMakeLists.txt in a follow-up PR — that would let every future C++ sample call fl_copy_runtime_dlls() without the local workaround.
  • samples/cpp/translation-perf-benchmark/ (not in this PR) already lives under the new convention — heads-up before this merges.

Verification

  • sdk/cpp clean build: 16/16 ninja steps pass; tests still compile
  • samples/cpp/sdk-quickstart configure + build: succeeds; exe + Foundry Local Core DLL + ONNX Runtime DLLs land in the build dir
  • samples/cpp/web-server-responses-vision configure + build: succeeds; same DLL set lands in the build dir
  • cmake --install of the SDK: byte-identical zip layout (bin/ + cmake/ + include/ + lib/ + sample/web-server-responses-vision/)
  • git ls-files | Select-String "sdk/cpp/sample" → empty
  • .github/workflows/ has no C++ sample references to update

Reviewer asks

  1. OK with the sample folder name sdk-quickstart?
  2. OK with keeping the binary name CppSdkSample?
  3. Anyone need the install-zip destination renamed too, or leave it as sample/web-server-responses-vision/ for back-compat?

Pure relocation, no functionality removed. All other language SDKs
(Python, JS, Rust, C#) keep samples under samples/<lang>/; the C++
SDK was unique in inlining samples under sdk/cpp/sample/. This moves
both samples to match the convention, and rewires the build system
so each sample becomes standalone-buildable like every other language.

Moves (git mv):
  sdk/cpp/sample/main.cpp
    -> samples/cpp/sdk-quickstart/main.cpp
  sdk/cpp/sample/web-server-responses-vision/*
    -> samples/cpp/web-server-responses-vision/*

sdk/cpp/CMakeLists.txt:
  - Drop inline CppSdkSample and WebServerResponsesVision exe targets
    (samples now self-build via add_subdirectory(sdk/cpp))
  - Drop VS_STARTUP_PROJECT (no longer relevant to the SDK build)
  - Update install() to source the vision sample from its new path
    so the customer-facing SDK zip layout is unchanged

samples/cpp/sdk-quickstart/ (new build files):
  - CMakeLists.txt mirrors samples/cpp/<other>/ pattern: find_package
    with add_subdirectory fallback, target name CppSdkSample preserved
  - CMakePresets.json, vcpkg.json, vcpkg-configuration.json added

samples/cpp/web-server-responses-vision/:
  - CMakeLists.txt: SDK path updated (../.. -> ../../../sdk/cpp)
  - CMakePresets.json: overlay-triplets path updated to the same

Both samples: re-derive FL_*_DLL_DIR before calling fl_copy_runtime_dlls.
The SDK sets those vars as non-CACHE, so they aren't visible to
sub-projects (a latent bug in the standalone build paths the samples'
READMEs already document). Re-deriving them locally is a one-line
workaround that fixes the standalone DLL copy without touching the SDK.

Docs:
  - sdk/cpp/README.md: vision-sample section + tree diagram updated
  - samples/README.md: add C++ row

Verified end-to-end:
  - sdk/cpp builds (16/16 ninja steps), tests still compile
  - samples/cpp/sdk-quickstart builds, exe + Foundry Local Core
    DLL + ONNX Runtime DLLs all land in the build dir
  - samples/cpp/web-server-responses-vision builds, same DLL set
    lands in the build dir
  - SDK install (cmake --install) produces byte-identical zip layout:
    bin/ + cmake/ + include/ + lib/ + sample/web-server-responses-vision/
  - git ls-files | grep "sdk/cpp/sample" returns nothing
  - .github/workflows/ has no C++ sample references to update
Copilot AI review requested due to automatic review settings May 26, 2026 23:41
@vercel
Copy link
Copy Markdown

vercel Bot commented May 26, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
foundry-local Ready Ready Preview, Comment May 29, 2026 9:40pm

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reorganizes the C++ samples to live under samples/cpp/ (consistent with the other language SDKs), and updates the C++ SDK docs/build/install wiring accordingly.

Changes:

  • Removed the inlined C++ sample targets from sdk/cpp/CMakeLists.txt and moved the sample sources under samples/cpp/.
  • Updated sdk/cpp/README.md and samples/README.md to point to the new sample locations.
  • Added standalone CMake + vcpkg manifests for the moved C++ samples, plus a local workaround to re-derive FL_*_DLL_DIR before invoking fl_copy_runtime_dlls().

Reviewed changes

Copilot reviewed 10 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
sdk/cpp/README.md Updates documentation links/commands to reference the new samples/cpp/... locations.
sdk/cpp/CMakeLists.txt Removes sample build targets from the SDK build; updates SDK install step to source the vision sample from samples/cpp/.
samples/README.md Adds C++ to the top-level samples index and describes the C++ sample set.
samples/cpp/web-server-responses-vision/vcpkg.json Adds vcpkg manifest dependencies for the vision Responses API sample.
samples/cpp/web-server-responses-vision/vcpkg-configuration.json Pins the vcpkg baseline for the vision sample.
samples/cpp/web-server-responses-vision/test_image.jpg Adds the default test image used by the vision sample.
samples/cpp/web-server-responses-vision/stb_impl.cpp Adds the single translation unit for stb implementations.
samples/cpp/web-server-responses-vision/README.md Updates the working directory path for building/running after the move.
samples/cpp/web-server-responses-vision/main.cpp Adds the standalone C++ vision streaming (SSE) sample implementation.
samples/cpp/web-server-responses-vision/CMakePresets.json Adds CMake presets to build the vision sample with vcpkg on Windows.
samples/cpp/web-server-responses-vision/CMakeLists.txt Adds standalone CMake project that can consume the prebuilt SDK or build it from source.
samples/cpp/sdk-quickstart/vcpkg.json Adds vcpkg manifest dependencies for the quickstart sample.
samples/cpp/sdk-quickstart/vcpkg-configuration.json Pins the vcpkg baseline for the quickstart sample.
samples/cpp/sdk-quickstart/main.cpp Adds the standalone C++ SDK quickstart sample implementation.
samples/cpp/sdk-quickstart/CMakePresets.json Updates preset overlay triplet path for the new directory layout.
samples/cpp/sdk-quickstart/CMakeLists.txt Adds standalone CMake project for the quickstart sample, including DLL copy workaround.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Resolves samples/README.md conflict: keep main's WinML EP verification description updates for C#/JS/Python/Rust and the bumped counts, keep this branch's C++ row (3 samples: sdk-quickstart, live-audio-transcription, web-server-responses-vision) in alphabetical order between C# and JavaScript.
@Wayne-Ch
Copy link
Copy Markdown
Collaborator Author

@microsoft-github-policy-service agree company="Microsoft"

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.

2 participants