Sign in to follow this  
Followers 0
3DModelerMan

CMake vs Premake

6 posts in this topic

I'm trying to decide what build system to use. I want to be able to just create one CMake or Premake project file and generate the project files/solutions for Microsoft Visual C++ 2010/2008, and Code::Blocks. I might also need to generate XCode projects, and possibly kDevelop. Which one is easier to use? And also, do either support custom build steps like batch files?
1

Share this post


Link to post
Share on other sites
Well, I've never heard of Premake, but CMake is widely used (for example, by the entire KDE project). Some people swear by it (and others at it, you know the drill).

I know CMake is extensible. Adding platform-specific things like batch files might just defeat the purpose of a cross-platform build, but I'm pretty sure you can add "if windows do this..." type constructs to the CMakeFile.txt so yeah, that's possible.
0

Share this post


Link to post
Share on other sites
I haven't used CMake so can't really comment on it.

As for Premake I have found it quite easy to use and setting up scripts is quite easy using their documentation. If you have any Lua experience then the scripting will be even easier for you as it's based on that. I haven't needed to run custom build steps as I'm only using it to build fairly simple solutions/projects. There is however the [i]"if win { do something }"[/i] constructs from which you could then extend Premake to launch a batch script.
0

Share this post


Link to post
Share on other sites
I've not used Premake, but I like the sounds of it -- it uses Lua for it's project scripts, whereas CMake uses it's own internal scripting language ([i]which is simple to learn, but still, it's not Lua![/i]).

I really love CMake, but it did have a bit of a learning curve in getting the projects scripts set up the way I wanted them. I actually found it easiest to get started by copying [url="http://horde3d.org/download.html"]another project's[/url] build files [img]http://public.gamedev.net/public/style_emoticons/default/wink.gif[/img]
After getting past the initial learning curve, I find it pretty easy to use and quite powerful -- I've got CMake set up to produce a VS2008 solution containing multiple libraries and EXEs in three configurations ([i]debug, development, retail, each with different compiler options/defines[/i]). Some of the EXEs are unit-tests, which have post-build steps that run the EXE ([i]printing unit test failures to MSVC's build output window[/i]) as part of a regular build.
The cmake script files show up in MSVC's file tree, so It's pretty easy to add new files to the project, and whenever the project files are changed, your solution will be re-generated next time you hit the build button.
Also, I've got some simple CMake macros set up to organise files in the MSVC file tree -- e.g. I can easily say: [i]any files in "[font="Lucida Console"][size="1"]./include/foo/bar[/size][/font]" or "[font="Lucida Console"][size="1"]./source/foo/bar[/size][/font]" inside the "Foo" project should be grouped under a folder named "Bar".[/i]
0

Share this post


Link to post
Share on other sites
I'm a happy user of CMake.
And it has a lot of happy user I think. :-)

However, it's unhappy to start with CMake.
The syntax is really horrible.
But after you get used with it, you will be happy with it.

Now whenever I add new unit test file, I don't tell CMake about that, and it will find it automatically, it really saves my time.
0

Share this post


Link to post
Share on other sites
cmake's scripting language is no lua and can be rather cumbersome at times, but despite of this cmake is actually easy to use. For instance, I found it much easier to do complicated stuff with cmake (such as generating correct dependencies for a code generation tool built as part of a project and used later during the build) than with scons despite that the later uses python as its scripting language. I never used premake though, so I don't know how it compares with cmake, but since the later is widely used it is probably supported better all around. For instance you have good chances to find a cmake module somewhere for every major library.

As for custom build steps not only does it support them but you can usually do it all using cmake's own language instead of having to rely on platform specific scripts such as .bat or .sh scripts. cmake also have some nice goodies such as the ability to generate platform specific installation packages from generic installation rules located throughout the cmake files. It can generate nsis installers on windows, debian / rpm / self-extracting tarballs on linux, etc.

You can of course also have platform specific code in your build files, that's also supported. Overall cmake is a very complete multiplatform build system, at least for C++.

As for kdevelop, if you use kdevelop4 you can directly import the top level cmakelists.txt file as a project.
0

Share this post


Link to post
Share on other sites
I ended up just downloading both and trying them out to see which one I liked best. I ended up going with premake because I'm familiar with Lua.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0