Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
CMake Cookbook

You're reading from   CMake Cookbook Building, testing, and packaging modular software with modern CMake

Arrow left icon
Product type Paperback
Published in Sep 2018
Publisher Packt
ISBN-13 9781788470711
Length 606 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Radovan Bast Radovan Bast
Author Profile Icon Radovan Bast
Radovan Bast
Roberto Di Remigio Roberto Di Remigio
Author Profile Icon Roberto Di Remigio
Roberto Di Remigio
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Setting up Your System FREE CHAPTER 2. From a Simple Executable to Libraries 3. Detecting the Environment 4. Detecting External Libraries and Programs 5. Creating and Running Tests 6. Configure-time and Build-time Operations 7. Generating Source Code 8. Structuring Projects 9. The Superbuild Pattern 10. Mixed-language Projects 11. Writing an Installer 12. Packaging Projects 13. Building Documentation 14. Alternative Generators and Cross-compilation 15. Testing Dashboards 16. Porting a Project to CMake 17. Other Books You May Enjoy

Preface

Computer software is present in almost every aspect of our daily lives: it triggers our alarm clocks, fuels our communication, banking, weather forecasts, bus schedules, calendars, meetings, travel, photo albums, television, music streaming, social media, dinner and movie reservations, from dawn till dusk.

The software that surrounds us contains many layers: apps are built on top of frameworks, frameworks on top of libraries, libraries use smaller libraries and executables, all the way down to smaller and smaller software components. Libraries and executables in turn need to be built from source code. Often we only see the outermost layer, but all these layers need to be carefully organized and built. This book is about how to build libraries and executables from sources using CMake.

CMake and its siblings, CTest, CPack, and CDash, have emerged as the leading toolset for building software from sources, surpassing in usage and popularity many other similar tools, such as the venerated GNU Autotools and the more recent, Python-based, SCons build system.

Search interest over time for three popular build systems: CMake, Automake, and SCons. The interest is measured using the number of searches for the relevant terms over time. The figure was obtained using data provided by Google Trends.

The history of the CMake project started in 1999, when Kitware, the company behind its development, was commissioned to design a new set of tools to simplify the day-to-day software work of researchers. The goal was clear: provide a set of tools that would make it easier to configure, build, test, and deploy the same project across different platforms. A fascinating account of the ensuing design choices in the CMake project can be found at https://www.aosabook.org/en/cmake.html.

CMake is a build-system generator, offering a powerful domain-specific language (DSL) to describe what the build system should achieve. In our opinion, this is one of the main strengths of CMake, because it allows the generation of platform-native build systems with the same set of CMake scripts. The CMake software toolset gives developers full control over the whole life cycle of a given project:

  • CMake lets you describe how your project, whether building an executable, libraries, or both, has to be configured, built, and installed on all major hardware and operating systems.
  • CTest allows you to define tests, test suites, and set how they should be executed.
  • CPack offers a DSL for all your packaging needs, whether your project should be bundled and distributed in source code or platform-native binary form.
  • CDash will be useful for reporting the results of tests for your project to an online dashboard.

An old adage goes that the deeper you dig, the more stones you will find. For the preparation of this book we have carefully been digging deeper through many software layers, with CMake being our quarry. The number of stones and artifacts that we have hit when building various software components and libraries on various platforms, each with their own quirks, has felt disheartening at times. But we believe we have cleared the ground of many stones and we are happy to share our findings and recipes with you, our readers. There will always be stones left but each stone will bring new insight and we encourage you to share this insight with the community.

lock icon The rest of the chapter is locked
Next Section arrow right
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 $19.99/month. Cancel anytime
Banner background image