Cmake or Make for C++ Projects?

Started by
5 comments, last by BitMaster 11 years, 3 months ago

Hi, just a quick question, but I was looking at automating my compiling process and have been using make (with a makefile) to do so. However, I saw cmake and was wondering whether it is easier to learn and/or is more organized? If someone had experience with the 2, what would you recommend?

Thanks.

Advertisement

CMake isn't a build tool in itself, it's a meta-build tool.

You can use a CMake file to generate a makefile for you, which you then use to build your project, or you can use the CMake file to make a project for an IDE like Microsoft Visual Studio, etc...

I use it so that I don't have to manually manage my Visual Studio project files, and so that when I port to linux I can also generate makefiles.

CMake or Premake4 would be my suggestions. I find Premake is a little nicer to work with. But CMake has better support for library location auto-discovery. They both can generate makefiles or Visual Studio projects,(or xcode and codeblocks iirc). The benifits of choosing one of these project generator tools is that they automate some of the process of binding libraries and whatnot in order to avoid some of the platform dependent changes you'd need to run on windows/linux. Both also really narrow down the scope of what it takes to describe your project, where raw makefiles can get rather verbose rather quickly.

Oh, sorry for my misunderstanding! I thought they were the same :S

Anyways, thanks for the help! I'll definitely try out CMake and get the Makefiles automated then. :)

cmake is the good !

I need some help learning CMake, I've read the documentation and the tutorial that they've officially gave out to use, but it's all very confusing. Is there any good alternatives to it?

Thanks.

CMake is not exactly perfect but I do not know of any better alternative (although I have not tried out Premake4 so far). I do not see any reasonable way to manage a single project across multiple building platforms without something like it (for example one project I work for needs to be buildable across MSVC, Linux gcc, Android and iOS).

That said, like any other tool, CMake largely requires a lot of practical experience. Try to create a project which just contains a single "hello world" source file. That should be doable in 5 or 10 lines if memory serves. Then slowly work yourself up using the documentation and tutorials to include management of external libraries, project-internal libraries with varying dependencies and custom build steps.

This topic is closed to new replies.

Advertisement