Skip to content

Conversation

Xaymar
Copy link
Contributor

@Xaymar Xaymar commented Oct 2, 2025

Description

Fixes a mistake in the libobs-metal CMake file that was likely missed due to unexpected CMake behavior. When ENABLE_PLUGINS is set to OFF we don't actually ever enable Swift support and CMake delays the error for this until after the configure stage. This behavior is hidden by mac-virtualcam which does call the proper functions.

Motivation and Context

When ENABLE_PLUGINS (since 32.0.0) is set to OFF strange CMake errors are reported and the build fails. These patches fix the mistake in the CMake code and allowed us to keep libobs as a dependency.

How Has This Been Tested?

We've been able to successfully build libOBS with ENABLE_PLUGINS=OFF locally and on Github Actions with these patches applied.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

I did not check any of the ones that don't apply here.

@PatTheMav
Copy link
Member

The ENABLE_UI option was renamed to ENABLE_FRONTEND. Explicitly enabling Swift support in the Metal renderer is probably the correct fix though - I'm surprised CMake doesn't fail for a default project configuration even though it's missing.

My only hunch is that the same call in the virtual camera module "fixes" it by default, but when plugins are disabled it's missing for the Metal renderer.

@Xaymar
Copy link
Contributor Author

Xaymar commented Oct 3, 2025

The ENABLE_UI option was renamed to ENABLE_FRONTEND.

I've likely misidentified the cause then, and definitely missed the change as the commit was titled "frontend: Migrate CMake files". There's a few spots that weren't correctly changed which might have caused features to go missing from obs-scripting: 1, 2, 3, 4, 5, 6, 7, and a few more. I'll test the change again with the correct switch applied to see if it's even needed.

My only hunch is that the same call in the virtual camera module "fixes" it by default, but when plugins are disabled it's missing for the Metal renderer.

That is indeed the behavior that CMake emits here, though it's not entirely clear why. My best guess is that even though they're configured in a specific order, CMake doesn't actually process the actual steps for add_library/add_executable until after configure. And at that point with ENABLE_PLUGINS=ON the mac-virtualcam plugin has called enable_language(Swift) for us.

@Xaymar Xaymar marked this pull request as draft October 3, 2025 01:56
We need to explicitly enable Swift language support if ENABLE_PLUGINS
is set to OFF.
@Xaymar Xaymar force-pushed the patch-libobs-as-lib branch from cf3aa61 to d23c66b Compare October 3, 2025 02:08
@Xaymar Xaymar changed the title Fix building libOBS with ENABLE_UI=OFF and ENABLE_PLUGINS=OFF libobs-metal: Explicitly enable Swift language support if ENABLE_PLUGINS is OFF Oct 3, 2025
@Xaymar Xaymar marked this pull request as ready for review October 3, 2025 02:11
@Xaymar
Copy link
Contributor Author

Xaymar commented Oct 3, 2025

I've tested it locally and with Github Actions and we indeed only need the libobs-metal fix. The other patch was removed entirely, both from our code as well as the pull request, and the necessary text adjusted as needed.

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