I code on C/C++ and use a (GNU) Makefile to compile the code. I can do the same with CMake and get a MakeFile. However, what is the difference between using Makefile and CMake to compile the code?
C++ – Difference between using Makefile and CMake to compile the code
ccmakemakefile
Related Topic
- C++ – What are the differences between a pointer variable and a reference variable in C++
- C++ – The Definitive C++ Book Guide and List
- The difference between the GNU Makefile variable assignments =, ?=, := and +=
- C++ – Difference between private, public, and protected inheritance
- C++ – the difference between const int*, const int * const, and int const *
- Sqlite – Improve INSERT-per-second performance of SQLite
- The purpose of .PHONY in a Makefile
- Java – Why is processing a sorted array faster than processing an unsorted array
Best Answer
Make (or rather a Makefile) is a buildsystem - it drives the compiler and other build tools to build your code.
CMake is a generator of buildsystems. It can produce Makefiles, it can produce Ninja build files, it can produce KDEvelop or Xcode projects, it can produce Visual Studio solutions. From the same starting point, the same CMakeLists.txt file. So if you have a platform-independent project, CMake is a way to make it buildsystem-independent as well.
If you have Windows developers used to Visual Studio and Unix developers who swear by GNU Make, CMake is (one of) the way(s) to go.
I would always recommend using CMake (or another buildsystem generator, but CMake is my personal preference) if you intend your project to be multi-platform or widely usable. CMake itself also provides some nice features like dependency detection, library interface management, or integration with CTest, CDash and CPack.
Using a buildsystem generator makes your project more future-proof. Even if you're GNU-Make-only now, what if you later decide to expand to other platforms (be it Windows or something embedded), or just want to use an IDE?