Skip to content

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

Open
lethalbit wants to merge 1 commit intobytecodealliance:mainfrom
lethalbit:aki/wasmtime-cmake-noinstall
Open

Improve c-api behavior when used as a CMake subproject#13157
lethalbit wants to merge 1 commit intobytecodealliance: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
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