Minimal CMake: Learn the best bits of CMake to create and share your own libraries and applications
معرفی کتاب «Minimal CMake: Learn the best bits of CMake to create and share your own libraries and applications» نوشتهٔ Tom Hulton-Harrop;، منتشرشده توسط نشر Packt Publishing در سال 2024. این کتاب در فرمت pdf، زبان انگلیسی ارائه شده است.
Design, build, and share cross-platform software effortlessly, and enhance your development workflow with this hands-on guide Key Features • Unlock efficient cross-platform builds with streamlined CMake setups • Learn CMake's most powerful features for streamlined software development from a seasoned game and engine developer • Create and distribute an application with step-by-step instructions, practical examples, and working code Book Description 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. Who is this book for? If you are a programmer skilled in C, C++, Swift, Objective-C, or C#, and keen on cross-platform development and open-source software, this book is for you. A solid grasp of CMake helps you to effectively utilize and create open-source libraries and applications. No prior knowledge of CMake is necessary, though familiarity with an imperative programming language (especially C and C++) is beneficial. While a basic understanding of the terminal is advantageous, comprehensive setup instructions will guide you across Windows, macOS, and Linux (Ubuntu). What you will learn • Set up projects for seamless cross-platform development • Integrate external libraries to enhance your project's functionality • Create and share reusable libraries • Manage complex software dependencies for improved maintainability • Package and distribute applications efficiently • Utilize top tools to streamline your CMake workflow • Explore resources for continuous learning Cover Title Page Copyright and Credits Dedications Contributors Table of Contents Preface Part 1: Starting Up Chapter 1: Getting Started Technical requirements Installing CMake on Windows Installing CMake on macOS Installing CMake on Linux (Ubuntu) Installing Git Visual Studio Code setup (optional) Summary Chapter 2: Hello, CMake! Technical requirements Using CMake from the command line Linux/macOS Windows Exploring the repository Invoking CMake Building with CMake Examining our first CMakeLists.txt file Setting a minimum version Naming the project Declaring the application Adding source files CMake generators Specifying a generator CMake configs Project next steps Adding another file Adding a dynamic array Forgetting to add a file To GLOB or not to GLOB Referencing interface files in target_sources Summary Chapter 3: Using FetchContent with External Dependencies Technical requirements Why FetchContent When to use FetchContent When not to use FetchContent Using FetchContent Including other CMake code Describing our dependency Using libraries from GitHub Using branch names Using local libraries with FetchContent Making the dependency available Linking to the dependencies Setting options on dependencies Updating our application Summary Chapter 4: Creating Libraries for FetchContent Technical requirements Making a library compatible with FetchContent Project structure The CMakeLists.txt file Creating the library Generator expressions Include interfaces Using our library Moving Game of Life to a library Making Game of Life a shared library Making things work on Windows Making things relocatable on macOS and Linux Final cross-platform additions Interface libraries Summary Part 2: Scaling Up Chapter 5: Streamlining CMake Configuration Technical requirements Reviewing how we use CMake Using scripts to avoid repetitive commands Moving to CMake presets Going further with CMake presets CMake preset overrides Other kinds of CMake presets A return to the CMake GUI Summary Chapter 6: Installing Dependencies and ExternalProject_Add Technical requirements What is installing? Installing a library Using an installed library CMake search modes Returning to find_package Informing CMake where to find our library Providing the location of our library CMakePreset improvements Using ExternalProject_Add to streamline installation Improving our use of ExternalProject_Add Handling multiple libraries with ExternalProject_Add Running the bgfx example Summary Chapter 7: Adding Install Support for Your Libraries Technical requirements Adding install support to a library The CMake install command Using our newly installed library Dealing with nested dependencies Private nested dependencies Public nested dependencies When and how to add COMPONENTS Supporting different versions of a library Writing a find module file Summary Chapter 8: Using Super Builds to Simplify Onboarding Technical requirements Using ExternalProject_Add with your own libraries Configuring a super build Integrating super build support Automating scripts with CMake Invoking the CMake script from CMakeLists.txt Setting options in nested files Installing an application Summary Part 3: Wrapping Up Chapter 9: Writing Tests for the Project Technical requirements Understanding CTest Adding unit tests to a library CMakeLists.txt changes for CTest Running the tests Adding end-to-end tests to an application Integrating a UI library Integrating end-to-end tests using Dear ImGui Integrating end-to-end tests with CTest Adding other kinds of tests Internal tests CMake script tests Using CDash with CTest Creating a CDash project Uploading test results Adding code coverage Summary Chapter 10: Packaging the Project for Sharing Technical requirements Understanding CPack Loading resources relative to the executable Integrating CPack CPack common properties The CPack Windows NSIS package The CPack macOS bundle package The CPack Linux Debian package Building a macOS bundle Adding CPack presets Other uses for CPack Summary Chapter 11: Supporting Tools and Next Steps Technical requirements CMake Tools for Visual Studio Code Navigating the Minimal CMake source code Configuring, building, and debugging Visual Studio Code and CMake presets Debugging CMakeLists.txt files Visual Studio Code extras Syntax highlighting Generating compile_commands.json Code auto-formatting Diff Folders CMake with other IDEs Visual Studio Xcode CLion C/C++ build recommendations Unity builds CMake script structure Future topics Summary Index Other Books You May Enjoy
دانلود کتاب Minimal CMake: Learn the best bits of CMake to create and share your own libraries and applications