1 option
Modern CMake for C++ : Effortlessly Build Cutting-Edge C++ Code and Deliver High-quality Solutions / Rafał Świdziński ; foreword by Alexander Kushnir.
- Format:
- Book
- Author/Creator:
- Świdziński, Rafał, author.
- Language:
- English
- Subjects (All):
- Open source software.
- C++ (Computer program language).
- Physical Description:
- 1 online resource (503 pages)
- Edition:
- Second edition.
- Place of Publication:
- Birmingham, England : Packt Publishing, [2024]
- Contents:
- Cover
- Copyright Page
- Foreword
- Contributors
- Table of Contents
- Preface
- Chapter 1: First Steps with CMake
- Technical requirements
- Understanding the basics
- What is CMake?
- How does it work?
- The configuration stage
- The generation stage
- The building stage
- Installing CMake on different platforms
- Docker
- Windows
- Linux
- macOS
- Building from the source
- Mastering the command line
- CMake command line
- Generating a project buildsystem
- Building a project
- Installing a project
- Running a script
- Running a command-line tool
- Running a workflow preset
- Getting help
- CTest command line
- CPack command line
- CMake GUI
- CCMake command line
- Navigating project directories and files
- The source tree
- The build tree
- Listfiles
- Project file
- Cache file
- Package definition file
- Generated files
- JSON and YAML files
- Preset files
- File-based API
- Configure log
- Ignoring files in Git
- Discovering scripts and modules
- Scripts
- Utility modules
- Find-modules
- Summary
- Further reading
- Chapter 2: The CMake Language
- The basics of the CMake language syntax
- Comments
- Command invocations
- Command arguments
- Bracket arguments
- Quoted arguments
- Unquoted arguments
- Working with variables
- Variable references
- Using environment variables
- Using cache variables
- How to correctly use variable scopes in CMake
- Using lists
- Understanding control structures in CMake
- Conditional blocks
- The syntax for conditional commands
- Loops
- while()
- foreach() loops
- Command definitions
- Macros
- Functions
- The procedural paradigm in CMake
- A word on naming conventions
- Exploring the frequently used commands
- The message() command
- The include() command
- The include_guard() command.
- The file() command
- The execute_process() command
- Chapter 3: Using CMake in Popular IDEs
- Getting to know IDEs
- Choosing an IDE
- Choose a comprehensive IDE
- Choose an IDE that is widely supported in your organization
- Don't pick an IDE based on the target OS and platform
- Pick an IDE with remote development support
- Installing toolchains
- Using this book's examples with IDEs
- Starting with the CLion IDE
- Why you might like it
- Take your first steps
- Advanced feature: Debugger on steroids
- Starting with Visual Studio Code
- Advanced feature: Dev Containers
- Starting with the Visual Studio IDE
- Advanced feature: Hot Reload debugging
- Chapter 4: Setting Up Your First CMake Project
- Understanding the basic directives and commands
- Specifying the minimum CMake version
- Defining languages and metadata
- Partitioning your project
- Managing scope with subdirectories
- When to use nested projects
- Keeping external projects external
- Thinking about the project structure
- Scoping the environment
- Detecting the operating system
- Cross-compilation - what are host and target systems?
- Abbreviated variables
- Host system information
- Does the platform have 32-bit or 64-bit architecture?
- What is the endianness of the system?
- Configuring the toolchain
- Setting the C++ standard
- Insisting on standard support
- Vendor-specific extensions
- Interprocedural optimization
- Checking for supported compiler features
- Compiling a test file
- Disabling in-source builds
- Chapter 5: Working with Targets
- Understanding the concept of a target.
- Defining executable targets
- Defining library targets
- Custom targets
- Dependency graph
- Visualizing dependencies
- Setting properties of targets
- What are Transitive Usage Requirements?
- Dealing with conflicting propagated properties
- Meet the pseudo targets
- Imported targets
- Alias targets
- Interface libraries
- Object libraries
- Build targets
- Writing custom commands
- Using a custom command as a generator
- Using a custom command as a target hook
- Chapter 6: Using Generator Expressions
- What are generator expressions?
- Learning the basic rules of general expression syntax
- Nesting
- Conditional expansion
- Evaluating to Boolean
- Logical operators
- Comparisons
- Queries
- Querying and transforming
- Dealing with strings, lists, and paths
- Parametrizing the build configuration and platform
- Tuning for toolchain
- Querying target-related information
- Escaping
- Trying out examples
- Build configurations
- System-specific one liners
- Interface libraries with compiler-specific flags
- Nested generator expressions
- The difference between a conditional expression and the evaluation of a BOOL operator
- Chapter 7: Compiling C++ Sources with CMake
- The basics of compilation
- How compilation works
- Initial configuration
- Requiring specific features from the compiler
- Managing sources for targets
- Configuring the preprocessor
- Providing paths to included files
- Preprocessor definitions
- Avoid accessing private class fields in your unit tests
- Using git commit to track a compiled version
- Configuring the headers
- Configuring the optimizer
- General level
- Function inlining
- Loop unrolling
- Loop vectorization
- Managing the process of compilation.
- Reducing compilation time
- Precompilation of headers
- Unity builds
- Finding mistakes
- Configuring errors and warnings
- Debugging the build
- Providing information for the debugger
- Chapter 8: Linking Executables and Libraries
- Getting the basics of linking right
- Building different library types
- Static libraries
- Shared libraries
- Shared modules
- Position-independent code (PIC)
- Solving problems with the ODR
- Sorting out dynamically linked duplicated symbols
- Use namespaces - don't count on the linker
- The order of linking and unresolved symbols
- Dealing with unreferenced symbols
- Separating main() for testing
- Chapter 9: Managing Dependencies in CMake
- Using already installed dependencies
- Finding packages with CMake's find_package()
- Writing your own find modules
- Discovering legacy packages with FindPkgConfig
- Using dependencies not present in the system
- FetchContent
- Basic example with a YAML reader
- Downloading the dependencies
- Updating and patching
- Using the installed dependency where possible
- ExternalProject
- Chapter 10: Using the C++20 Modules
- What are the C++20 modules?
- Writing projects with C++20 module support
- Enabling the experimental support in CMake 3.26 and 3.27
- Enabling support for CMake 3.28 and up
- Setting the compiler requirements
- Declaring a C++ module
- Chapter 11: Testing Frameworks
- Why are automated tests worth the trouble?
- Using CTest to standardize testing in CMake
- Build-and-test mode
- Test mode
- Querying tests
- Filtering tests
- Shuffling tests
- Handling failures.
- Repeating tests
- Controlling output
- Miscellaneous
- Creating the most basic unit test for CTest
- Structuring our projects for testing
- Unit-testing frameworks
- Catch2
- GoogleTest
- Using GTest
- GMock
- Generating test coverage reports
- Using LCOV for coverage reports
- Avoiding the SEGFAULT gotcha
- Chapter 12: Program Analysis Tools
- Enforcing formatting
- Using static checkers
- clang-tidy
- Cpplint
- Cppcheck
- include-what-you-use
- Link What You Use
- Dynamic analysis with Valgrind
- Memcheck
- Memcheck-Cover
- Chapter 13: Generating Documentation
- Adding Doxygen to your project
- Generating documentation with a modern look
- Enhancing output with custom HTML
- Chapter 14: Installing and Packaging
- Exporting without installation
- Installing projects on the system
- Installing logical targets
- Utilizing the default destination for different platforms
- Dealing with public headers
- Low-level installation
- Installing with install(FILES) and install(PROGRAMS)
- Working with entire directories
- Invoking scripts during installation
- Installing runtime dependencies
- Creating reusable packages
- Understanding the issues with relocatable targets
- Installing target export files
- Writing basic config files
- Creating advanced config files
- Generating package version files
- Defining components
- How to use components in find_package()
- How to use components in the install() command
- Managing symbolic links for versioned shared libraries
- Packaging with CPack
- Chapter 15: Creating Your Professional Project
- Planning our work
- Project layout.
- Shared libraries versus static libraries.
- Notes:
- Includes bibliographical references and index.
- Description based on publisher supplied metadata and other sources.
- Description based on print version record.
- ISBN:
- 1-80512-336-X
The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.