Skip to content

Conversation

@PatTheMav
Copy link
Member

@PatTheMav PatTheMav commented Nov 1, 2023

Description

Completes the migration of OBS Studio's build system to the updated CMake 3.0 build path introduced to macOS and Windows before.

Important

This PR is directly based on top of #9769, which should be reviewed and merged first, at which point a rebase will reduce the amount of changes introduced by this PR.

Additional squashing of commits will be done after reviews are finished.

This PR builds on all the systems and methods introduced for other platforms before and extends it:

  • Added updated find modules for Linux-specific dependencies:
    • JACK audio
    • LibUUID
    • Libdrm
    • Libfdk
    • Libpci
    • Libudev
    • Libv4l2
    • Libva
    • OSS
    • PipeWire
    • PulseAudio
    • Sndio
    • Sysinfo
    • Wayland
    • glib and gio
    • X11-xcb
    • XCB
    • xkbcommon
  • Updates existing find modules to improve compatibility with Linux:
    • FFmpeg (improved version extraction from ffversion.h)
    • Libx264 (improved version extraction from x264_config.h)
    • LuaJIT (switched version extraction to use LuaJIT version and not Lua version)
    • MbedTLS (improved version extraction from mbedtls/version.h)
  • Find modules should be able to locate dependencies either via pkg-config hints or CMake's build in dependency detection
  • Added check for possibly separate math library provided by toolchain to explicitly link to it when necessary
  • Added some additional checks for the presence of headers in system include paths
  • Updated all Linux-specific modules:
    • linux-alsa
    • linux-capture
    • linux-jack
    • linux-pipewire
    • linux-pulseaudio
    • linux-v4l2
    • oss-audio
    • sndio
  • Updated Linux-specific code for already updated modules:
    • libobs
    • obs-libfdk
    • obs-ffmpeg
    • obs-outputs
    • obs-qsv11
    • UI
    • aja
    • vlc
  • Enabled support for Python 3.11+ outside of Windows and macOS
  • Fixed simple GCC compile warnings (unused code)
  • Add GCC-specific warning suppressions where appropriate (usually for parity with Clang-specific warnings)
  • Updated default GCC compiler flags for parity with Clang compiler flags
  • Retained reasonable FreeBSD compatibility (updated Cirrus CI file to enable CMake 3.0 builds for FreeBSD)
  • Updated CI build scripts and GitHub Actions workflows

Note

Lower CMake version boundary is not increased by this PR, the minimum required version on Linux will still be CMake 3.22.

Fixes #7407.
Fixes #7972.
Closes #10008.

Motivation and Context

Remove legacy code and improve CMake codebase for Linux (and FreeBSD) and achieve parity with Windows and macOS.

How Has This Been Tested?

Tested on Ubuntu 23.04 and FreeBSD 13.2.

Types of changes

  • Code cleanup (non-breaking change which makes code smaller or more readable)

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.

@PatTheMav PatTheMav force-pushed the linux-build-update branch 4 times, most recently from 35f2103 to 84d4c4f Compare November 1, 2023 17:41
@tytan652
Copy link
Collaborator

tytan652 commented Nov 1, 2023

CMake 3.0 does not provide support for system ftl-sdk install.

@tytan652
Copy link
Collaborator

tytan652 commented Nov 1, 2023

Made a packaging test build on Arch Linux and many headers are missing as it is.

example.h indicate a missing header compared to a build without the PR.

Screenshot from 2023-11-01 22-11-01

Screenshot from 2023-11-01 22-11-28

I didn't dig further but for some reason obs-browser-page locale file are no longer installed, I don't know if it's intended error.html is missing too. I do use your obs-browser branch.

@tytan652
Copy link
Collaborator

tytan652 commented Nov 1, 2023

I forgot to mention, the pkg-config file for libobs is no longer installed.
On Linux, even if there is a CMake package, this method is not universal among build-systems (pkg-config is).

@PatTheMav
Copy link
Member Author

I forgot to mention, the pkg-config file for libobs is no longer installed. On Linux, even if there is a CMake package, this method is not universal among build-systems (pkg-config is).

We should add a handcrafted pkg-config file - generating it from CMake will break the moment generator expressions are used in the dependency graph (or at the very least make it complicated to generate one).

Some elements might be generated automatically (e.g. version) but CFlags and everything surround static/shared requirements should be written by hand.

I'm happy to add that if someone can provide me the template file for it.

@tytan652
Copy link
Collaborator

tytan652 commented Nov 2, 2023

You should force the Flatpak to build with CMake 3.0 (without preset), there is many issues not revealed in CI because of that.

@PatTheMav
Copy link
Member Author

You should force the Flatpak to build with CMake 3.0 (without preset), there is many issues not revealed in CI because of that.

I deliberately not updated that yet because I wanted to leave that to you or @GeorgesStavracas to update when you can support the migration.

@tytan652
Copy link
Collaborator

tytan652 commented Nov 2, 2023

I deliberately not updated that yet because I wanted to leave that to you or @GeorgesStavracas to update when you can support the migration.

I will not debug this post merge, this should pass all Linux CI with CMake 3.0. Also what migration ?

@PatTheMav
Copy link
Member Author

I deliberately not updated that yet because I wanted to leave that to you or @GeorgesStavracas to update when you can support the migration.

I will not debug this post merge, this should pass all Linux CI with CMake 3.0. Also what migration ?

When this PR is merged, it will not automatically default to the new CMake build variant if no preset is selected, it is "opt-in" (like it is on Windows right now). That way packagers/maintainers can chose when to make the switch and report bugs that might not have been discovered during review without breaking the ability to still generate packages.

That timeframe until either a preset is required or the legacy code paths are removed is the migration period (so far we waited a full release cycle to remove the legacy path for macOS, Windows legacy and x86 slices might be removed with the version after the next) so the Flatpak update does not have to occur at the same time but can happen at a later point.

That's up to the Flatpak maintainers to decide and adapt.

@tytan652
Copy link
Collaborator

tytan652 commented Nov 2, 2023

AJA is broken, on Flatpak and Arch Linux.

[152/509] Linking CXX shared module plugins/aja/aja.so
FAILED: plugins/aja/aja.so 
: && /usr/bin/c++ -fPIC -O3 -DNDEBUG  -L/app/lib -shared  -o plugins/aja/aja.so plugins/aja/CMakeFiles/aja-support.dir/aja-card-manager.cpp.o plugins/aja/CMakeFiles/aja-support.dir/aja-common.cpp.o plugins/aja/CMakeFiles/aja-support.dir/aja-presets.cpp.o plugins/aja/CMakeFiles/aja-support.dir/aja-props.cpp.o plugins/aja/CMakeFiles/aja-support.dir/aja-routing.cpp.o plugins/aja/CMakeFiles/aja-support.dir/aja-vpid-data.cpp.o plugins/aja/CMakeFiles/aja-support.dir/aja-widget-io.cpp.o plugins/aja/CMakeFiles/aja.dir/aja-output.cpp.o plugins/aja/CMakeFiles/aja.dir/aja-source.cpp.o plugins/aja/CMakeFiles/aja.dir/audio-repack.c.o plugins/aja/CMakeFiles/aja.dir/main.cpp.o  -Wl,-rpath,/home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/rundir/Release/lib:/home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/libobs:  libobs/libobs.so.30  /app/lib/libajantv2.a && cd /home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/plugins/aja && /usr/bin/cmake -E make_directory /home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/rundir/Release/lib/obs-plugins && /usr/bin/cmake -E copy_if_different /home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/plugins/aja/aja.so /home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/rundir/Release/lib/obs-plugins && cd /home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/plugins/aja && /usr/bin/cmake -E make_directory /home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/rundir/Release/share/obs/obs-plugins/aja && /usr/bin/cmake -E copy_directory /home/tytan652/Programming/OBS/obs-studio/plugins/aja/data /home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/rundir/Release/share/obs/obs-plugins/aja
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: plugins/aja/CMakeFiles/aja-support.dir/aja-routing.cpp.o: warning: relocation against `_ZTVSt9basic_iosIcSt11char_traitsIcEE@@GLIBCXX_3.4' in read-only section `.text.unlikely'
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: plugins/aja/CMakeFiles/aja-support.dir/aja-card-manager.cpp.o: relocation R_X86_64_PC32 against symbol `__libc_single_threaded@@GLIBC_2.32' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
[157/509] Building C object plugins/linux-capture/CMakeFiles/linux-capture.dir/xshm-input.c.o
ninja: build stopped: subcommand failed.

@RytoEX RytoEX added Code Cleanup Non-breaking change which makes code smaller or more readable New Feature New feature or plugin labels Nov 2, 2023
@RytoEX RytoEX added this to the OBS Studio (Next Version) milestone Nov 2, 2023
Copy link
Collaborator

@tytan652 tytan652 left a comment

Choose a reason for hiding this comment

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

Review of the GIO finder with suggestions to make it work correctly.

@PatTheMav
Copy link
Member Author

AJA is broken, on Flatpak and Arch Linux.

[152/509] Linking CXX shared module plugins/aja/aja.so
FAILED: plugins/aja/aja.so 
: && /usr/bin/c++ -fPIC -O3 -DNDEBUG  -L/app/lib -shared  -o plugins/aja/aja.so plugins/aja/CMakeFiles/aja-support.dir/aja-card-manager.cpp.o plugins/aja/CMakeFiles/aja-support.dir/aja-common.cpp.o plugins/aja/CMakeFiles/aja-support.dir/aja-presets.cpp.o plugins/aja/CMakeFiles/aja-support.dir/aja-props.cpp.o plugins/aja/CMakeFiles/aja-support.dir/aja-routing.cpp.o plugins/aja/CMakeFiles/aja-support.dir/aja-vpid-data.cpp.o plugins/aja/CMakeFiles/aja-support.dir/aja-widget-io.cpp.o plugins/aja/CMakeFiles/aja.dir/aja-output.cpp.o plugins/aja/CMakeFiles/aja.dir/aja-source.cpp.o plugins/aja/CMakeFiles/aja.dir/audio-repack.c.o plugins/aja/CMakeFiles/aja.dir/main.cpp.o  -Wl,-rpath,/home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/rundir/Release/lib:/home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/libobs:  libobs/libobs.so.30  /app/lib/libajantv2.a && cd /home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/plugins/aja && /usr/bin/cmake -E make_directory /home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/rundir/Release/lib/obs-plugins && /usr/bin/cmake -E copy_if_different /home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/plugins/aja/aja.so /home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/rundir/Release/lib/obs-plugins && cd /home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/plugins/aja && /usr/bin/cmake -E make_directory /home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/rundir/Release/share/obs/obs-plugins/aja && /usr/bin/cmake -E copy_directory /home/tytan652/Programming/OBS/obs-studio/plugins/aja/data /home/tytan652/.cache/gnome-builder/projects/obs-studio/builds/com.obsproject.Studio.json-flatpak-org.kde.Platform-6.5-x86_64-linux-build-update/rundir/Release/share/obs/obs-plugins/aja
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: plugins/aja/CMakeFiles/aja-support.dir/aja-routing.cpp.o: warning: relocation against `_ZTVSt9basic_iosIcSt11char_traitsIcEE@@GLIBCXX_3.4' in read-only section `.text.unlikely'
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: plugins/aja/CMakeFiles/aja-support.dir/aja-card-manager.cpp.o: relocation R_X86_64_PC32 against symbol `__libc_single_threaded@@GLIBC_2.32' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-unknown-linux-gnu/12.2.0/../../../../x86_64-unknown-linux-gnu/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
[157/509] Building C object plugins/linux-capture/CMakeFiles/linux-capture.dir/xshm-input.c.o
ninja: build stopped: subcommand failed.

That might require explicitly setting the POSITION_INDEPENDENT_CODE target property - I just have to find out for which target specifically.

@IGN-Styly
Copy link

Fails to build on linux?

@PatTheMav
Copy link
Member Author

PR has been rebased and updated but still requires the browser and websocket submodules to be updated first.

@PatTheMav PatTheMav force-pushed the linux-build-update branch 4 times, most recently from 975e1b8 to 15f890a Compare April 13, 2024 18:10
@RytoEX
Copy link
Member

RytoEX commented Apr 13, 2024

@PatTheMav and I did some off-thread testing and debugging and found a few lingering items to fix up. Will re-check this "soon".

@PatTheMav PatTheMav force-pushed the linux-build-update branch 2 times, most recently from f52ab63 to 197659a Compare April 13, 2024 22:46
@PatTheMav PatTheMav force-pushed the linux-build-update branch from 197659a to c490439 Compare April 14, 2024 01:46
@PatTheMav PatTheMav force-pushed the linux-build-update branch from c490439 to 218a9f2 Compare April 14, 2024 02:02
Copy link
Member

@RytoEX RytoEX left a comment

Choose a reason for hiding this comment

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

Looks good on Windows 11. I tested on Ubuntu earlier today. If we missed something or if anything is not working it will surely be brought to our attention.

@RytoEX RytoEX merged commit fb4d658 into obsproject:master Apr 14, 2024
@PatTheMav PatTheMav deleted the linux-build-update branch April 14, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code Cleanup Non-breaking change which makes code smaller or more readable New Feature New feature or plugin Seeking Testers Build artifacts on CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libobs pkgconfig (and possibly cmake) configs are broken on non-x86_64 (particularly AArch64) release tarballs miss required sources

6 participants