Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
CMake Best Practices

You're reading from   CMake Best Practices Upgrade your C++ builds with CMake for maximum efficiency and scalability

Arrow left icon
Product type Paperback
Published in Aug 2024
Publisher Packt
ISBN-13 9781835880647
Length 356 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Mustafa Kemal Gilor Mustafa Kemal Gilor
Author Profile Icon Mustafa Kemal Gilor
Mustafa Kemal Gilor
Dominik Berner Dominik Berner
Author Profile Icon Dominik Berner
Dominik Berner
Arrow right icon
View More author details
Toc

Table of Contents (22) Chapters Close

Preface 1. Part 1 – The Basics
2. Chapter 1: Kickstarting CMake FREE CHAPTER 3. Chapter 2: Accessing CMake in the Best Ways 4. Chapter 3: Creating a CMake Project 5. Part 2 – Practical CMake – Getting Your Hands Dirty with CMake
6. Chapter 4: Packaging, Deploying, and Installing a CMake Project 7. Chapter 5: Integrating Third-Party Libraries and Dependency Management 8. Chapter 6: Automatically Generating Documentation 9. Chapter 7: Seamlessly Integrating Code Quality Tools with CMake 10. Chapter 8: Executing Custom Tasks with CMake 11. Chapter 9: Creating Reproducible Build Environments 12. Chapter 10: Handling Distributed Repositories and Dependencies in a Super-Build 13. Chapter 11: Creating Software for Apple Systems 14. Part 3 – Mastering the Details
15. Chapter 12: Cross-Platform-Compiling Custom Toolchains 16. Chapter 13: Reusing CMake Code 17. Chapter 14: Optimizing and Maintaining CMake Projects 18. Chapter 15: Migrating to CMake 19. Index 20. Other Books You May Enjoy Appendix: Contributing to CMake and Further Reading Material

What this book covers

Chapter 1, Kickstarting CMake, explains what CMake is in a nutshell, then jumps right into installing CMake and building something with CMake. You learn how to install the latest stable version manually, even if not provided by your package manager. You’ll also learn about the basic concepts behind CMake and why it is a build system generator and not a build system itself. Learn how it fits into modern software development with C++ (And C).

Chapter 2, Accessing CMake in the Best Ways, shows how to best use CMake from the command line, with a GUI and how CMake integrates into some of the common IDEs and Editors.

Chapter 3, Creating a CMake Project, takes you through setting up a project for building an executable, a library, and linking the two together.

Chapter 4, Packaging, Deploying, and Installing a CMake Project, will show you how to create a distributable version of your software project. You will learn how to add installation instructions and package the project using CMake and CPack (CMakes packaging program).

Chapter 5, Integrating Third-Party Libraries and Dependency Management, explains how to integrate existing 3rd-party libraries into your project. It also shows you how to add libraries already installed in your system, external CMake projects and non-CMake projects. This chapter covers CMakes depedency providers and gives a brief insight into using external package managers.

Chapter 6, Automatically Generating Documentation, explores how to generate documentation from your code with CMake as part of the build process with doxygen, dot (graphviz), and plantuml.

Chapter 7, Seamlessly Integrating Code Quality Tools with CMake, will show you how to integrate unit testing, code sanitizers, static code analysis and code coverage tools into your project. It will show you how CMake can help to discover and execute tests.

Chapter 8, Executing Custom Tasks with CMake, will explain how you can integrate almost any tool into your build process. You will learn how to wrap external programs into custom targets or hook into the build process to execute them. We will cover how custom tasks can be used to generate files and how they can consume files produced by other targets. You will also learn how to execute system commands during the configuration of the CMake build and how to create platform-agnostic commands using the CMake cscript mode.

Chapter 9, Creating Reproducible Build Environments, shows how you can build a portable environment between various machines including CI/CD pipelines. How to work with docker, sysroots, and CMake presets to make your build work “out of the box” everywhere.

Chapter 10, Handling Distributed Repositories and Dependencies in a Super-Build, simplifies managing projects that are distributed across multiple git repositories with CMake. You will learn how to create a super-build that allows you to build specific versions as well as the latest nightly builds. Explore what prerequisites it needs and how to combine them.

Chapter 11, Creating Software for Apple Systems, Because of the closed ecosystem, Apple platforms have some unique build characteristics, especially for applications with a graphical user interface and more complex library frameworks. For those cases Apple uses specific formats called app bundles and frameworks. In this chapter you will learn how to create these Apple-specific build artifacts and how to sign them for use in the App Store.

Chapter 12, Cross-Platform Compiling and Custom Toolchains, demonstrates how you can use a predefined cross-platform toolchains. You will also learn how to write your own toolchain definitions and conveniently use different toolchains with CMake.

Chapter 13, Reusing CMake Code, explains CMake Modules and how you can generalize your cmake files. You will learn how to write broadly used modules, which you can ship individually from your project.

Chapter 14, Optimizing and Maintaining CMake Projects, hints about how to get faster build times and tips and tricks for keeping a CMake project neat and tidy over a long period of time.

Chapter 15, Migrating to CMake, explains a high-level strategy on how to migrate a large existing codebase to CMake without the need to completely stop your development.

Appendix, Contributing to CMake and Further Reading Material, hints about where to go if you want to contribute, what is looked for, and basic contributing guidelines. It will also guide you on where to find additional in-depth information or more specific literature.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime