Skip to content

Improve c-api behavior when used as a CMake subproject#13157

Merged
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
lethalbit:aki/wasmtime-cmake-noinstall
Apr 21, 2026
Merged

Improve c-api behavior when used as a CMake subproject#13157
alexcrichton merged 1 commit into
bytecodealliance:mainfrom
lethalbit:aki/wasmtime-cmake-noinstall

Conversation

@lethalbit

Copy link
Copy Markdown
Contributor

Hey it's me again!

I expect a bit of deliberation on this as it changes some default behaviour, and could likely be massaged a bit to be a bit better in a way that I'm likely not thinking of, but here's the gist.

This PR adds one new CMake option and changes the default behavior when being used as a subproject.

First, off, the WASMTIME_ALWAYS_INSTALL option was added, to override the new behavior and keep it working like it was previously.

Next, we check to see if the wasmtime cmake project is being used as a subproject (e.g. it was loaded up with add_subdirectory) if so, then we disable the installation of the headers and static library artifacts. However if BUILD_SHARED_LIBS is enabled, even as a subproject we always install the shared object artifact. If WASMTIME_ALWAYS_INSTALL is set, then regardless we install everything as before.

If keeping old behaviour as a default is prefered, then it would be easy enough to flip things around and rename WASMTIME_ALWAYS_INSTALL and have it turn-off installing things when being used as a subproject. I know changing defaults out from under people is not very nice, but my personal opinion on this is that this is generally how well-behaved subprojects are expected to act anyway.

Either way, look forward to your feedback and thoughts!

This commit adds one new CMake option and changes the default behavior when being used as a subproject.

First, off, the `WASMTIME_ALWAYS_INSTALL` option was added, to override the new behavior and keep it working like it was previously.

Next, we check to see if the wasmtime cmake project is being used as a subproject (e.g. it was loaded up with `add_subdirectory`) if so, then we disable the installation of the headers and static library artifacts. However if `BUILD_SHARED_LIBS` is enabled, even as a subproject we always install the shared object artifact. If `WASMTIME_ALWAYS_INSTALL` is set, then regardless we install everything as before.
@lethalbit lethalbit requested a review from a team as a code owner April 21, 2026 00:47
@lethalbit lethalbit requested review from alexcrichton and removed request for a team April 21, 2026 00:47
@github-actions github-actions Bot added the wasmtime:c-api Issues pertaining to the C API. label Apr 21, 2026

@alexcrichton alexcrichton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Seems reasonable to me, thanks!

@alexcrichton alexcrichton added this pull request to the merge queue Apr 21, 2026
Merged via the queue into bytecodealliance:main with commit 9d08671 Apr 21, 2026
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasmtime:c-api Issues pertaining to the C API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants