These are the slides from my CppCon 2018 talk. You can find the recording here: https://www.youtube.com/watch?v=S4QSKLXdTtA. All my other talks can be found here: https://train-it.eu/resources.
---
Git and CMake are already established standards in our community. However, it is uncommon to see them being used in an efficient way. As a result, many C++ projects have big problems with either importing other dependencies or making themselves easy to import by others. It gets even worse when we need to build many different configurations of our package on one machine.
That presentation lists and addresses the problems of build system and packaging that we have with large, multi-platform, C++ projects that often have many external and internal dependencies. The talk will present how proper use of CMake and Conan package manager can address those use cases. It will also describe current issues with the cooperation of those tools.
If you've attended or seen my talk at C++Now 2018, that time you can expect much more information on Conan and package creation using that tool. I will also describe how the integration of CMake and Conan changed over the last few months.
CMake is an open-source cross-platform build system. It is increasingly becoming the build system of choice for open source projects. The Qt project recently announced that Qbs, the replacement build system for qmake, will no longer be supported and future efforts will focus on CMake. It may become the default build system for Qt version 6.
CMake has offered support for building Qt applications for some time, and is supported within the Qt Creator IDE. In this webinar we will:
-Introduce you to CMake
-Cover its basic features and how to use it
-Show some CMake configurations including Qt-based applications
-Prove how easy it is to use Cmake with Qt so you'll be ready to use it for your C++ and Qt-based applications!
eBPF is an exciting new technology that is poised to transform Linux performance engineering. eBPF enables users to dynamically and programatically trace any kernel or user space code path, safely and efficiently. However, understanding eBPF is not so simple. The goal of this talk is to give audiences a fundamental understanding of eBPF, how it interconnects existing Linux tracing technologies, and provides a powerful aplatform to solve any Linux performance problem.
While CMake has become the de-facto standard buildsystem for C++, it's siblings CTest and CPack are less well known. This talk gives a lightspeed introduction into these three tools and then focuses on best practices on building, testing, and packaging.
CMake is an open-source cross-platform build system. It is increasingly becoming the build system of choice for open source projects. The Qt project recently announced that Qbs, the replacement build system for qmake, will no longer be supported and future efforts will focus on CMake. It may become the default build system for Qt version 6.
CMake has offered support for building Qt applications for some time, and is supported within the Qt Creator IDE. In this webinar we will:
-Introduce you to CMake
-Cover its basic features and how to use it
-Show some CMake configurations including Qt-based applications
-Prove how easy it is to use Cmake with Qt so you'll be ready to use it for your C++ and Qt-based applications!
eBPF is an exciting new technology that is poised to transform Linux performance engineering. eBPF enables users to dynamically and programatically trace any kernel or user space code path, safely and efficiently. However, understanding eBPF is not so simple. The goal of this talk is to give audiences a fundamental understanding of eBPF, how it interconnects existing Linux tracing technologies, and provides a powerful aplatform to solve any Linux performance problem.
While CMake has become the de-facto standard buildsystem for C++, it's siblings CTest and CPack are less well known. This talk gives a lightspeed introduction into these three tools and then focuses on best practices on building, testing, and packaging.
Video: https://www.facebook.com/atscaleevents/videos/1693888610884236/ . Talk by Brendan Gregg from Facebook's Performance @Scale: "Linux performance analysis has been the domain of ancient tools and metrics, but that's now changing in the Linux 4.x series. A new tracer is available in the mainline kernel, built from dynamic tracing (kprobes, uprobes) and enhanced BPF (Berkeley Packet Filter), aka, eBPF. It allows us to measure latency distributions for file system I/O and run queue latency, print details of storage device I/O and TCP retransmits, investigate blocked stack traces and memory leaks, and a whole lot more. These lead to performance wins large and small, especially when instrumenting areas that previously had zero visibility. This talk will summarize this new technology and some long-standing issues that it can solve, and how we intend to use it at Netflix."
Το CMake είναι το πιο διαδεδομένο εργαλείο για να "χτίσεις" projects γραμμένα σε C++ για το 2021.
Το CMake δε μεταγλωτίζει το ίδιο τον κώδικα αλλά παράγει τις κατάλληλες παραμέτρους για άλλα εργαλεία (π.χ. make) τα οποία αναλαμβάνουν τη μεταγλώτισση.
Η χρήση εργαλείων όπως το CMake είναι μονόδρομος όταν ένα έργο σε C++ περιλαμβάνει πολλά αρχεία, διάφορες παραμέτρους, εξωτερικά dependencies κλπ. Σε αυτή την περίπτωση η ανάπτυξή του γίνεται εκθετικά δυσκολότερη όσο το μέγεθός του αυξάνεται, εάν δεν υιοθετηθεί χρήση εργαλείων όπως το CMake.
邏 Στο εργαστήριο θα δείξουμε πως μπορούμε να στήσουμε ένα τυπικό project γραμμένο σε C++ και θα καλύψουμε τα πιο βασικά σενάρια που χρειάζεται να γνωρίζει κάποιος όπως:
✅ Παραγωγή εκτελέσιμου αρχείου
✅ Καθορισμός του include path
✅ Δημιουργία βιβλιοθήκης για static ή dynamic linking
✅ Ελεγχος των διάφορων compilation flags
✅ Δημιουργία functions εντός του CMake
✅ Παραμετροποίηση μέσω options
Talk for PerconaLive 2016 by Brendan Gregg. Video: https://www.youtube.com/watch?v=CbmEDXq7es0 . "Systems performance provides a different perspective for analysis and tuning, and can help you find performance wins for your databases, applications, and the kernel. However, most of us are not performance or kernel engineers, and have limited time to study this topic. This talk summarizes six important areas of Linux systems performance in 50 minutes: observability tools, methodologies, benchmarking, profiling, tracing, and tuning. Included are recipes for Linux performance analysis and tuning (using vmstat, mpstat, iostat, etc), overviews of complex areas including profiling (perf_events), static tracing (tracepoints), and dynamic tracing (kprobes, uprobes), and much advice about what is and isn't important to learn. This talk is aimed at everyone: DBAs, developers, operations, etc, and in any environment running Linux, bare-metal or the cloud."
Linux Performance Analysis: New Tools and Old SecretsBrendan Gregg
Talk for USENIX/LISA2014 by Brendan Gregg, Netflix. At Netflix performance is crucial, and we use many high to low level tools to analyze our stack in different ways. In this talk, I will introduce new system observability tools we are using at Netflix, which I've ported from my DTraceToolkit, and are intended for our Linux 3.2 cloud instances. These show that Linux can do more than you may think, by using creative hacks and workarounds with existing kernel features (ftrace, perf_events). While these are solving issues on current versions of Linux, I'll also briefly summarize the future in this space: eBPF, ktap, SystemTap, sysdig, etc.
High-Performance Networking Using eBPF, XDP, and io_uringScyllaDB
In the networking world there are a number of ways to increase performance over naive use of basic Berkeley sockets. These techniques have ranged from polling blocking sockets, non-blocking sockets controlled by Epoll, all the way through completely bypassing the Linux kernel for maximum network performance where you talk directly to the network interface card by using something like DPDK or Netmap. All these tools have their place, and generally occupy a space from convenience to performance. But in recent years, that landscape has changed massively.. The tools available to the average Linux systems developer have improved from the creation of io_uring, to the expansion of bpf from a simple filtering language to a full-on programming environment embedded directly in the kernel. Along with that came something called XDP (express datapath). This was Linux kernel's answer to kernel-bypass networking. AF_XDP is the new socket type created by this feature, and generally works very similarly to something like DPDK. History lessons out of the way, this talk will look into, and discuss the merits of this technology, it's place in the broader ecosystem and how it can be used to attain the highest level of performance possible. This talk will dive into crucial details, such as how AF_XDP works, how it can be integrated into a larger system and finally more advanced topics such as request sharding/load balancing. There will be detailed look at the design of AF_XDP, the eBpf code used, as well as the userspace code required to drive it all. It will also include performance numbers from this setup compared to regular kernel networking. And most importantly how to put all this together to handle as much data as possible on a single modern multi-core system.
[Container Plumbing Days 2023] Why was nerdctl made?Akihiro Suda
nerdctl (contaiNERD CTL) was made to facilitate development of new technologies in the containerd platform.
Such technologies include:
- Lazy-pulling with Stargz/Nydus/OverlayBD
- P2P image distribution with IPFS
- Image encryption with OCIcrypt
- Image signing with Cosign
- “Real” read-only mounts with mount_setattr
- Slirp-less rootless containers with bypass4netns
- Interactive debugging of Dockerfiles, with buildg
nerdctl is also useful for debugging Kubernetes nodes that are running containerd.
Through this session, the audiences will learn these functionalities of nerdctl, relevant projects, and the roadmap for the future.
https://containerplumbing.org/sessions/2023/why_was_nerdctl_
Slides that were presented during the webrtc Qt Cmake tutorial at IIT-RTC in October 2017 in Chicago. The slides are not yet complete, and will be updated later.
Video: https://www.facebook.com/atscaleevents/videos/1693888610884236/ . Talk by Brendan Gregg from Facebook's Performance @Scale: "Linux performance analysis has been the domain of ancient tools and metrics, but that's now changing in the Linux 4.x series. A new tracer is available in the mainline kernel, built from dynamic tracing (kprobes, uprobes) and enhanced BPF (Berkeley Packet Filter), aka, eBPF. It allows us to measure latency distributions for file system I/O and run queue latency, print details of storage device I/O and TCP retransmits, investigate blocked stack traces and memory leaks, and a whole lot more. These lead to performance wins large and small, especially when instrumenting areas that previously had zero visibility. This talk will summarize this new technology and some long-standing issues that it can solve, and how we intend to use it at Netflix."
Το CMake είναι το πιο διαδεδομένο εργαλείο για να "χτίσεις" projects γραμμένα σε C++ για το 2021.
Το CMake δε μεταγλωτίζει το ίδιο τον κώδικα αλλά παράγει τις κατάλληλες παραμέτρους για άλλα εργαλεία (π.χ. make) τα οποία αναλαμβάνουν τη μεταγλώτισση.
Η χρήση εργαλείων όπως το CMake είναι μονόδρομος όταν ένα έργο σε C++ περιλαμβάνει πολλά αρχεία, διάφορες παραμέτρους, εξωτερικά dependencies κλπ. Σε αυτή την περίπτωση η ανάπτυξή του γίνεται εκθετικά δυσκολότερη όσο το μέγεθός του αυξάνεται, εάν δεν υιοθετηθεί χρήση εργαλείων όπως το CMake.
邏 Στο εργαστήριο θα δείξουμε πως μπορούμε να στήσουμε ένα τυπικό project γραμμένο σε C++ και θα καλύψουμε τα πιο βασικά σενάρια που χρειάζεται να γνωρίζει κάποιος όπως:
✅ Παραγωγή εκτελέσιμου αρχείου
✅ Καθορισμός του include path
✅ Δημιουργία βιβλιοθήκης για static ή dynamic linking
✅ Ελεγχος των διάφορων compilation flags
✅ Δημιουργία functions εντός του CMake
✅ Παραμετροποίηση μέσω options
Talk for PerconaLive 2016 by Brendan Gregg. Video: https://www.youtube.com/watch?v=CbmEDXq7es0 . "Systems performance provides a different perspective for analysis and tuning, and can help you find performance wins for your databases, applications, and the kernel. However, most of us are not performance or kernel engineers, and have limited time to study this topic. This talk summarizes six important areas of Linux systems performance in 50 minutes: observability tools, methodologies, benchmarking, profiling, tracing, and tuning. Included are recipes for Linux performance analysis and tuning (using vmstat, mpstat, iostat, etc), overviews of complex areas including profiling (perf_events), static tracing (tracepoints), and dynamic tracing (kprobes, uprobes), and much advice about what is and isn't important to learn. This talk is aimed at everyone: DBAs, developers, operations, etc, and in any environment running Linux, bare-metal or the cloud."
Linux Performance Analysis: New Tools and Old SecretsBrendan Gregg
Talk for USENIX/LISA2014 by Brendan Gregg, Netflix. At Netflix performance is crucial, and we use many high to low level tools to analyze our stack in different ways. In this talk, I will introduce new system observability tools we are using at Netflix, which I've ported from my DTraceToolkit, and are intended for our Linux 3.2 cloud instances. These show that Linux can do more than you may think, by using creative hacks and workarounds with existing kernel features (ftrace, perf_events). While these are solving issues on current versions of Linux, I'll also briefly summarize the future in this space: eBPF, ktap, SystemTap, sysdig, etc.
High-Performance Networking Using eBPF, XDP, and io_uringScyllaDB
In the networking world there are a number of ways to increase performance over naive use of basic Berkeley sockets. These techniques have ranged from polling blocking sockets, non-blocking sockets controlled by Epoll, all the way through completely bypassing the Linux kernel for maximum network performance where you talk directly to the network interface card by using something like DPDK or Netmap. All these tools have their place, and generally occupy a space from convenience to performance. But in recent years, that landscape has changed massively.. The tools available to the average Linux systems developer have improved from the creation of io_uring, to the expansion of bpf from a simple filtering language to a full-on programming environment embedded directly in the kernel. Along with that came something called XDP (express datapath). This was Linux kernel's answer to kernel-bypass networking. AF_XDP is the new socket type created by this feature, and generally works very similarly to something like DPDK. History lessons out of the way, this talk will look into, and discuss the merits of this technology, it's place in the broader ecosystem and how it can be used to attain the highest level of performance possible. This talk will dive into crucial details, such as how AF_XDP works, how it can be integrated into a larger system and finally more advanced topics such as request sharding/load balancing. There will be detailed look at the design of AF_XDP, the eBpf code used, as well as the userspace code required to drive it all. It will also include performance numbers from this setup compared to regular kernel networking. And most importantly how to put all this together to handle as much data as possible on a single modern multi-core system.
[Container Plumbing Days 2023] Why was nerdctl made?Akihiro Suda
nerdctl (contaiNERD CTL) was made to facilitate development of new technologies in the containerd platform.
Such technologies include:
- Lazy-pulling with Stargz/Nydus/OverlayBD
- P2P image distribution with IPFS
- Image encryption with OCIcrypt
- Image signing with Cosign
- “Real” read-only mounts with mount_setattr
- Slirp-less rootless containers with bypass4netns
- Interactive debugging of Dockerfiles, with buildg
nerdctl is also useful for debugging Kubernetes nodes that are running containerd.
Through this session, the audiences will learn these functionalities of nerdctl, relevant projects, and the roadmap for the future.
https://containerplumbing.org/sessions/2023/why_was_nerdctl_
Slides that were presented during the webrtc Qt Cmake tutorial at IIT-RTC in October 2017 in Chicago. The slides are not yet complete, and will be updated later.
Serverless Data Architecture at scale on Google Cloud Platform - Lorenzo Ridi...Codemotion
Let's say you are in charge of the design of a data processing architecture. You finally managed to deploy and tune the "ideal" configuration, but data are like weeds: they just KEEP GROWING! So, eventually you have to add new pieces, or even start over and re-design everything. Sounds familiar? Cloud can be a solution to this Data Architect nightmare. In this talk we will build an end-to-end Serverless, No-Ops, scalable and reliable data solution, based on Google Cloud Platform.
Container Power Hour with Jess, Clare, and Abby (CON362) - AWS re:Invent 2018Amazon Web Services
Join Jess Frazelle, from GitHub, and Clare Liguori and Abby Fuller, from AWS, for a container power hour to kick off your re:Invent. In this session, learn how to use Git and GitHub to run your containers, and build, test, and deploy processes. GitOps and Actions and AWS Fargate—oh my! This session features a demo from Jess on using the new GitHub Actions to deploy to Fargate.
How to build an ETL pipeline with Apache Beam on Google Cloud DataflowLucas Arruda
Nowadays more and more companies are searching for insights with potential to grow their business by analyzing large amounts of data from many different systems. However, in order to reach this level of Big Data Analysis it's necessary to build an ETL pipeline that allows us to process raw data coming from different sources into an appropriate format that is possible to use against visualization tools such as Tableau.
This kind of data processing can be done by a variety of tools and in this presentation I show how to do it by using an unified programming model created by Google and open-sourced as the name of Apache Beam. We will build a simple pipeline that will be executed in the Cloud by a fully-managed service called Google Cloud Dataflow.
Enhance Your Kubernetes CI/CD Pipelines With GitLab & Open SourceNico Meisenzahl
Working within a heavily regulated environment brings a special set of challenges, including increased difficulty in application scaling. In this session you will learn how you can enhance your Kubernetes CI/CD pipelines with GitLab and other open source projects. We will demonstrate practices for deployments using newer GitLab features like the Web Application Firewall for Kubernetes Ingress, and managing serverless functions with Knative. The techniques covered in this session will give you new options to streamline your Kubernetes pipelines reliably and consistently.
DEVNET-2006 Coding 210: Parsing JSON in C++Cisco DevNet
This hands-on session will give you an overview of the techniques needed to parse and work with JSON data in the C++ language. Bring your laptop and join in the coding.
Integrating Existing C++ Libraries into PySpark with Esther KundinDatabricks
Bloomberg’s Machine Learning/Text Analysis team has developed many machine learning libraries for fast real-time sentiment analysis of incoming news stories. These models were developed using smaller training sets, implemented in C++ for minimal latency, and are currently running in production. To facilitate backtesting our production models across our full data set, we needed to be able to parallelize our workloads, while using the actual production code.
We also wanted to integrate the C++ code with PySpark and use it to run our models. In this talk, I will discuss some of the challenges we faced, decisions we made, and other options when dealing with integrating existing C++ code into a Spark system. The techniques we developed have been used successfully by our team multiple times and I am sure others will benefit from the gotchas that we were able to identify.
Gitlab - Creating C++ applications with Gitlab CIUilian Ries
Gitlab is a complete tool that integrates everything from project management to product construction. In this talk I will present how a C ++ project can be analyzed, built, tested and deployed using Gitlab.
Free Lunch is Over: Why is C++ so Important in the Modern World?Mateusz Pusz
"Don’t pay for what you don’t use" and "Don't leave room for a language below C++ (except assembler)" are the C++ design and evolution priorities that have stuck with us since the beginning of the programming language. CPU clock frequencies stopped growing more than 10 years ago, and since that time, our processor cores are no longer accelerating. Moreover, the demand for power savings is higher than ever for both small factor devices, like mobile phones, and for huge factor server farms. In the domains where each CPU cycle counts, C++ is the fastest and the most robust solution on the market. C++ programming language is evolving faster now than ever before — and EPAM is an active contributor to this transformation. This talk will briefly summarize the history of C++, describe the benefits of the programming language, highlight the business domains where its usage is essential, and provide some insights on the future of the language and its standardization process.
A Physical Units Library for the Next C++Mateusz Pusz
These are the slides from my CppCon 2020 talk. You can find the recording here: https://www.youtube.com/watch?v=7dExYGSOJzo. All my other talks can be found here: https://train-it.eu/resources.
---
During CppCon 2019 Mateusz provided an overview of current solutions on the market as well as challenges of implementing a modern C++ physical units library. This year's talk will focus on 'mp-units', the library that was developed by Mateusz and contributors, and which is proposed for C++ standardization. During the tutorial, we will get familiar with the building blocks of the library's framework and its most important concepts. Numerous code examples will present how to use and solve real-life problems with the library. The audience will learn how easy it is to extend it with new units, dimensions, or even whole new systems of quantities. Last but not least Mateusz will provide a fair comparison of how well this library performs in comparison to other products on the market.
These are the slides from my keynote talk on C++ on CoreHard Autumn 2019. You can find the recording here: https://www.youtube.com/watch?v=nqf53MlnMpo. All my other talks can be found here: https://train-it.eu/resources.
---
That talk will present the C++ world seen from Low Latency domain. The world where no dynamic allocations are welcomed, C++ exceptions are nearly not used, where STL containers are often not enough, and where developers often need to go deep down to assembly level to verify if the code really does its best.
Rethinking the Way We do Templates in C++Mateusz Pusz
These are the slides from my CppCon 2019 talk. You can find the recording here: https://www.youtube.com/watch?v=oNBnYhLxlTU. All my other talks can be found here: https://train-it.eu/resources.
---
Template metaprogramming is hard. In case it is hard only for the library implementer then it is not that bad. The problem arises when it also affects the users of this library.
This talk is summarizing my experience and thoughts gathered during the implementation of the Physical Units Library for C++. The way we do template metaprogramming now results with inscrutable compile-time errors and really long type names observed while debugging our code. That is mostly caused by aliasing class template specializations of non-trivial metaprogramming interface designs. Compilation times of such code also leave a lot of room for improvement, and the practices we chose to use in the Standard Library are often suboptimal. Taking into account the Rule of Chiel while designing templated code makes a huge difference in the compile times. This talk presents a few simple examples (including the practices from the C++ Standard Library) of achieving the same goal in different ways and provides benchmark results of time needed to compile such source code.
These are the slides from my talk on C++ London meetup. You can find the recording here: https://www.youtube.com/watch?v=HsC1EoFjf8U. All my other talks can be found here: https://train-it.eu/resources.
---
C++ is the fastest programming language in the world, and it leaves no room for other languages below it (except assembler). That is why it gets more attention now than ever before. As a result, we observe an increasing speed of C++ language evolution. C++11 was a game changer, but is now considered an "old" language already. C++14 & 17 provided many improvements that allow us to write portable, safer, and faster code in a shorter time. The resulting source code is easier to reason about and maintain. Moreover, C++20 is coming soon, and it is going to be a game changer again.
In my talk, I provide a few typical legacy code examples that most of us write every day. I describe how those samples evolve with the changes introduced in the each C++ language release from C++11 up to the major groundbreaking features of the upcoming C++20. During the talk, the audience will learn how much easier, more robust, and safer is the code written using modern tools that we get with every new C++ release.
Implementing a Physical Units Library for C++Mateusz Pusz
These are the slides from my keynote talk on C++ on CoreHard Spring 2019. You can find the recording here: https://www.youtube.com/watch?v=hcgL8QBmh2I. All my other talks can be found here: https://train-it.eu/resources.
---
This talk will present the current state of my work on designing and implementing Physical Units Library for C++. I will present all the challenges, design tradeoffs, and potential solutions to those problems. During the lecture, we will also see how new C++20 features help to make the library interface easier to use, maintain, and extend. Among others, we will see how we can benefit from class types provided as non-type template parameters, how new class template argument deduction rules simplify the interfaces and the full power of using concepts to constrain template types.
Effective replacement of dynamic polymorphism with std::variantMateusz Pusz
These are the slides from my ACCU 2019 talk. You can find the recording here: https://www.youtube.com/watch?v=JGYxOieiZnY. All my other talks can be found here: https://train-it.eu/resources.
---
This short talk presents how easy it is to replace some cases of dynamic polymorphism with std::variant. During the lecture, we will analyze and compare a few implementations of the same simple Finite State Machine. It turns up that variant-based code is not only much faster but also it gives us the opportunity to define our interfaces and program flow much better. The talk will end up with the discussion of pros and cons of each approach and will try to give guidelines on when to use them.
Implementing Physical Units Library for C++Mateusz Pusz
These are the slides from my 4Developers 2019 talk. You can find the recording here: https://www.youtube.com/watch?v=O1vlFZcaMKo. All my other talks can be found here: https://train-it.eu/resources.
---
This talk will present the current state of my work on designing and implementing Physical Units Library for C++. I will present all the challenges, design tradeoffs, and potential solutions to those problems. During the lecture, we will also see how new C++20 features help to make the library interface easier to use, maintain, and extend. Among others, we will see how we can benefit from class types provided as non-type template parameters, how new class template argument deduction rules simplify the interfaces, and a full power of using concepts to constrain template types.
C++ Concepts and Ranges - How to use them?Mateusz Pusz
These are the slides from my Meeting C++ 2018 talk. You can find the recording here: https://www.youtube.com/watch?v=pe05ZWdh0N0. All my other talks can be found here: https://train-it.eu/resources.
---
The most of the Concepts TS and Ranges TS is merged into the C++20 standard draft document. The talk will present a current design of those features and will provide suggestions on how to use them in our source code. That presentation is meant to inspire discussion on how should we use those long-awaited features while building tools and the C++ Standard Library.
Effective replacement of dynamic polymorphism with std::variantMateusz Pusz
These are the slides from my CppCon 2018 talk. You can find the recording here: https://www.youtube.com/watch?v=gKbORJtnVu8. All my other talks can be found here: https://train-it.eu/resources.
---
This short talk presents how easy it is to replace some cases of dynamic polymorphism with std::variant. During the lecture, we will analyze and compare 2 implementations of the same simple Finite State Machine. It turns up that variant-based code is not only much faster but also it gives us the opportunity to define our interfaces and program flow much better. The talk will end up with the discussion of pros and cons of each approach and will try to give guidelines on when to use them.
These are the slides from my C++Now 2018 talk. You can find the recording here: https://www.youtube.com/watch?v=y7PBciQp0B8. All my other talks can be found here: https://train-it.eu/resources.
---
Presentation of features already voted into C++20 Standard Draft in Toronto, Albuquerque, and Jacksonville ISO C++ Committee Meetings as well as the overview of other really promising proposals that have high chances to arrive in C++20.
Pointless Pointers - How to make our interfaces efficient?Mateusz Pusz
These are the slides from my code::dive 2017 talk. You can find the recording here: https://www.youtube.com/watch?v=qrifyjQW9gA. All my other talks can be found here: https://train-it.eu/resources.
---
C++ is not C. C++ developers too often forget about that. The effects are often disastrous. nullptr dereferences, buffer overflows, resource leaks are the problems often seen in C++ applications bug trackers. Does it have to be like that? The talk presents a few simple rules tested in production that will make most of those issues go away and never appear again in the C++ software. Interested? Come and see :-)
These are the slides from my 4Developers 2017 talk. You can find the recording here: https://www.youtube.com/watch?v=pU0VRMqM5vs. All my other talks can be found here: https://train-it.eu/resources.
---
That talk will present the C++ world seen from Low Latency domain. The world where no dynamic allocations are welcomed, C++ exceptions are nearly not used, where STL containers are often not enough, and where developers often need to go deep down to assembly level to verify if the code really does its best.
These are the slides from my code::dive 2016 talk. You can find the recording here: https://www.youtube.com/watch?v=yCfFt061SU4. All my other talks can be found here: https://train-it.eu/resources.
---
Writing fast C++ applications is a really complex subject. It often turns out that deep but isolated knowledge of ISO C++ standard and algorithmic complexity of operations does not guarantee the success. Often the bottleneck of our applications happens to be the performance of computer’s memory or its wrong usage by our code. The lack of knowledge in that subject can ruin all our ambitions to create high performance implementation.
std::shared_ptr<T> - (not so) Smart hammer for every pointy nailMateusz Pusz
These are the slides from my code::dive 2016 talk. You can find the recording here: https://www.youtube.com/watch?v=hHQS-Q7aMzg. All my other talks can be found here: https://train-it.eu/resources.
---
C++ rule of thumb is “you do not pay for what you do not use”. However, it turns out that this is not the case for some of the utilities from the C++ Standard Library. The key example here is the favorite tool of many developers – std::shared_ptr. The talk will describe the problems related to it in detail. It will also try to answer the question how it was possible to avoid them.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
3. VERSION CONTROL SYSTEM git
BUILDING
PACKAGE MANAGEMENT
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
THE MOST COMMON C++ TOOLSET
2
4. VERSION CONTROL SYSTEM git
BUILDING CMake
PACKAGE MANAGEMENT
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
THE MOST COMMON C++ TOOLSET
2
5. VERSION CONTROL SYSTEM git
BUILDING CMake
PACKAGE MANAGEMENT None
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
THE MOST COMMON C++ TOOLSET
2
6. VERSION CONTROL SYSTEM git
BUILDING CMake
PACKAGE MANAGEMENT None
• Please do not partition our C++ development environment even more
• Other tools may sometimes be better at one aspect but probably are worse at others
• Until a strong game-changer appears on the market please use above tools
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
THE MOST COMMON C++ TOOLSET
2
7. VERSION CONTROL SYSTEM git
BUILDING CMake
PACKAGE MANAGEMENT None
• Please do not partition our C++ development environment even more
• Other tools may sometimes be better at one aspect but probably are worse at others
• Until a strong game-changer appears on the market please use above tools
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
THE MOST COMMON C++ TOOLSET
Conan is a strong contender to become the C++ Package Manager
2
8. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
TYPICAL WAYS TO HANDLE DEPENDENCIES IN C++ PROJECTS
3
9. 1 external or 3rdparty subdirs with external projects' source code + CMake add_subdirectory()
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
TYPICAL WAYS TO HANDLE DEPENDENCIES IN C++ PROJECTS
3
10. 1 external or 3rdparty subdirs with external projects' source code + CMake add_subdirectory()
2 External source code as git submodules + CMake add_subdirectory()
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
TYPICAL WAYS TO HANDLE DEPENDENCIES IN C++ PROJECTS
3
11. 1 external or 3rdparty subdirs with external projects' source code + CMake add_subdirectory()
2 External source code as git submodules + CMake add_subdirectory()
3 CMake ExternalProject_Add() + CMake add_subdirectory()
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
TYPICAL WAYS TO HANDLE DEPENDENCIES IN C++ PROJECTS
3
12. 1 external or 3rdparty subdirs with external projects' source code + CMake add_subdirectory()
2 External source code as git submodules + CMake add_subdirectory()
3 CMake ExternalProject_Add() + CMake add_subdirectory()
4 Downloading and installing each dependency + CMake find_package()
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
TYPICAL WAYS TO HANDLE DEPENDENCIES IN C++ PROJECTS
3
13. 1 external or 3rdparty subdirs with external projects' source code + CMake add_subdirectory()
2 External source code as git submodules + CMake add_subdirectory()
3 CMake ExternalProject_Add() + CMake add_subdirectory()
4 Downloading and installing each dependency + CMake find_package()
5 Usage of other languages' toolsets (i.e. maven, NuGet, ...)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
TYPICAL WAYS TO HANDLE DEPENDENCIES IN C++ PROJECTS
3
14. 1 external or 3rdparty subdirs with external projects' source code + CMake add_subdirectory()
2 External source code as git submodules + CMake add_subdirectory()
3 CMake ExternalProject_Add() + CMake add_subdirectory()
4 Downloading and installing each dependency + CMake find_package()
5 Usage of other languages' toolsets (i.e. maven, NuGet, ...)
6 Dedicated C++ package managers (i.e. Conan)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
TYPICAL WAYS TO HANDLE DEPENDENCIES IN C++ PROJECTS
3
15. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
add_subdirectory() FOR DEPS?
4
16. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
add_subdirectory() FOR DEPS?
5
17. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
add_subdirectory() FOR DEPS?
6
18. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
add_subdirectory() FOR DEPS? PLEASE DON'T!
7
19. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
add_subdirectory() FOR DEPS? PLEASE DON'T!
Handling dependencies as subdirectories does not scale!
7
20. Not a build system!
Cross-platform C++ build generator
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CMake
8
22. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
MODERN CMake
10
23. Build flags don't scale!
• Every change in public flags has to be propagated upwards
• Not possible to maintain flags on a large scale
• Di erent targets may require conflicting flag values
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
MODERN CMake
11
24. Build flags don't scale!
• Every change in public flags has to be propagated upwards
• Not possible to maintain flags on a large scale
• Di erent targets may require conflicting flag values
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
MODERN CMake
Modern CMake is about Targets and Properties
11
25. EXECUTABLES add_executable
SHARED LIBRARIES add_library(SHARED)
STATIC LIBRARIES add_library(STATIC)
OBJECT LIBRARIES add_library(OBJECT)
INTERFACE LIBRARIES add_library(INTERFACE)
ALIAS LIBRARIES add_library(ALIAS)
IMPORTED LIBRARIES add_library(IMPORTED [GLOBAL])
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CMake TARGET TYPES
12
26. EXECUTABLES add_executable
SHARED LIBRARIES add_library(SHARED)
STATIC LIBRARIES add_library(STATIC)
OBJECT LIBRARIES add_library(OBJECT)
INTERFACE LIBRARIES add_library(INTERFACE)
ALIAS LIBRARIES add_library(ALIAS)
IMPORTED LIBRARIES add_library(IMPORTED [GLOBAL])
• If no type is given explicitly to add_library() the type is STATIC or SHARED based on whether the
current value of the variable BUILD_SHARED_LIBS is ON
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CMake TARGET TYPES
12
27. • Available since version 2.8.12 (Oct 2013)
• Specified by target_xxx() commands
target_link_libraries(<target>
<PRIVATE|PUBLIC|INTERFACE> <item>...
[<PRIVATE|PUBLIC|INTERFACE> <item>...]...)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
MODERN CMake: MODULAR DESIGN
13
28. • Available since version 2.8.12 (Oct 2013)
• Specified by target_xxx() commands
target_link_libraries(<target>
<PRIVATE|PUBLIC|INTERFACE> <item>...
[<PRIVATE|PUBLIC|INTERFACE> <item>...]...)
NEEDED BY ME NOT NEEDED BY ME
NEEDED BY DEPENDERS PUBLIC INTERFACE
NOT NEEDED BY DEPENDERS PRIVATE :-)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
MODERN CMake: MODULAR DESIGN
13
29. • Available since version 2.8.12 (Oct 2013)
• Specified by target_xxx() commands
target_link_libraries(<target>
<PRIVATE|PUBLIC|INTERFACE> <item>...
[<PRIVATE|PUBLIC|INTERFACE> <item>...]...)
NEEDED BY ME NOT NEEDED BY ME
NEEDED BY DEPENDERS PUBLIC INTERFACE
NOT NEEDED BY DEPENDERS PRIVATE :-)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
MODERN CMake: MODULAR DESIGN
INTERFACE and PUBLIC dependencies are transitive while PRIVATE are not
13
30. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PHYSICAL DESIGN: OLD CMAKE STYLE
14
31. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PHYSICAL DESIGN: OLD CMAKE STYLE
Linking diagram only. Not useful to reveal real design problems.
14
32. • More than a linking diagram
• Logical dependencies included
• PRIVATE and PUBLIC dependencies make
di erence
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PHYSICAL DESIGN: MODERN CMAKE
15
33. • More than a linking diagram
• Logical dependencies included
• PRIVATE and PUBLIC dependencies make
di erence
• Now we see real design problems...
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PHYSICAL DESIGN: MODERN CMAKE
15
34. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
NO CYCLIC PHYSICAL DEPENDENCIES!
16
35. add_library(MyLibrary lib_source.cpp lib_source.h include/MyLibrary/lib_header.h)
add_library(MyCompany::MyLibrary ALIAS MyLibrary)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
ALIAS TARGETS
17
36. add_library(MyLibrary lib_source.cpp lib_source.h include/MyLibrary/lib_header.h)
add_library(MyCompany::MyLibrary ALIAS MyLibrary)
# find_package(MyLibrary CONFIG REQUIRED)
target_link_libraries(MyLibraryTest
PUBLIC
MyCompany::MyLibrary
GTest::Main
)
• Unifies with find_package() target naming
• :: has to be followed with Target name (prevents typos)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
ALIAS TARGETS
17
38. add_executable(hello main.cpp)
if(CMAKE_BUILD_TYPE STREQUAL DEBUG)
target_sources(hello PRIVATE helper_debug.cpp)
else()
target_sources(hello PRIVATE helper_release.cpp)
endif()
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
GENERATOR EXPRESSIONS
BAD
19
39. add_executable(hello main.cpp)
if(CMAKE_BUILD_TYPE STREQUAL DEBUG)
target_sources(hello PRIVATE helper_debug.cpp)
else()
target_sources(hello PRIVATE helper_release.cpp)
endif()
add_executable(hello main.cpp
$<IF:$<CONFIG:Debug>:helper_debug.cpp,helper_release.cpp>)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
GENERATOR EXPRESSIONS
BAD
GOOD
19
40. add_executable(hello main.cpp)
if(CMAKE_BUILD_TYPE STREQUAL DEBUG)
target_sources(hello PRIVATE helper_debug.cpp)
else()
target_sources(hello PRIVATE helper_release.cpp)
endif()
add_executable(hello main.cpp
$<IF:$<CONFIG:Debug>:helper_debug.cpp,helper_release.cpp>)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
GENERATOR EXPRESSIONS
BAD
GOOD
Never use CMAKE_BUILD_TYPE in if()
19
41. The library interface may change during installation. Use
BUILD_INTERFACE and INSTALL_INTERFACE generator expression
filters.
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
GENERATOR EXPRESSIONS
20
42. The library interface may change during installation. Use
BUILD_INTERFACE and INSTALL_INTERFACE generator expression
filters.
target_include_directories(Foo PUBLIC
$<BUILD_INTERFACE:${Foo_BINARY_DIR}/include>
$<BUILD_INTERFACE:${Foo_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
GENERATOR EXPRESSIONS
20
43. cmake_minimum_required(VERSION 3.8)
project(MyLibrary VERSION 0.0.1)
# dependencies
find_package(Foo 1.0 REQUIRED)
# library definition
add_library(MyLibrary lib_source.cpp lib_source.h include/MyLibrary/lib_header.h)
target_compile_features(MyLibrary PUBLIC cxx_std_17)
target_include_directories(MyLibrary PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(MyLibrary PRIVATE Foo::Foo)
add_library(MyCompany::MyLibrary ALIAS MyLibrary)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
MODERN LIBRARY EXAMPLE
21
44. cmake_minimum_required(VERSION 3.8)
project(MyLibrary VERSION 0.0.1)
# dependencies
find_package(Foo 1.0 REQUIRED)
# library definition
add_library(MyLibrary lib_source.cpp lib_source.h include/MyLibrary/lib_header.h)
target_compile_features(MyLibrary PUBLIC cxx_std_17)
target_include_directories(MyLibrary PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(MyLibrary PRIVATE Foo::Foo)
add_library(MyCompany::MyLibrary ALIAS MyLibrary)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
MODERN LIBRARY EXAMPLE
21
45. cmake_minimum_required(VERSION 3.8)
project(MyLibrary VERSION 0.0.1)
# dependencies
find_package(Foo 1.0 REQUIRED)
# library definition
add_library(MyLibrary lib_source.cpp lib_source.h include/MyLibrary/lib_header.h)
target_compile_features(MyLibrary PUBLIC cxx_std_17)
target_include_directories(MyLibrary PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(MyLibrary PRIVATE Foo::Foo)
add_library(MyCompany::MyLibrary ALIAS MyLibrary)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
MODERN LIBRARY EXAMPLE
21
46. cmake_minimum_required(VERSION 3.8)
project(MyLibrary VERSION 0.0.1)
# dependencies
find_package(Foo 1.0 REQUIRED)
# library definition
add_library(MyLibrary lib_source.cpp lib_source.h include/MyLibrary/lib_header.h)
target_compile_features(MyLibrary PUBLIC cxx_std_17)
target_include_directories(MyLibrary PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(MyLibrary PRIVATE Foo::Foo)
add_library(MyCompany::MyLibrary ALIAS MyLibrary)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
MODERN LIBRARY EXAMPLE
21
47. cmake_minimum_required(VERSION 3.8)
project(MyLibrary VERSION 0.0.1)
# dependencies
find_package(Foo 1.0 REQUIRED)
# library definition
add_library(MyLibrary lib_source.cpp lib_source.h include/MyLibrary/lib_header.h)
target_compile_features(MyLibrary PUBLIC cxx_std_17)
target_include_directories(MyLibrary PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(MyLibrary PRIVATE Foo::Foo)
add_library(MyCompany::MyLibrary ALIAS MyLibrary)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
MODERN LIBRARY EXAMPLE
Avoid custom variables in the arguments of project commands
21
48. • Standalone library definition and installation
• Does not change compiler's warnings!
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
FILES ORGANIZATION
MYLIBRARY/SRC/CMAKELISTS.TXT
22
49. • Standalone library definition and installation
• Does not change compiler's warnings!
• Standalone unit tests definition
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
FILES ORGANIZATION
MYLIBRARY/SRC/CMAKELISTS.TXT
MYLIBRARY/TEST/CMAKELISTS.TXT
22
50. • Standalone library definition and installation
• Does not change compiler's warnings!
• Standalone unit tests definition
• Simple project wrapper
• Entry point for development
• src and test subdirectories added with
add_subdirectory()
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
FILES ORGANIZATION
MYLIBRARY/SRC/CMAKELISTS.TXT
MYLIBRARY/TEST/CMAKELISTS.TXT
MYLIBRARY/CMAKELISTS.TXT
22
51. cmake_minimum_required(VERSION 3.5)
project(MyLibrary)
# add project code
add_subdirectory(src)
# add unit tests
enable_testing()
add_subdirectory(test)
• Useful for project development
– no need to install the library in order to run unit tests
• Entry point for IDEs like CLion or Visual Studio
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
WRAPPER: LOCAL DEVELOPMENT ENTRY POINT
23
53. Done?
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
COMPILED, BUILT, TESTED
25
54. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
DON'T BE ASOCIAL!
26
55. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
EXPORT YOUR LIBRARY INTERFACE
27
56. cmake_minimum_required(VERSION 3.8)
project(MyLibrary VERSION 0.0.1)
find_package(Foo 1.0 REQUIRED)
add_library(MyLibrary lib_source.cpp lib_source.h include/MyLibrary/lib_header.h)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
EXPORT YOUR LIBRARY INTERFACE
CMAKELISTS.TXT
28
57. cmake_minimum_required(VERSION 3.8)
project(MyLibrary VERSION 0.0.1)
find_package(Foo 1.0 REQUIRED)
add_library(MyLibrary lib_source.cpp lib_source.h include/MyLibrary/lib_header.h)
install(TARGETS MyLibrary EXPORT MyLibraryTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)
install(EXPORT MyLibraryTargets
DESTINATION lib/cmake/MyLibrary
FILE MyLibraryTargets.cmake
NAMESPACE MyCompany::)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
EXPORT YOUR LIBRARY INTERFACE
CMAKELISTS.TXT
28
58. cmake_minimum_required(VERSION 3.8)
project(MyLibrary VERSION 0.0.1)
find_package(Foo 1.0 REQUIRED)
add_library(MyLibrary lib_source.cpp lib_source.h include/MyLibrary/lib_header.h)
install(TARGETS MyLibrary EXPORT MyLibraryTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include)
install(EXPORT MyLibraryTargets
DESTINATION lib/cmake/MyLibrary
FILE MyLibraryTargets.cmake
NAMESPACE MyCompany::)
install(DIRECTORY include/MyLibrary
DESTINATION include)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
EXPORT YOUR LIBRARY INTERFACE
CMAKELISTS.TXT
28
59. cmake_minimum_required(VERSION 3.8)
project(MyLibrary VERSION 0.0.1)
find_package(Foo 1.0 REQUIRED)
add_library(MyLibrary lib_source.cpp lib_source.h include/MyLibrary/lib_header.h)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(MyLibraryConfigVersion.cmake
COMPATIBILITY SameMajorVersion)
install(FILES MyLibraryConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/MyLibraryConfigVersion.cmake
DESTINATION lib/cmake/MyLibrary)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
EXPORT YOUR LIBRARY INTERFACE
CMAKELISTS.TXT
29
60. cmake_minimum_required(VERSION 3.8)
project(MyLibrary VERSION 0.0.1)
find_package(Foo 1.0 REQUIRED)
add_library(MyLibrary lib_source.cpp lib_source.h include/MyLibrary/lib_header.h)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(MyLibraryConfigVersion.cmake
COMPATIBILITY SameMajorVersion)
install(FILES MyLibraryConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/MyLibraryConfigVersion.cmake
DESTINATION lib/cmake/MyLibrary)
include(CMakeFindDependencyMacro)
find_dependency(Foo 1.0)
include("${CMAKE_CURRENT_LIST_DIR}/MyLibraryTargets.cmake")
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
EXPORT YOUR LIBRARY INTERFACE
CMAKELISTS.TXT
MYLIBRARYCONFIG.CMAKE
29
61. • Create and install the package
mkdir src/build
cd src/build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/.local
cmake --build . --target install
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE TESTING WORKFLOW
30
62. • Create and install the package
mkdir src/build
cd src/build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/.local
cmake --build . --target install
• Compile and run tests using the installed library
mkdir test/build
cd test/build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=~/.local
ctest -VV
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE TESTING WORKFLOW
30
63. • Build each repository in isolation, generate and install its binaries along with a CMake config file
• For each project that has dependencies, use find_package() to load the config file and use the library
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PURE CMAKE: DEPENDENCIES THE WRONG WAY
PROCESS
31
64. • Build each repository in isolation, generate and install its binaries along with a CMake config file
• For each project that has dependencies, use find_package() to load the config file and use the library
• Updating a program implies recompiling its package and then every one of its dependers manually
• It doesn't scale (many levels of dependencies, many configurations, ...)
• What about supporting di erent versions?
– Release, Debug, RelWithDebInfo, ...
– di erent compilers (gcc, clang, ...), compiler versions, C++ libraries (libc++ vs libstdc++)
– di erent runtime libraries
– di erent package configurations (no exceptions, shared lib, ...)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PURE CMAKE: DEPENDENCIES THE WRONG WAY
PROCESS
PROBLEMS
31
65. • One build process builds the project and all dependencies
• Only required dependencies are being rebuilt
– reuse of prebuilt binaries if available and up-to-date
• No need to manually download, build and install the dependencies
• Possibility to use our own versions of dependencies (ZLib, Boost, etc) instead of using system versions
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
WHAT WE WANT?
32
66. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
WHAT I WANT NOW AND I DID NOT REALIZE THAT EARLIER?
33
67. • Decentralized servers
– OSS, corporate, private, etc
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
WHAT I WANT NOW AND I DID NOT REALIZE THAT EARLIER?
33
68. • Decentralized servers
– OSS, corporate, private, etc
• Central cache on local PC
– sharing of the dependencies data among di erent projects
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
WHAT I WANT NOW AND I DID NOT REALIZE THAT EARLIER?
33
69. • Decentralized servers
– OSS, corporate, private, etc
• Central cache on local PC
– sharing of the dependencies data among di erent projects
• Support for
– sources only (do not use prebuilt binaries even if available)
– sources + prebuilt binaries (improves build performance)
– binaries only (for closed source projects and development tools)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
WHAT I WANT NOW AND I DID NOT REALIZE THAT EARLIER?
33
70. • Decentralized servers
– OSS, corporate, private, etc
• Central cache on local PC
– sharing of the dependencies data among di erent projects
• Support for
– sources only (do not use prebuilt binaries even if available)
– sources + prebuilt binaries (improves build performance)
– binaries only (for closed source projects and development tools)
• O line use
– so I can start a new project with popular dependencies in a plane flying to CppCon ;-)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
WHAT I WANT NOW AND I DID NOT REALIZE THAT EARLIER?
33
71. conan.ioC++ package manager
• Conan is OSS, with a MIT license
• Decentralized package manager with
a client-server architecture
• The servers are just a package storage
– they do not build nor create the packages
• The packages are created by the client
– packaging of prebuilt binaries
– building from sources if needed
• Portable to any platform supporting Python
• Works with any build system
• Uses Python as its scripting language
• Easy hosting in a cloud or on a local server
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN
34
72. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN CLIENT-SERVER ARCHITECTURE
35
73. • Console/terminal application
• Package creation and consumption
• Local cache for package storage
– allows o line work
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN CLIENT-SERVER ARCHITECTURE
CONAN CLIENT
36
74. • Console/terminal application
• Package creation and consumption
• Local cache for package storage
– allows o line work
• Provides public and free hosting service for OSS
conan packages
• Account is only needed to upload packages
(anonymous read access)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN CLIENT-SERVER ARCHITECTURE
CONAN CLIENT
JFROG BINTRAY
36
75. • Console/terminal application
• Package creation and consumption
• Local cache for package storage
– allows o line work
• Quite simple TCP server
• User can run it as a daemon or a service
• Provides public and free hosting service for OSS
conan packages
• Account is only needed to upload packages
(anonymous read access)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN CLIENT-SERVER ARCHITECTURE
CONAN CLIENT CONAN SERVER
JFROG BINTRAY
36
76. • Console/terminal application
• Package creation and consumption
• Local cache for package storage
– allows o line work
• Quite simple TCP server
• User can run it as a daemon or a service
• Provides public and free hosting service for OSS
conan packages
• Account is only needed to upload packages
(anonymous read access)
• O ers conan repositories
• More powerful than conan server (WebUI,
multiple auth protocols, High Availability, ...)
• JFrog Artifactory Community Edition for C/C++
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN CLIENT-SERVER ARCHITECTURE
CONAN CLIENT CONAN SERVER
JFROG BINTRAY JFROG ARTIFACTORY
36
77. • Moderated, curated and well-maintained packages
• Place in which you can share your packages with the community
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
POPULAR CONAN REMOTES ON BINTRAY
CONAN-CENTER
37
78. • Moderated, curated and well-maintained packages
• Place in which you can share your packages with the community
• The Bincra ers team builds binary so ware packages for the OSS community
• Contains a wide and growing variety of Conan packages from contributors
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
POPULAR CONAN REMOTES ON BINTRAY
CONAN-CENTER
BINCRAFTERS
37
79. • Moderated, curated and well-maintained packages
• Place in which you can share your packages with the community
• The Bincra ers team builds binary so ware packages for the OSS community
• Contains a wide and growing variety of Conan packages from contributors
• Created by Conan developers
• An incubator for maturing packages
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
POPULAR CONAN REMOTES ON BINTRAY
CONAN-CENTER
BINCRAFTERS
CONAN-COMMUNITY
37
80. • Usually project/library name
• Owner of the package version
• Namespace that allows di erent users to have
their own packages for the same library with
the same name
• Any string
• Allows di erent packages for the same library
• Usually denote the maturity of a package
("stable", "testing")
package_name/package_version@user/channel
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PACKAGE IDENTIFIER
PACKAGE_NAME
USER
PACKAGE_VERSION
CHANNEL
38
83. • List packages in the local cache
conan search
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
SEARCHING FOR PACKAGES
41
84. • List packages in the local cache
conan search
• List all gtest packages in the conan-center
conan search gtest -r conan-center
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
SEARCHING FOR PACKAGES
41
85. • List packages in the local cache
conan search
• List all gtest packages in the conan-center
conan search gtest -r conan-center
• Inspect binary package details
conan search gtest/1.8.1@bincrafters/stable
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
SEARCHING FOR PACKAGES
41
86. • List packages in the local cache
conan search
• List all gtest packages in the conan-center
conan search gtest -r conan-center
• Inspect binary package details
conan search gtest/1.8.1@bincrafters/stable
• Generate table of binary packages of gtest/1.8.1@bincrafters/stable on conan-center
conan search gtest/1.8.1@bincrafters/stable -r conan-center --table=conan_matrix.html
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
SEARCHING FOR PACKAGES
41
87. conan search gtest/1.8.1@bincrafters/stable
Existing packages for recipe gtest/1.8.1@bincrafters/stable:
Package_ID: a4062ec0208a59375ac653551e662b6cc469fe58
[options]
build_gmock: True
fPIC: True
shared: False
[settings]
arch: x86_64
build_type: Release
compiler: gcc
compiler.libcxx: libstdc++11
compiler.version: 7
os: Linux
Outdated from recipe: False
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE DETAILS
42
88. • Inspect your current project’s dependencies
conan info ..
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
INSPECTING DEPENDENCIES
43
89. • Inspect your current project’s dependencies
conan info ..
• Inspect dependencies of OpenSSL/1.1.0i@conan/stable
conan info OpenSSL/1.1.0i@conan/stable
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
INSPECTING DEPENDENCIES
43
90. • Inspect your current project’s dependencies
conan info ..
• Inspect dependencies of OpenSSL/1.1.0i@conan/stable
conan info OpenSSL/1.1.0i@conan/stable
• Generates a graph of dependencies of current project
conan info .. --graph=graph.html
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
INSPECTING DEPENDENCIES
43
91. OpenSSL/1.1.0i@conan/stable
ID: 75b541b6f810787a4fcee8cec9cfdbf95959366f
BuildID: None
Remote: conan-center=https://conan.bintray.com
URL: http://github.com/lasote/conan-openssl
License: The current OpenSSL licence is an 'Apache style' license: https://www.openssl.org/source/license.html
Recipe: Downloaded
Binary: Download
Binary remote: conan-center
Creation date: 2018-08-28 09:02:07
Required by:
PROJECT
Requires:
zlib/1.2.11@conan/stable
zlib/1.2.11@conan/stable
ID: 6ae331b72e7e265ca2a3d1d8246faf73aa030238
BuildID: None
Remote: conan-center=https://conan.bintray.com
URL: http://github.com/lasote/conan-zlib
License: http://www.zlib.net/zlib_license.html
Recipe: Cache
Binary: Cache
Binary remote: conan-center
Creation date: 2018-08-30 15:46:32
Required by:
OpenSSL/1.1.0i@conan/stable
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE DEPENDENCIES
44
92. • Installing specific package by hand
conan install gtest/1.8.1@bincrafters/stable -g cmake
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
INSTALLING DEPENDENCIES
45
93. • Installing specific package by hand
conan install gtest/1.8.1@bincrafters/stable -g cmake
• Usage of project-specific conanfile.txt or conanfile.py files
conan install ..
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
INSTALLING DEPENDENCIES
45
94. • Installing specific package by hand
conan install gtest/1.8.1@bincrafters/stable -g cmake
• Usage of project-specific conanfile.txt or conanfile.py files
conan install ..
• Optionally a profile name can be provided (otherwise profile named default is used)
conan install .. -pr vs2017
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
INSTALLING DEPENDENCIES
45
95. • Installing specific package by hand
conan install gtest/1.8.1@bincrafters/stable -g cmake
• Usage of project-specific conanfile.txt or conanfile.py files
conan install ..
• Optionally a profile name can be provided (otherwise profile named default is used)
conan install .. -pr vs2017
• Build missing packages from sources (if prebuilt ones are not available)
conan install .. -b missing
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
INSTALLING DEPENDENCIES
45
96. [requires]
Foo/1.0@my_channel/stable
gtest/1.8.1@bincrafters/stable
[options]
[generators]
cmake
• cmake generator creates conanbuildinfo.cmake file that defines
– CMake variables (module paths include paths, library names, ...)
– CMake helper functions (defining targets, configuring CMake environment, ...)
• Many di erent generators provided to support any build system
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN FILES
CONANFILE.TXT
46
97. [requires]
Foo/1.0@my_channel/stable
gtest/1.8.1@bincrafters/stable
[options]
[generators]
cmake
from conans import ConanFile
class MyLibraryConan(ConanFile):
requires = (
"Foo/1.0@my_channel/stable",
"gtest/1.8.1@bincrafters/stable"
)
generators = "cmake"
• cmake generator creates conanbuildinfo.cmake file that defines
– CMake variables (module paths include paths, library names, ...)
– CMake helper functions (defining targets, configuring CMake environment, ...)
• Many di erent generators provided to support any build system
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN FILES
CONANFILE.TXT CONANFILE.PY
46
99. [requires]
Foo/1.0@my_channel/stable
gtest/1.8.1@bincrafters/stable
[options]
gtest:shared=True
[generators]
cmake
from conans import ConanFile
class MyLibraryConan(ConanFile):
requires = (
"Foo/1.0@my_channel/stable",
"gtest/1.8.1@bincrafters/stable"
)
default_options = "gtest:shared=True"
generators = "cmake"
• Command line override
conan install .. -o gtest:shared=True
conan install .. -o *:shared=True
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
SETTING PACKAGE OPTIONS
CONANFILE.TXT CONANFILE.PY
47
100. [requires]
Foo/1.0@my_channel/stable
gtest/1.8.1@bincrafters/stable
[options]
gtest:shared=True
[generators]
cmake
[imports]
bin, *.dll -> ./bin
lib, *.dylib* -> ./bin
from conans import ConanFile
class MyLibraryConan(ConanFile):
requires = (
"Foo/1.0@my_channel/stable",
"gtest/1.8.1@bincrafters/stable"
)
default_options = "gtest:shared=True"
generators = "cmake"
def imports(self):
self.copy("*.dll", dst="bin", src="bin")
self.copy("*.dylib*", dst="bin", src="lib")
• Copies all *.dll files from packages bin folder to my ./bin folder
• Copies all *.dylib* files from packages lib folder to my ./bin folder
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
FIXING IMPORTS FOR SHARED LIBRARIES
CONANFILE.TXT CONANFILE.PY
48
101. from conans import ConanFile, CMake
class MyLibraryConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
requires = (
"Foo/1.0@my_channel/stable",
"gtest/1.8.1@bincrafters/stable"
)
generators = "cmake"
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
cmake.install()
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
MORE POWER WITH CONANFILE.PY
49
102. from conans import ConanFile, CMake
class MyLibraryConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
requires = (
"Foo/1.0@my_channel/stable",
"gtest/1.8.1@bincrafters/stable"
)
generators = "cmake"
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
cmake.install()
conan install . -pr vs2017 --install-folder build
conan build . --build-folder build
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
MORE POWER WITH CONANFILE.PY
49
103. from conans import ConanFile
class MyLibraryConan(ConanFile):
requires = (
"gtest/1.8.1@bincrafters/stable"
)
options = { "testing": [True, False] }
default_options = "testing=False"
generators = "cmake"
def requirements(self):
if self.options.testing:
self.requires("Foo/2.0@my_channel/testing")
else:
self.requires("Foo/1.0@my_channel/stable")
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
MORE POWER WITH CONANFILE.PY
50
104. from conans import ConanFile
class MyLibraryConan(ConanFile):
requires = (
"gtest/1.8.1@bincrafters/stable"
)
options = { "testing": [True, False] }
default_options = "testing=False"
generators = "cmake"
def requirements(self):
if self.options.testing:
self.requires("Foo/2.0@my_channel/testing")
else:
self.requires("Foo/1.0@my_channel/stable")
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
MORE POWER WITH CONANFILE.PY
And many more features...
50
106. conan profile show clang6
Configuration for profile clang6:
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=clang
compiler.version=6.0
compiler.libcxx=libstdc++11
build_type=Release
[options]
[build_requires]
[env]
CC=/usr/bin/clang
CXX=/usr/bin/clang++
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PROFILES
52
107. conan profile show clang6
Configuration for profile clang6:
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=clang
compiler.version=6.0
compiler.libcxx=libstdc++11
build_type=Release
[options]
[build_requires]
[env]
CC=/usr/bin/clang
CXX=/usr/bin/clang++
• Easy to override or extend the profile
conan install .. -pr clang6 -s build_type=Debug
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PROFILES
52
108. • Example of a Conan profile file distributed with the project source code
include(default)
[settings]
build_type=Debug
[options]
Poco:shared=True
Poco:enable_apacheconnector=False
OpenSSL:shared=True
conan install .. -pr=../debug_shared
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PROFILES
DEBUG_SHARED
53
109. 1 The package recipe independent of the project source code repository
• packaging 3rd party libraries
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PACKAGES
54
110. 1 The package recipe independent of the project source code repository
2 The package recipe inside the project source code repository
• packaging own library
• 2 approaches
– exporting snapshot of the source code together with the recipe
– exporting only the recipe and obtaining the source code from the project repository
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PACKAGES
55
111. 1 The package recipe independent of the project source code repository
2 The package recipe inside the project source code repository
3 Packaging existing binaries
• only prebuilt 3rd party binaries are available
• artifacts already built and no need to rebuild
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PACKAGES
56
112. 1 The package recipe independent of the project source code repository
2 The package recipe inside the project source code repository
3 Packaging existing binaries
4 Packaging of the development tools
• distribution of the development tools needed to build the project (i.e. CMake, nasm)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PACKAGES
57
113. • ./conanfile.py
– main recipe file used to create a package
• ./LICENSE
– licence of the Conan package source code
– not to be confused with a license of a
packaged project
• ./test_package
– simple package consumer project
• ./test_package/conanfile.py
– recipe of a testing project
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
TYPICAL CONAN PACKAGE CONTENTS
58
114. class GoogleBenchmarkConan(ConanFile):
name = "google-benchmark"
version = "1.4.1"
description = "A microbenchmark support library"
# ...
• Basic package information
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE RECIPE ATTRIBUTES
59
115. class GoogleBenchmarkConan(ConanFile):
name = "google-benchmark"
version = "1.4.1"
description = "A microbenchmark support library"
license = "https://github.com/google/benchmark/blob/master/LICENSE"
# ...
• The license of the packaged project
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE RECIPE ATTRIBUTES
60
116. class GoogleBenchmarkConan(ConanFile):
name = "google-benchmark"
version = "1.4.1"
description = "A microbenchmark support library"
license = "https://github.com/google/benchmark/blob/master/LICENSE"
url = "https://github.com/mpusz/conan-google-benchmark"
# ...
• Link to the Conan package repository (not the packaged project)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE RECIPE ATTRIBUTES
61
117. class GoogleBenchmarkConan(ConanFile):
name = "google-benchmark"
version = "1.4.1"
description = "A microbenchmark support library"
license = "https://github.com/google/benchmark/blob/master/LICENSE"
url = "https://github.com/mpusz/conan-google-benchmark"
exports = ["LICENSE"]
# ...
• Copies a packaging code license to be stored within a package
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE RECIPE ATTRIBUTES
62
118. class GoogleBenchmarkConan(ConanFile):
name = "google-benchmark"
version = "1.4.1"
description = "A microbenchmark support library"
license = "https://github.com/google/benchmark/blob/master/LICENSE"
url = "https://github.com/mpusz/conan-google-benchmark"
exports = ["LICENSE"]
settings = "os", "arch", "compiler", "build_type"
# ...
• The configuration of the di erent binary packages
• Any change in those parameters will generate a di erent binary package
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE RECIPE ATTRIBUTES
63
119. class GoogleBenchmarkConan(ConanFile):
name = "google-benchmark"
version = "1.4.1"
description = "A microbenchmark support library"
license = "https://github.com/google/benchmark/blob/master/LICENSE"
url = "https://github.com/mpusz/conan-google-benchmark"
exports = ["LICENSE"]
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"exceptions": [True, False],
"lto": [True, False],
}
default_options = ("shared=False", "exceptions=True", "lto=False")
# ...
• Package options and their default values
• Any change in those parameters will generate a di erent binary package
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE RECIPE ATTRIBUTES
64
120. class GoogleBenchmarkConan(ConanFile):
name = "google-benchmark"
version = "1.4.1"
description = "A microbenchmark support library"
license = "https://github.com/google/benchmark/blob/master/LICENSE"
url = "https://github.com/mpusz/conan-google-benchmark"
exports = ["LICENSE"]
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"exceptions": [True, False],
"lto": [True, False],
}
default_options = ("shared=False", "exceptions=True", "lto=False")
scm = {
"type": "git",
"url": "https://github.com/google/benchmark.git",
"revision": "v%s" % version
}
# ...
• Packaged project repository information
• Used to obtain project source code to build and pack
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE RECIPE ATTRIBUTES
65
121. • Project-wide and common to all the dependencies in order for them to link together without issues
with the project being built
• Provided by the environment and cannot be defaulted in the recipe
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
SETTINGS VS OPTIONS
SETTINGS
66
122. • Project-wide and common to all the dependencies in order for them to link together without issues
with the project being built
• Provided by the environment and cannot be defaulted in the recipe
• Package-specific configuration and each dependency can provide di erent set of options to fulfill their
configuration needs
• Default option values provided in the recipe file can be overridden by the user
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
SETTINGS VS OPTIONS
SETTINGS
OPTIONS
66
123. • generators - not needed only if a package does not have any dependencies
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
OTHER USEFUL ATTRIBUTES
67
124. • generators - not needed only if a package does not have any dependencies
• requires - package dependencies
class MyLibConan(ConanFile):
requires = (("Hello/[>1.0,<2.0]@user/testing"),
("Bye/2.1@coder/beta", "private"),
("Say/0.2@dummy/stable", "override"))
– private - not exposed to clients, non-transitive
– override - does not introduce a new dependency, overrides a version if it is a dependency already
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
OTHER USEFUL ATTRIBUTES
67
125. • generators - not needed only if a package does not have any dependencies
• requires - package dependencies
class MyLibConan(ConanFile):
requires = (("Hello/[>1.0,<2.0]@user/testing"),
("Bye/2.1@coder/beta", "private"),
("Say/0.2@dummy/stable", "override"))
– private - not exposed to clients, non-transitive
– override - does not introduce a new dependency, overrides a version if it is a dependency already
– version ranges
>1.1,<2.1 # in such range
2.8 # equivalent to =2.8
~=3.0 # compatible, according to semver
>1.1 || 0.8 # conditions can be OR'ed
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
OTHER USEFUL ATTRIBUTES
67
126. • build_requires - build-time only dependencies
– only needed to build a package from sources
– dev tools, compilers, build systems, code analyzers, testing libraries, etc.
– non-transitive
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
OTHER USEFUL ATTRIBUTES
68
127. • build_requires - build-time only dependencies
– only needed to build a package from sources
– dev tools, compilers, build systems, code analyzers, testing libraries, etc.
– non-transitive
• exports - copies provided files to be stored in a package along with the recipe
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
OTHER USEFUL ATTRIBUTES
68
128. • build_requires - build-time only dependencies
– only needed to build a package from sources
– dev tools, compilers, build systems, code analyzers, testing libraries, etc.
– non-transitive
• exports - copies provided files to be stored in a package along with the recipe
• exports_sources - creates a snapshot of the packaged project source code in the package
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
OTHER USEFUL ATTRIBUTES
68
129. • build_requires - build-time only dependencies
– only needed to build a package from sources
– dev tools, compilers, build systems, code analyzers, testing libraries, etc.
– non-transitive
• exports - copies provided files to be stored in a package along with the recipe
• exports_sources - creates a snapshot of the packaged project source code in the package
• homepage - the home web page of the library being packaged
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
OTHER USEFUL ATTRIBUTES
68
130. class GoogleBenchmarkConan(ConanFile):
options = {
"shared": [True, False],
"exceptions": [True, False],
"lto": [True, False],
}
# ...
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["BENCHMARK_ENABLE_EXCEPTIONS"] = "ON" if self.options.exceptions else "OFF"
cmake.definitions["BENCHMARK_ENABLE_LTO"] = "ON" if self.options.lto else "OFF"
cmake.definitions["BENCHMARK_ENABLE_TESTING"] = "OFF"
cmake.configure()
return cmake
# ...
• Helper method to configure CMake
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE RECIPE METHODS
69
131. class GoogleBenchmarkConan(ConanFile):
options = {
"shared": [True, False],
"exceptions": [True, False],
"lto": [True, False],
}
# ...
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["BENCHMARK_ENABLE_EXCEPTIONS"] = "ON" if self.options.exceptions else "OFF"
cmake.definitions["BENCHMARK_ENABLE_LTO"] = "ON" if self.options.lto else "OFF"
cmake.definitions["BENCHMARK_ENABLE_TESTING"] = "OFF"
cmake.configure()
return cmake
# ...
• CMake helper automatically appends some definitions based on popular settings
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE RECIPE METHODS
70
132. class GoogleBenchmarkConan(ConanFile):
options = {
"shared": [True, False],
"exceptions": [True, False],
"lto": [True, False],
}
# ...
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["BENCHMARK_ENABLE_EXCEPTIONS"] = "ON" if self.options.exceptions else "OFF"
cmake.definitions["BENCHMARK_ENABLE_LTO"] = "ON" if self.options.lto else "OFF"
cmake.definitions["BENCHMARK_ENABLE_TESTING"] = "OFF"
cmake.configure()
return cmake
# ...
• Compiling unit tests makes the packaging longer and does not influence the binary package content
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE RECIPE METHODS
71
133. class GoogleBenchmarkConan(ConanFile):
options = {
"shared": [True, False],
"exceptions": [True, False],
"lto": [True, False],
}
# ...
def _configure_cmake(self):
# ...
def build(self):
cmake = self._configure_cmake()
cmake.build()
# ...
• Configures and builds the project
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE RECIPE METHODS
72
134. class GoogleBenchmarkConan(ConanFile):
options = {
"shared": [True, False],
"exceptions": [True, False],
"lto": [True, False],
}
# ...
def _configure_cmake(self):
# ...
def build(self):
cmake = self._configure_cmake()
cmake.build()
def package(self):
cmake = self._configure_cmake()
cmake.install()
self.copy("license*", dst="licenses", ignore_case=True, keep_path=False)
# ...
• Copies packaged project binaries, CMake configuration files, and its license to the package
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE RECIPE METHODS
73
135. class GoogleBenchmarkConan(ConanFile):
options = {
"shared": [True, False],
"exceptions": [True, False],
"lto": [True, False],
}
# ...
def _configure_cmake(self):
# ...
def build(self):
cmake = self._configure_cmake()
cmake.build()
def package(self):
cmake = self._configure_cmake()
cmake.install()
self.copy("license*", dst="licenses", ignore_case=True, keep_path=False)
def package_info(self):
self.cpp_info.libs = ["benchmark"]
# ...
• Defines the target that the consumer must link with when using this package
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE RECIPE METHODS
74
136. • source() - retrieves the source code from external origin (git, *.tgz, ...)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
OTHER USEFUL METHODS
75
137. • source() - retrieves the source code from external origin (git, *.tgz, ...)
• requirements() - defines more advanced requirements logic
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
OTHER USEFUL METHODS
75
138. • source() - retrieves the source code from external origin (git, *.tgz, ...)
• requirements() - defines more advanced requirements logic
• build_requirements() - defines dependencies used when the package is built from sources
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
OTHER USEFUL METHODS
75
139. • source() - retrieves the source code from external origin (git, *.tgz, ...)
• requirements() - defines more advanced requirements logic
• build_requirements() - defines dependencies used when the package is built from sources
• imports() - copies files from the local store to client's project
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
OTHER USEFUL METHODS
75
140. • source() - retrieves the source code from external origin (git, *.tgz, ...)
• requirements() - defines more advanced requirements logic
• build_requirements() - defines dependencies used when the package is built from sources
• imports() - copies files from the local store to client's project
• package_id() - creates a unique ID for the package
def package_id(self):
self.info.header_only()
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
OTHER USEFUL METHODS
75
141. • source() - retrieves the source code from external origin (git, *.tgz, ...)
• requirements() - defines more advanced requirements logic
• build_requirements() - defines dependencies used when the package is built from sources
• imports() - copies files from the local store to client's project
• package_id() - creates a unique ID for the package
def package_id(self):
self.info.header_only()
• configure() - configures or constrains/validates the available options in a package
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
OTHER USEFUL METHODS
75
142. • source() - retrieves the source code from external origin (git, *.tgz, ...)
• requirements() - defines more advanced requirements logic
• build_requirements() - defines dependencies used when the package is built from sources
• imports() - copies files from the local store to client's project
• package_id() - creates a unique ID for the package
def package_id(self):
self.info.header_only()
• configure() - configures or constrains/validates the available options in a package
• config_options() - constrains the available options in a package, before they are given a value
def config_options(self):
if self.settings.os == 'Windows':
del self.options.fPIC
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
OTHER USEFUL METHODS
75
143. • test_package di ers from the library unit or integration tests (which should be more comprehensive)
• Packaging tests to verify that
– the package is properly created
– the package consumers will be able to link against it and reuse it
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
THE test_package DIRECTORY
76
144. from conans import ConanFile, CMake
class GoogleBenchmarkTestConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake_paths"
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def imports(self):
self.copy("*.dll", dst="bin", src="bin")
self.copy("*.dylib*", dst="bin", src="lib")
self.copy('*.so*', dst='bin', src='lib')
def test(self):
cmake = CMake(self)
self.run("ctest -VV -C %s" % cmake.build_type)
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
THE test_package RECIPE
77
145. from conans import ConanFile, CMake
class GoogleBenchmarkTestConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake_paths"
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def imports(self):
self.copy("*.dll", dst="bin", src="bin")
self.copy("*.dylib*", dst="bin", src="lib")
self.copy('*.so*', dst='bin', src='lib')
def test(self):
cmake = CMake(self)
self.run("ctest -VV -C %s" % cmake.build_type)
• requires attribute skipped as all needed information (e.g. project version) is automatically injected
by Conan during the package creation
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
THE test_package RECIPE
77
146. conan create . google-benchark/testing
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PACKAGE CREATION
78
147. conan create . google-benchark/testing
• Exports the conanfile.py and files specified by the exports_sources field into the local cache
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PACKAGE CREATION
78
148. conan create . google-benchark/testing
• Exports the conanfile.py and files specified by the exports_sources field into the local cache
• Installs the package, forcing it to be built from the sources
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PACKAGE CREATION
78
149. conan create . google-benchark/testing
• Exports the conanfile.py and files specified by the exports_sources field into the local cache
• Installs the package, forcing it to be built from the sources
• Creates a temporary ./test_package/build directory
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PACKAGE CREATION
78
150. conan create . google-benchark/testing
• Exports the conanfile.py and files specified by the exports_sources field into the local cache
• Installs the package, forcing it to be built from the sources
• Creates a temporary ./test_package/build directory
• Executes the conan install .., to install the requirements of the ./test_package/conanfile.py
and the packaged project
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PACKAGE CREATION
78
151. conan create . google-benchark/testing
• Exports the conanfile.py and files specified by the exports_sources field into the local cache
• Installs the package, forcing it to be built from the sources
• Creates a temporary ./test_package/build directory
• Executes the conan install .., to install the requirements of the ./test_package/conanfile.py
and the packaged project
• Builds and launches the example consuming application, calling the ./test_package/conanfile.py
build() and test() methods
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PACKAGE CREATION
78
152. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGING STEPS
79
153. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGING STEPS
79
154. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGING STEPS
79
155. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGING STEPS
79
156. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGING STEPS
79
157. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGING STEPS
79
158. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGING STEPS
79
159. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGING STEPS
79
160. conan create . user/channel
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PACKAGE DEVELOPMENT FLOW: OUT-OF-SOURCE
80
161. conan create . user/channel
conan create . user/channel --keep-source
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PACKAGE DEVELOPMENT FLOW: OUT-OF-SOURCE
80
162. conan create . user/channel
conan create . user/channel --keep-source
conan create . user/channel --keep-build
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PACKAGE DEVELOPMENT FLOW: OUT-OF-SOURCE
80
163. conan create . user/channel
conan create . user/channel --keep-source
conan create . user/channel --keep-build
conan test test_package MyLibrary/0.1@user/channel
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PACKAGE DEVELOPMENT FLOW: OUT-OF-SOURCE
80
164. conan source . --source-folder=tmp/source
conan install . --install-folder=tmp/build [--profile XXXX]
conan build . --source-folder=tmp/source --build-folder=tmp/build
conan package . --source-folder=tmp/source --build-folder=tmp/build --package-folder=tmp/package
conan export-pkg . user/testing --package-folder=tmp/package
conan test test_package MyLibrary/0.1@user/channel
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PACKAGE DEVELOPMENT FLOW: IN-SOURCE
81
165. conan source . --source-folder=tmp/source
conan install . --install-folder=tmp/build [--profile XXXX]
conan build . --source-folder=tmp/source --build-folder=tmp/build
conan package . --source-folder=tmp/source --build-folder=tmp/build --package-folder=tmp/package
conan export-pkg . user/testing --package-folder=tmp/package
conan test test_package MyLibrary/0.1@user/channel
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
CONAN PACKAGE DEVELOPMENT FLOW: IN-SOURCE
Even smaller steps are possible with --configure, --build, --install
options of conan build command
81
166. • Recipe should include description, license, and url attributes
• Use only lowercase letters in package names
• Include test_package
• Raise errors on invalid configurations
• Do not use version ranges
• Distribute packaged so ware license files in binary packages
• Export packaging code license
• Use clean python code and the latest Conan features
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
PACKAGE QUALITY
82
167. • If not done already, add the Conan remote
conan remote add conan-mpusz https://bintray.com/mpusz/conan-mpusz
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
UPLOADING A PACKAGE
83
168. • If not done already, add the Conan remote
conan remote add conan-mpusz https://bintray.com/mpusz/conan-mpusz
• Upload the package recipe and all binaries to the Conan remote
conan upload google-benchmark/1.4.1@mpusz/stable -r conan_mpusz --all
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
UPLOADING A PACKAGE
83
169. 1 cmake
2 cmake_multi
3 cmake_paths
4 cmake_find_package
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
USING CONAN WITH CMAKE: GENERATORS
84
170. • Creates conanbuildinfo.cmake file that defines CMake
– variables (module paths include paths, library names, ...)
– helper functions (defining targets, configuring CMake environment, ...)
• Changes to CMakeLists.txt file are required
cmake_minimum_required(VERSION 3.5)
project(MyLibrary)
if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
endif()
# ...
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
cmake GENERATOR
85
171. • Creates conanbuildinfo_multi.cmake file
• Used with multi-configuration environments like Visual Studio and Xcode
• Does not configure for a specific build_type, like Debug or Release
• Cannot be used to create packages and issues with find_package() usage
• Changes to CMakeLists.txt file are required
cmake_minimum_required(VERSION 3.5)
project(MyLibrary)
if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo_multi.cmake)
include(${CMAKE_BINARY_DIR}/conanbuildinfo_multi.cmake)
conan_basic_setup(TARGETS)
endif()
# ...
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
cmake_multi GENERATOR
86
172. • Creates conan_paths.cmake file that defines
– CMAKE_MODULE_PATH used by find_package() to find CMake configuration and FindXXX.cmake files
– CMAKE_PREFIX_PATH used by find_library() to locate library files in packages
cmake_minimum_required(VERSION 3.5)
project(MyLibrary)
include(${CMAKE_BINARY_DIR}/conan_paths.cmake OPTIONAL)
# ...
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
cmake_paths GENERATOR
87
173. • Creates conan_paths.cmake file that defines
– CMAKE_MODULE_PATH used by find_package() to find CMake configuration and FindXXX.cmake files
– CMAKE_PREFIX_PATH used by find_library() to locate library files in packages
cmake_minimum_required(VERSION 3.5)
project(MyLibrary)
include(${CMAKE_BINARY_DIR}/conan_paths.cmake OPTIONAL)
# ...
• Can work without doing any changes to CMake files
cmake .. -DCMAKE_PROJECT_MyLibrary_INCLUDE=conan_paths.cmake -DCMAKE_BUILD_TYPE=Release
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
cmake_paths GENERATOR
87
174. • Creates Find<package_name>.cmake file for each requirement specified in the conanfile
• When used with CMake helper in build() method of conanfile.py no changes to CMake files needed
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
cmake_find_package GENERATOR
88
175. • Creates Find<package_name>.cmake file for each requirement specified in the conanfile
• When used with CMake helper in build() method of conanfile.py no changes to CMake files needed
• When used with conanfile.txt
– can be used together with cmake_paths generator
[requires]
...
[generators]
cmake_find_package
cmake_paths
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
cmake_find_package GENERATOR
88
176. • Creates Find<package_name>.cmake file for each requirement specified in the conanfile
• When used with CMake helper in build() method of conanfile.py no changes to CMake files needed
• When used with conanfile.txt
– can be used together with cmake_paths generator
[requires]
...
[generators]
cmake_find_package
cmake_paths
– CMAKE_MODULE_PATH can be updated manually
cmake_minimum_required(VERSION 3.5)
project(MyLibrary)
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
# ...
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
cmake_find_package GENERATOR
88
177. class MyLibraryConan(ConanFile):
# ...
generators = "cmake"
def source(self):
# ...
tools.replace_in_file("%s/CMakeLists.txt" % self.subfolder,
"project(MyLibrary)",
"""project(MyLibrary)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()""")
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
BKM: AUTOMATION OF UPDATING CMakeLists.txt FILE
OPTION 1
89
178. class MyLibraryConan(ConanFile):
# ...
exports_sources = ["CMakeLists.txt"]
generators = "cmake"
scm = {
"type": "git",
"subfolder": "source_subfolder",
# ...
}
project(MyLibraryWrapper)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
add_subdirectory("source_subfolder")
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
BKM: AUTOMATION OF UPDATING CMakeLists.txt FILE
OPTION 2
90
179. class MyLibraryConan(ConanFile):
# ...
generators = "cmake_paths"
def build_requirements(self):
if tools.get_env("CONAN_RUN_TESTS", False):
self.build_requires("gtest/1.8.1@bincrafters/stable")
def _configure_cmake(self):
cmake = CMake(self)
# ...
cmake.definitions["BENCHMARK_ENABLE_TESTING"] = "ON" if tools.get_env("CONAN_RUN_TESTS", False) else "OFF"
cmake.definitions["CMAKE_PROJECT_benchmark_INCLUDE"] = "conan_paths.cmake"
cmake.configure()
return cmake
def build(self):
cmake = self._configure_cmake()
cmake.build()
if tools.get_env("CONAN_RUN_TESTS", False):
cmake.test()
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
BKM: HOW TO RUN UNIT TESTS DURING PACKAGING PROCESS?
91
180. class MyLibraryConan(ConanFile):
# ...
generators = "cmake_paths"
def build_requirements(self):
if tools.get_env("CONAN_RUN_TESTS", False):
self.build_requires("gtest/1.8.1@bincrafters/stable")
def _configure_cmake(self):
cmake = CMake(self)
# ...
cmake.definitions["BENCHMARK_ENABLE_TESTING"] = "ON" if tools.get_env("CONAN_RUN_TESTS", False) else "OFF"
cmake.definitions["CMAKE_PROJECT_benchmark_INCLUDE"] = "conan_paths.cmake"
cmake.configure()
return cmake
def build(self):
cmake = self._configure_cmake()
cmake.build()
if tools.get_env("CONAN_RUN_TESTS", False):
cmake.test()
• To enable building and running tests define environment variable, set it in a profile file, or run
conan create . user/channel -e CONAN_RUN_TESTS=1
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
BKM: HOW TO RUN UNIT TESTS DURING PACKAGING PROCESS?
91
181. • Package is asocial (does not have CMake configuration files or FindXXX.cmake file)
• Existing "o icial" FindXXX.cmake file is not able to find our libraries
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
BKM: CUSTOM FindXXX.cmake FILE
REASON
92
182. • Package is asocial (does not have CMake configuration files or FindXXX.cmake file)
• Existing "o icial" FindXXX.cmake file is not able to find our libraries
• Create a custom FindXXX.cmake file in package root folder and export it with the package
class MyLibraryConan(ConanFile):
name = "my-library"
version = "0.1"
# ...
exports_sources = ["FindMyLibrary.cmake"]
def package(self):
# ...
self.copy("FindMyLibrary.cmake", ".", ".")
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
BKM: CUSTOM FindXXX.cmake FILE
REASON
BKM
92
183. class MyLibraryConan(ConanFile):
name = "my-library"
version = "0.1"
something = ""
some_dynamic_path = ""
def source(self):
self.something = "Hello"
some_dynamic_path = find_some_dynamic_path()
def build(self):
print(self.something)
use_some_dynamic_path(some_dynamic_path)
def package(self):
print(self.something)
use_some_dynamic_path(some_dynamic_path)
• Works fine with conan create . user/channel because it calls all the methods in sequence
• Problems with commands that execute only a part of the sequence
– i.e. the source() and build() methods won’t be called at all when you run conan package
command
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
BKM: DO NOT USE CLASS VARIABLES TO SHARE STATE
93
184. CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
SUMMARY
94
185. • Many projects still do not use CMake at all
• Many projects still do not use CMake in a Modern way
• Many projects still do not provide installation option with proper CMake configuration files generation
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
SUMMARY
CMAKE
94
186. • Many projects still do not use CMake at all
• Many projects still do not use CMake in a Modern way
• Many projects still do not provide installation option with proper CMake configuration files generation
• Production quality Package Manager designed with C++ in mind
• For free and on MIT license
• Easy to use and the documentation is really good
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
SUMMARY
CMAKE
CONAN
94
187. • Many projects still do not use CMake at all
• Many projects still do not use CMake in a Modern way
• Many projects still do not provide installation option with proper CMake configuration files generation
• Production quality Package Manager designed with C++ in mind
• For free and on MIT license
• Easy to use and the documentation is really good
• Give it a try!
pip install conan
CppCon 2018 | Git, CMake, Conan - How to ship and reuse our C++ projects
SUMMARY
CMAKE
CONAN
94