Skip to content

demos/distrib: Generate CMake presets for the demos in the release package - #439

Open
KonradBreitsprecherBkd wants to merge 3 commits into
mainfrom
dev_cmakepresets_for_demos
Open

KonradBreitsprecherBkd wants to merge 3 commits into
mainfrom
dev_cmakepresets_for_demos

Conversation

@KonradBreitsprecherBkd

Copy link
Copy Markdown
Contributor

The SilKit-Demos folder of a release package now contains a generated CMakePresets.json that only offers presets for the package's architecture:

  • Windows: x64-release / x64-debug or x86-release / x86-debug (Ninja, architecture strategy external)
  • Linux: release / debug (Unix Makefiles)

Without it, Visual Studio ("Open Folder") or VS Code could configure a 32-bit build for a 64-bit SIL Kit package.

Changes

  • Demos/CMakePresets.json.in: new presets template. It is left out of the plain demo install.
  • SilKit/cmake/SilKitDemoPresets.cmake: new silkit_install_demo_presets(), which detects the platform, configures the template and installs it to
  • CMakeLists.txt: calls it in the SILKIT_INSTALL_SOURCE block.
  • Docs: docs/demos/build.rst explains how to use the presets in Visual Studio and on the command line, and the changelog has a new entry.

…lKit-Demos based on the build arch

Signed-off-by: Konrad Breitsprecher <Konrad.Breitsprecher@vector.com>
Signed-off-by: Konrad Breitsprecher <Konrad.Breitsprecher@vector.com>
Comment thread CMakeLists.txt Resolved
@KonradBreitsprecherBkd KonradBreitsprecherBkd added the status: ready for review Complete and waiting for a reviewer. label Oct 21, 2026
MariusBgm

This comment was marked as resolved.

Comment thread SilKit/cmake/SilKitDemoPresets.cmake Resolved
@MariusBgm

Copy link
Copy Markdown
Collaborator

I tested this on Windows with packages built from this branch (release and x86-release), opening SilKit-Demos from the unzipped package:

Package Visual Studio VS Code, clean start VS Code, 64-bit developer environment loaded
x64 builds not tested builds
x86 builds builds, binaries are x86 (dumpbin: 14C machine (x86)) fails with the original error: SilKitConfig.cmake, version: 5.0.8 (32bit) not accepted

So the presets fix Visual Studio, and VS Code as long as it starts without a developer env.

When a developer env is already loaded, VS Code ignores the preset's architecture. With the default cmake.useVsDeveloperEnvironment: "auto", CMake Tools only sources vcvarsall for the preset's architecture if it can't find cl or ninja. A clean start also means closing every VS Code window first and deleting the build folder: VS Code keeps one process, so a window started from the Start menu while another one was open still had the 64-bit environment.

Should we document that in docs/demos/build.rst and or in the commit message?

- Use MSVC instead of WIN32 to choose the Windows presets, since WIN32
  also matches MinGW, which gets the Unix Makefiles presets instead.
- Lower the presets version to 2, which already supports
  buildPresets and the "external" architecture strategy.
- Install *.json.in files with the SilKit-Source package, so that
  CMakePresets.json.in is available when building from the source package.
- docs/demos/build.rst: document the presets for VS Code.

Known limitation with VS Code on Windows: the CMake Tools extension
(cmake.useVsDeveloperEnvironment: "auto") only loads the developer
environment for the preset's architecture if neither cl nor ninja is
found. If a developer environment for another architecture is already
loaded, the preset's architecture is ignored and configuring a 32-bit
package fails because the 32-bit SilKitConfig.cmake is not accepted.
Close all VS Code windows (VS Code reuses one process), delete the
build folder and start VS Code without a developer environment, or from
one that matches the package. Visual Studio is not affected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Konrad Breitsprecher <Konrad.Breitsprecher@vector.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: ready for review Complete and waiting for a reviewer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants