Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Minimal CMake
  • Table Of Contents Toc
  • Feedback & Rating feedback
Minimal CMake

Minimal CMake

By : Tom Hulton-Harrop
5 (1)
close
close
Minimal CMake

Minimal CMake

5 (1)
By: Tom Hulton-Harrop

Overview of this book

Minimal CMake guides you through creating a CMake project one step at a time. The book utilizes the author's unique expertise in game and engine development to craft compelling examples of how CMake can be used to build complex software. The chapters introduce concepts gradually, each one building on the last. Throughout the course of the book, you will progress from a simple console application all the way through to a full windowed app. The book will help you build a strong foundation in CMake that will translate to future projects. You'll learn how to integrate existing software libraries to enhance your app's functionality, how to build reusable libraries to share with others, and how to manage developing for multiple platforms simultaneously, including macOS, Windows, and Linux. You'll also find out how CMake facilitates testing and how to package your application ready for distribution. The book aims to not overwhelm you with everything there is to know about CMake. Instead, it focuses on the most relevant and important parts that will help you become productive quickly. By the end of this book, you will be a confident CMake user and will have gained the skills and experience to build and share your own libraries and applications.
Table of Contents (17 chapters)
close
close
Free Chapter
1
Part 1: Starting Up
6
Part 2: Scaling Up
11
Part 3: Wrapping Up

Why CMake?

CMake is one of those tools that unfortunately (though, not necessarily undeservedly) has a bit of a bad reputation. There are many developers out there who’ve been burned by CMake. They may have been forced to interact with it in a legacy code base, having had to deal with significant complexity, reams of CMake scripts, and questionable practices. Alternatively, they may have tried to use it for a new project, only to get stuck and frustrated trying to get things to work. As CMake has been around for a long time, there are many outdated examples and resources referencing old versions of CMake without all the latest features (and the benefit of hindsight about what works, and what not to do). As with any successful framework or language, CMake also comes with a certain amount of baggage, which is unfortunately unavoidable.

With all that being said, the good news is that over the last few years, there has been somewhat of a renaissance in CMake, and from version 3.0 (technically 2.8 for the diehards) onward, the new functionality to compose complex projects from targets has made an enormous difference, and it has been slowly gaining in popularity since.

One of the reasons for CMake’s growing popularity is a crucial detail that cannot be overstated. If you describe your build using CMake, you’ll by default have a project that you can build on Windows, Linux, and macOS. If you instead start a project with Visual Studio on Windows, Xcode on macOS, or Make files on Linux, it’s harder to migrate to other platforms, and harder for others working on different platforms to contribute. Having your build settings and options stored in versioned, human-readable scripts is incredibly useful (no more searching through nested tabs and windows in IDEs to find the right value to change).

The other interesting development is with this increasing popularity, CMake is now the lingua franca of build systems in C and C++. If a C or C++ project lives on GitHub, chances are it’s using CMake, and even if it’s not, with a minimal amount of effort, it’s possible to write a simple integration or wrapper to make that library consumable from CMake. This unlocks a vast wealth of potential, as adding a dependency to provide improvements to your project suddenly becomes a few lines of code, instead of an agonizing, laborious, and time-consuming process, usually requiring either embedding code from other libraries in your project or downloading and writing the code to build those libraries yourself.

Using CMake to build your projects and knowing enough CMake to get by (you most certainly do not need to be an expert) will make writing your applications faster, more maintainable, and more collaborative. It will also make working with C or C++ more fun (we promise), and not only C and C++, as there’s CMake support for C#, Fortran, CUDA, Objective-C, and Swift at the time of publication.

CMake is by no means perfect, but today, it is ubiquitous across the C and C++ landscape, and it is constantly evolving and improving thanks to the excellent work of the developers at Kitware and the many impactful open source contributors. We’re convinced, that whether you’re a professional C++ developer with years of experience, or a student or hobbyist just starting out, picking up, or getting reacquainted with CMake, will make you a happier, more productive developer. The experience you’ll gain when it comes to things such as dependency management and project structure will also serve you well in the future.

Let’s now turn our attention toward which group you feel most aligned with to help get the most out of this book.

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon

Create a Note

Modal Close icon
You need to login to use this feature.

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note