Skip to main content

Automated Testing for Seamless CMake Config File Integration

· 13 min read
Christopher McArthur
C++ DevOps Expert

As a C++ developer, ensuring your library integrates flawlessly with other projects is crucial for driving adoption. CMake being the defacto standard plays a vital role in this process by providing installed configuration files; guiding consumers on how to find and utilize your library using find_package. But how do you guarantee these config files are installed correctly and provide all the necessary information? Enter automated testing!

This blog post explores an approach for testing CMake config files inspired by Behavioral Driven Development practices and showcases a powerful implementation on GitHub Actions featuring 14+ test cases.

Why Test CMake Config Files?

Imagine creating a fantastic C++ library, only to have users encounter missing headers or library paths when they attempt to integrate it within their builds. This very real headache is why many open-source developers have opted for header-only libraries. "Just copying the headers" eventually became the norm. However, this trend has culminated in ballooned build times, as the preprocessing stage can become a bottleneck.

Breaking down the 2024 Survey Results

· 13 min read
Christopher McArthur
C++ DevOps Expert

It's that time of year once again! The ISO Committee published the summary of the results for the C++ Developer Survey "Lite". This has been running for several years and it's probably the first time we can start to see some trends... hopefully!

The survey results, with less than 1300 developers compared to 1700 last year, is only partially explained by third-party restrictions as noted by the blog post sharing the results. Regardless a wider sample would be ideal. The dominance of CMake with an 83% market share is striking. Could this 4% growth be linked to the lower burden for managing build scripts? Despite these limitations, the survey offers valuable insights into C++ ecosystem trends.

Since this blog is all about building and shipping C++ software, I'll be focusing on the tooling and ecosystem questions and results. There's a natural bias here, as I'm particularly interested in how these trends affect developers like us. But fear not, there's plenty for everyone! In fact, I'm curious what aspects other bloggers will delve into. Let's jump right in as there are some fascinating statistical correlations to explore!

Package Management vs. Reproducible Builds... Or Complementary Approaches?

· 9 min read
Christopher McArthur
C++ DevOps Expert

Let's face it, in the land of C++ development, package management and reproducible builds can feel like oil and water. Package managers promise lightning-fast builds with pre-built libraries, while reproducible builds preach control and consistency by rebuilding everything. But here's the thing: they're not sworn enemies.

Think of it this way.

Let's start with the basic build system. Imagine you're spending hours compiling your code. You throw more cores at the problem, and the build time shrinks – but there's a limit. Eventually, adding more cores won't magically make it compile any faster. Now imagine you don't build at all. Poof! Your build time is divided by zero, because it's not happening at all, it's just not a factor anymore. The most reproducible builds are the ones you don't have to repeat endlessly. That's where package management comes in, saving you from endless build marathons. Yet there's even more benefits for reproducibility as well.

This post will explore how these two seemingly opposing forces can actually work together to create a streamlined and efficient development workflow. Despite being a new idea, there is evidence of this already being used along with potential new opportunities for future development in this space.

Const Correctness for C++ Builds

· 6 min read
Christopher McArthur
C++ DevOps Expert

In the ever-evolving world of software development, ensuring code quality and maintainability is paramount. Two seemingly unrelated concepts, const correctness in C++ and ephemeral build environments from DevOps, share a surprising connection, both aiming to build a strong foundation for reliable software.

Const Correctness: Enforcing Immutability in Code

Const correctness is a programming paradigm in C++ that emphasizes the use of the const keyword to explicitly declare variables and objects that shouldn't be modified. This enforces a form of immutability within your code. Just like an immutable object in other languages, a const variable cannot have its value changed after initialization.

CPS: A Streamlined Future for C++ or Overly Specific?

· 6 min read
Christopher McArthur
C++ DevOps Expert

The most relevant problems for C++ developers are package management, setting up CI/CD pipelines, and maintaining build scripts. Talking to developers and builds teams the cause of that frustration is the lack of interoperability between build systems.

The Common Package Specification (CPS) aims to revolutionize C++ development by standardizing how dependencies are described. While the core concept holds promise, specific aspects raise questions about its practicality within the C++ ecosystem.

Conquer C++ Dependency Challenges: A Comprehensive Guide

· 2 min read

Streamline your C++ development workflow and ensure long-term project sustainability with effective dependency management. This comprehensive guide delves deeper than just libraries, providing a holistic perspective on the entire toolchain ecosystem and equipping you with practical strategies for success.

Mastering the Art of Dependency Management

By following these industry-proven best practices, you can establish a robust and sustainable approach to dependency management in your C++ projects:

  • Embrace Version Control and Lockfiles: Ensure reproducible builds and prevent unexpected behavior by explicitly specifying exact versions of dependencies in your project configuration files and utilizing tools that generate lockfiles to record downloaded versions.
  • Minimize and Evaluate Dependencies: Carefully consider alternative approaches or existing libraries before introducing new dependencies to reduce complexity and potential issues. Regularly evaluate your existing dependencies and maintain an up-to-date list with documented justifications for each one.
  • Strike a Balance with Updates: Stay informed about updates to your dependencies and address critical security vulnerabilities promptly. However, prioritize stability and avoid frequent updates unless strictly necessary. Focus on updating the fewest number of dependencies possible, prioritizing direct dependencies during development and limiting updates for transitive dependencies to patches addressing vulnerabilities.
  • Implement Thorough Testing and Documentation: Proactively identify and mitigate issues arising from dependency changes by incorporating comprehensive testing strategies that cover functionalities impacted by updates or conflicts. Maintain clear documentation listing all project dependencies and their purpose to aid understanding and future maintenance efforts.
  • Leverage Artifact Management: Facilitate version control, sharing, and retrieval of build artifacts (compiled binaries, libraries, packages) across different environments and teams by utilizing a central artifact repository. Implement versioning and tagging schemes within your repository to track changes, identify specific builds, and ensure consistent deployments. Automate artifact publishing and promotion to streamline the workflow and reduce manual intervention.

Conclusion

Effective dependency management is an ongoing journey, but by embracing the insights and strategies outlined in this comprehensive guide, you can conquer the C++ dependency landscape with confidence. Build resilient and maintainable projects, streamline your development process, and empower yourself to deliver exceptional C++ applications.

Layer by Layer: Navigating C++ Dependencies with Precision

· 6 min read
Christopher McArthur
C++ DevOps Expert

The ever-evolving world of C++ development unlocks incredible possibilities, but one persistent challenge haunts programmers: dependency management. While libraries often steal the spotlight, the true scope of dependencies extends far beyond. It encompasses the entire toolchain ecosystem, from the compilers and operating systems used to craft your code for the operating systems where it ultimately executes on.

Imagine building a spacecraft. While the engine is undeniably crucial, neglecting the guidance system, navigation tools, and communication equipment would be disastrous. Similarly, focusing solely on libraries paints an incomplete picture. Every software tool you utilize, from the ground up, contributes to the final product's functionality, stability, and maintainability.

This guide delves into the intricate tooling and dependencies, exploring the various categories, offering effective management strategies, and practical examples across diverse project types. By venturing beyond the surface level of libraries, we equip you with the knowledge and tools to navigate the dependency landscape with confidence and efficiency, ensuring your C++ projects reach their full potential.

DevOps Is Software Engineering for Your Builds

· 6 min read
Christopher McArthur
C++ DevOps Expert

C++ developers often approach DevOps with a reasonable degree of skepticism, and it's not without reason. Their top five challenges revolve around build scripts, dependency management, and setting up CI pipelines—areas traditionally associated with DevOps responsibilities. Michael Xymitoulias articulated this sentiment well in a recent LinkedIn post writing:

Right now, it feels that C++ developers have to deal with way more than just writing business logic code. [...] Allowing devs to focus more on coding rather than trying to solve problems of the ecosystem would probably be liberating

Xymitoulias suggestion that allowing developers to focus more on coding, rather than grappling with ecosystem problems, would be liberating. He's not alone, Bill Hoffman, CTO behind CMake supports this ideal of simplifying the developer workflows, something we've seen put in place with recent improvements to the popular build system.

While building in C++ certainly comes with its challenges, streamlining this process is our collective goal. So, let's delve into the core focus as it relates to C++ and dispel some common misconceptions.

C++ Package Managers: The Ultimate Roundup

· 13 min read
Christopher McArthur
C++ DevOps Expert

C++'s journey with dependency management has seen numerous transformations. Early years were marked by manual library integration and complex build scripts, presenting significant challenges. However, the landscape has since evolved, offering an array of sophisticated package managers designed to streamline workflows but most of all reduce the burden on developers.

Join in and delve into the strengths and weaknesses of these diverse solutions, empowering you to make informed choices and conquer the challenge of dependency management in your C++ endeavors.

Comparing Linux System Package Managers with C++ Package Managers

· 3 min read
Christopher McArthur
C++ DevOps Expert

Feeling lost in the jungle of C++ package managers? You're not alone. Wrangling dependencies in the C++ world can feel like navigating a tangled mess of vines, with cryptic tools and endless options leaving you frustrated. But fear not, intrepid C++ developer! This guide will cut through the undergrowth and help you get on the right path.

First things first: Let's dispel a common misconception. System package managers like rpm and apt are great for keeping your operating system humming, but they're not designed for the unique challenges of C++ development. That's where C++ specific package managers like vcpkg, Conan, and Xrepo come in.