Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add cmake support #14

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Conversation

mcmtroffaes
Copy link

This patch adds cmake support. This is currently used by vcpkg to build theora on windows under msvc (since msvc has excellent cmake support these days). The cmake script builds the theora, theoraenc, and theoradec libraries, as well as the test suite, which it can run via ctest as usual.

In principle it can also be used to build theora under linux, macos, and other systems. I've tested the build on linux and it passes regression testing (even though it uses the windows source files from the x86_vc folder; it would be possible to change this with some configuration switches). It would not be too hard to fully support these systems properly.

An issue I ran into: msvc does not support inline assembler in 64 bit mode (see https://docs.microsoft.com/en-us/cpp/assembler/inline/inline-assembler?view=vs-2019: "Inline assembly is not supported on the ARM and x64 processors."). However the theora x86 optimisations for msvc are written in inline assembler. Therefore, these optimisations are currently only enabled for the 32 bit builds. To fix this, the assembler code would have to be moved to separate files. I'm not sure if it's worth the effort given most folks have likely moved on to more modern codecs, but I thought it was worth pointing out since you might wonder why the configuration is set up in this way.

@MrSapps
Copy link

MrSapps commented May 2, 2021

Is this every likely to be merged?

@mcmtroffaes
Copy link
Author

Looks like upstream is maintained here: https://gitlab.xiph.org/xiph/theora/ Will repost there when I get some time, as it seems that the devs don't consider github PRs.

@mcmtroffaes
Copy link
Author

@MrSapps
Copy link

MrSapps commented May 6, 2021

Hardly any activity over there? Is this project dead? I've been thinking about libvpx to use VP8/9 instead...

@petterreinholdtsen
Copy link
Contributor

There is also a request for mason build system in https://gitlab.xiph.org/xiph/theora/-/issues/2314 .

@petterreinholdtsen
Copy link
Contributor

It is unclear from this pull request and the issue listed on https://gitlab.xiph.org/xiph/theora/-/issues/2316 what the rationale for adding another build system is. As far as I can tell, theora autotools, scons, Visual studio in win32/ and a MacOSX build system in macosx/. When you move the patch on to gitlab.xiph.org, please include a rationale what problem adding cmake solve, if one of the existing build systems can be dropped with its introduction and perhaps also some information about the disadvantages of adding cmake.

I do not know cmake enough to make a judgement call on this myself, but hope to make a new release of theora next weekened and would love for someone to have a look at the build system situation by then. Having an updated patch available upstream for review would be great. Note, a new define OP_HAVE_CLOCK_GETTIME has been introduced since your original patch.

@tmatth
Copy link
Member

tmatth commented Mar 11, 2025

I'm also not keen on adding more buildsystems but I understand the desire for something more cross-platform friendly like meson or cmake...at a minimum, whatever buildsystem gets added would also need a pipeline (or pipelines) added for it in .gitlab-ci.yml

@mcmtroffaes
Copy link
Author

Thank you for the feedback.

Unfortunately, I am completely tied up with other things so won't be able to seriously pick this up again, if desired, before April. Some quick thoughts in the meantime...

  1. In the course of the last 5 years, downstream vcpkg have made further edits to their cmake file that likely should be integrated with this patch as well.
  2. It would make sense to replace the existing Visual Studio project files with cmake, as the existing project files are very old and do not target the latest MSVC versions (which fully support CMake nowadays).
  3. A far more ambitious aim could be to unify all build systems into just one. For this, both cmake and meson are IMO worthy of consideration. The challenge here will be to correctly carry over the platform specific parts from autotools into cmake/meson.
  4. There's still the issue of MSVC not supporting inline assembler on x64, and so some minor refactoring of the code would be desirable to ensure theora runs as efficiently as possible also on these builds.

@ccawley2011
Copy link
Contributor

FWIW, I also did some work on adding support for CMake a few years ago without being aware of this PR. It does have have a few advantages though, including being closer to the libogg/libvorbis CMake code at the time it was written, supporting the ARM assembly code and having the option to build Mac OS X frameworks.

https://github.com/ccawley2011/theora/tree/cmake

@petterreinholdtsen
Copy link
Contributor

As noted in #10 this issue is reported upstream as https://gitlab.xiph.org/xiph/theora/-/issues/2316 without any merge request upstream and should probably be closed here. Unless someone show up to explain which problem cmake solve and provide a brushed up patch upstream, a fix is unlikely to make it into the coming weekends release.

@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.0)
Copy link

Choose a reason for hiding this comment

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

Suggested change
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.10)

Co-authored-by: Michael Keck <git@cr0ydon.com>
@mcmtroffaes
Copy link
Author

I'll see if, in the next few days, I can bring this up to speed with the latest version at vcpkg here: https://github.com/microsoft/vcpkg/tree/master/ports/libtheora

@petterreinholdtsen
Copy link
Contributor

petterreinholdtsen commented Mar 24, 2025 via email

@Croydon
Copy link

Croydon commented Mar 24, 2025

As @mcmtroffaes said previously:

It would make sense to replace the existing Visual Studio project files with cmake, as the existing project files are very old and do not target the latest MSVC versions (which fully support CMake nowadays).

At the very least, Visual Studio-specific project files can be replaced. Probably more. But this PR is open for 5 years and counting. I would recommend to not make this too big, not get too much distracted. Unifying build system beyond MS build environments can be done later.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants