xiph / ogg

Reference implementation of the Ogg media container
BSD 3-Clause "New" or "Revised" License
345 stars 168 forks source link

CMake #6

Closed stopiccot closed 9 years ago

stopiccot commented 9 years ago

Let me explain the reasons behind this pull request.

The truth is that the majority of open source projects have unix roots and thus use makefiles as their main build system. Makefiles are somewhat ok for OS X (but Xcode is still better) and totally unacceptable on Windows. Eventually almost all open source project eventually add win32 and macosx folders where handcrafted Visual Studio and Xcode projects are located. Two main common problems of this approach are:

Here is where CMake comes to help. It solves two mentioned problems and it's really well known tool. It's being successfully used in such big C/C++ projects like LLVM. Even Microsoft itself uses it for their own open source C/C++ projects like coreclr. And almost all C/C++ programmers already know CMake and have it installed anyway.

So please take a look through the code and feel free to express and thoughts and complains. I'm not an autotools expert so I could missed something. For example I still don't understand purpose of ogg-uninstalled.pc.in file. Documentation installing is also not implemented yet. Anyway I'm here to fix anything you find suspicious.

Also I would be really happy to see hand-crafted projects to be removed eventually but it's probably too early to think about that and not up to me to decide at all.

rillian commented 9 years ago

Since all the maintainers use unix systems, I wouldn't like to take a patch replacing the makefiles with cmake. If people find it useful as an alternative to the unix build, I have no objections. As derf suggested on irc, I'd also like to hear from the maintainers of the current project files.

How does this help with windows? I thought anything but an in-tree project file was a problem for most people working in Visual Studio? Can we use this to maintain in-tree project files from Linux, or does the Visual Studio support still require an actual copy of Visual Studio?

stopiccot commented 9 years ago

It wasn't ment to replace makefiles. Only Visual Studio and Xcode projects. In long-term perspective. For the beginning I would be happy if it can just coexist with all the current stuff.

stopiccot commented 9 years ago

And storing generated projects under version control is not considered to be a good practice. The whole idea is that every user can generate project for their IDE of choice with options enabled\disabled they want. It's kinda similar to ./configure step when you generate makefiles that build your app in actually specified configuration.

stopiccot commented 9 years ago

And yes you can build ogg using CMake even on Linux, but consider it a free bonus. I don't image makefiles removed in any foreseeable future.

rillian commented 9 years ago

I still don't understand purpose of ogg-uninstalled.pc.in file.

These refer to the build products inside the tree before they are installed. A foo-uninstalled.pc file takes precedence over foo.pc, so one can build another project against a local source checkout just by adding its location to PKG_CONFIG_PATH.

See the --uninstalled switch in the pkg-config man page.

stopiccot commented 9 years ago

So... can I fix anything/answer any questions?

rillian commented 9 years ago

It wasn't ment to replace makefiles.

Your patch suggests cmake for linux.

Can you answer the question about whether it can generate Visual Studio and Xcode project files on Linux?

erikd commented 9 years ago

@rillian I'm pretty sure CMake needs VS (and XCode for the XCode case) to be installed to generate the VS and XCode build files.

For what its worth I have a CMakefile for libsndfile. Its passable, but apart from its ability to generate VS and XCode project files, I do not consider CMake a suitable replacement for autotools.

cristianadam commented 9 years ago

CMake support? Yes please! :+1:

@rillian You can generate Visual Studio projects (they are just xml files) with CMake on Linux. But people usually don't do this – pregenerate projects for IDEs by cmake.

I use CMake at work and while it can produce Visual Studio project files I use Qt Creator to compile, edit, debug on Windows.

I've found out that we have a really simple (libogg is simple) CMakeLists.txt for libogg.

CMake support is helpful not just only for XCode and VisualStudio users, but also for those who use only one crossplatform IDE (QtCreator, Eclipse CDT etc).

CMake has also support for Ninja, which is just an added bonus.

As a note, it seems libogg is already offered by Biicode. Biicode is a C/C++ CMake based dependency manager.

stopiccot commented 9 years ago

Your patch suggests cmake for linux.

Main idea is to generate VS and Xcode project files via CMake. And yes you can also generate Makefiles is you want. But it comes for free. Just like mentioned Ninja support. Never intended to remove autotools files.

Can you answer the question about whether it can generate Visual Studio and Xcode project files on Linux?

I'm not sure. I really never tested this feature. But if you want to generate project files on Linux and store them in git so they can be used on Windows\OS X it's considered a bad practice anyway. Just like you don't store in git repo makefiles generated by autotools.

rillian commented 9 years ago

cmake doesn't list visual studio or xcode generators on my Linux machine, so I guess Erik is correct.

I've pushed the changes based on Cristian's ack. Thanks for the contribution!