SlideShare a Scribd company logo
Managing Dependenciesin C++
Kutsan Aleksandr
2020-11-26
2www.luxoft.com
Problems in life
 From time to time I can see gtest gmock sources in
projects, weird.
 Many times I totally don’t understand dependencies of
the project when I start working with it.
 Building project on another environment or cross-
compilation becomes painful.
 After some system changes project in not compliable
or works in correctly.
3www.luxoft.com
Presentation Manual
Dependencies types
Corporate Deck
Compile time dependencies
Need to be installed to developer workstation,
CI/CD server.
Required for building applications.
Compile and runtime
dependencies
*-dev libraries and header need to be installed on
developer workstation and CI/CD servers.
Required for building applications.
Library also required for application runtime.
Usually a shared library.
Only runtime dependencies
Usually IPC services like Dbus, vsomeip,
rabbitmq.
In case if application is some kind of a
framework/extension/plugin, runtime
dependency can be the pluggable application.
4www.luxoft.com
Compile time dependencies
management approaches
 Store dependencies sources within application
sources
 Fetch dependencies sources before compilation
 Use pre-installed dependencies on the system
 Fetch dependencies binaries before compilation
5www.luxoft.com
Store dependencies sources near the application sources
 You should take care about fetching security patches of the dependencies.
 Dependencies may have their dependencies.
 A lot of code to store.
 Code of the dependency is now your code, and you should take care of it.
 You can be sure that you have all assets for program compilation.
 Don’t need internet to compile a program.
 Compilation takes extremely long time.
 Dependencies is part of the program, but developers would not like to recompile it even after a clean build. Need to create a
separate compile target that will install dependencies.
 Bad idea to install dependencies to the system during compilation.
 Dependencies may have different compile/configure approaches, so it may be tricky to integrate it to your build system.
6www.luxoft.com
Fetch dependencies sources during compilation
 You need internet to build our system
 Now you don’t have to apply security patches yourself.
 Servers are sometimes down.
 In 5/10/20 years appropriate sources may not be accessible via specified links.
 Compilation is still too long.
 You still need to find out how to install dependencies but not pollute the system with it.
 Build approach still may be different.
 If you use git for fetching sources, you should never use master branch - use specific tag instead.
7www.luxoft.com
Fetch dependencies binaries during compilation
 You need internet to build our system.
 Now you don’t have to apply security patches yourself.
 Servers are sometimes down.
 In 5/10/20 years appropriate sources may be not accessible by specified links.
 You still need to find out how to install dependencies but not pollute the system with it.
8www.luxoft.com
 Project is clear and contains only meaningful sources. That is nice.
 You require a developer to modify the system for application compilation.
 Dependencies on the system may have a different version.
 Dependencies on the system may be stored by unexpected paths: /opt, /home, etc.
 Dependencies may be patched or even “infected”. Do you really trust the user environment?
Use preinstalled compile time dependencies
9www.luxoft.com
 Project is clear and contains only meaningful sources. That is nice.
 Developer may build a container or fetch container binaries.
 Developer may recreate an environment on a local workstation and build as needed.
 Can be tricky to integrate with IDE.
 Build container can be extremely heavy, but I don’t feel like it’s an issue.
 Containers are not created for building in most cases: such usage is a bit of a hack.
Pack dependencies with container
10www.luxoft.com
Projects are so
different
11www.luxoft.com
 User desktop application
 Plugin/Shared library
 Web application
 Embedded application
 System service
 Kernel module
Project types
12www.luxoft.com
 Cross-compilation might be required
 Several cross-compilation targets might be required.
 Different compile options require different dependencies:
 Unit tests ON OFF
 Component tests ON OFF
 Some hardware/drivers usage ON/OFF
 Coverage, debug, linters, sanitizers, etc.
Compile options and targets
13www.luxoft.com
Canadian build
14www.luxoft.com
 Almost always cross-compilation is needed
 Output may be a firmware, not a binary.
 Yocto is widely used for such type of compilation.
 SDK layers should contain all required dependencies.
 You may need a team that takes care of SDK.
 Development environment may be delivered with docker or nix.
Embedded apps dependency management
15www.luxoft.com
 User should have an ability to compile it without major efforts.
 Build system should follow modern industry standards: cmake / make
 Users might want to use their own version of dependencies.
 Configure errors should be transparent.
Desktop/System apps dependency management
16www.luxoft.com
 You should provide Docker container with preinstalled environment for building applications.
 You should use modern industry standards: cmake / make
 You should use a modern cmake targets approach. It will be useful for embedding your app into another app.
 If user has already installed dependencies on the system with correct versions – use it.
 If dependencies are missed, use Fetch_content to download dependencies sources.
 Keep several backup URLs for dependencies fetching
 Keep forks of dependencies in case official repo is not available
 User should have an ability to redefine a search path for dependencies.
 Do not mix a dependency with application code. At least keep them in different folders or use submodules.
 Application cmakes.txt should not contain more than cmake find_package.
Mixed approach for most of cases of lib/system/desktop apps
17www.luxoft.com
Compile + runtime
dependencies
 Require preinstalled dependencies.
 Compile and deliver dependencies with the application.
 You may face DLL hell.
 You may deliver the application as flatpack/snap/brew/
 You may deliver the application via docker container.
18www.luxoft.com
 It is an industry standard
 So many ways to add projects:
 Submodule + add_subdirectory
 ExternalProject_Add
 find_package
 Use modern cmake. Follow https://gist.github.com/mbinna/c61dbb39bca0e4fb7d1f73b0d66a4fd1
 You can use FetchContent and ExternalProjectAdd, but only for small pet projects.
 Create .cmake file for each dependency and then include it.
 Try not to use custom variables - instead use standard CMAKE_PREFIX_PATH,CMAKE_INSTALL_PREFIX, etc …
 Leave the ability to use locally installed dependencies on the system.
Closer to code: cmake
19www.luxoft.com
 You are not using a dependency as a dependency – you are integrating it to your project. It may affect it with build flags, exported
variables, etc.
 Dependencies might have their own dependencies – it can lead to version mismatch
What’s wrong with add_subdirectory, FetchContent and ExternalProject add
20www.luxoft.com
 Problem that I can see there: Mixing dependency management and application compilation.
 Configure → Build → Compile→ Link
 Maybe something else before “Configure”?
Another level of abstraction can resolve any problem
21www.luxoft.com
Dependency management
is NOT a cmake
responsibility
22www.luxoft.com
So many ways to
solutions
 Conan
 Maven
 Meson
 apt/rpm/pacman/brew
 Nix
 Buckaroo
 Build2
 Docker
 Vcpkg
 Yocto
 CPM
 Venv
 NuGet
23www.luxoft.com
Conan
 Modern approach
 Runs before cmake
 Distributed (you can have our own bintray)
 Fetch dependencies binaries instead of sources
 Easily integrates with cmake in many different ways.
 Does not require major modifications of cmake. find_package is working.
 Sometimes some things are not working :-)
 Patching dependencies is possible but hard.
 Packages have various prebuild configurations
 Do not pollute the system
 Wonderful for desktop/library projects with popular dependencies like boost/opencv/poco/etc.
24www.luxoft.com
Nix package manager
 Not specific for C++ (contains enough software to make NixOS distro)
 The biggest package database
 Distributed, allows to contain own local caches
 Contains own functional language for package description
 Nix can even give you a compiler. nix-shell qtcreator gcc cmake boost and start development :-)
 Creating nixfile for the project allows to create a development environment that does not depend on the OS
(except Windows)
 Easily allows a full rebuild on local workstation
 nix-shell -p hello will open shell with hello program copied from cache
 nix-shell -p hello --option build-use-substitutes false will build hello program with dependencies locally
25www.luxoft.com
Nix package manager
 Not specific for C++ ( contains enough software to make NixOS distro)
 The biggest package database
 Distributed, allow to contain own local caches
 Contains own functional language for package description
 Nix can even give you a compiler. nix-shell qtcreator gcc cmake boost and start development :-)
 Creating nixfile for the project allows to create a development environment that doesn’t depend on the OS
(except Windows)
 Does not require integration with cmake. Emulates native package installation, but doesn’t pollute the system.
 Easily allows a full rebuild on local workstation
 nix-shell -p hello will open shell with hello program copied from cache
 nix-shell -p hello --option build-use-substitutes false will build hello program with dependencies locally
26www.luxoft.com
vcpkg
 Mostly same as previous ones
 Centralized
 Integrates to cmake via TOOL_CHAIN file
 Limited functionality (issue with building a shared lib)
 Maintained by Microsoft
27www.luxoft.com
vcpkg
 Mostly same as previous ones
 Centralized
 Integrates to cmake via TOOL_CHAIN file
 Limited functionality (issue with building a shared lib)
 Maintained by Microsoft
28www.luxoft.com
Build2
 Inspired by cargo from Rust
 Replaces cmake and make
 Mixes all abstraction levels (configure, build, deploy, testing, etc.), not unix way.
 Uses own Makefile like syntax for project description
 Modern and interesting view, maybe these guys have a clue.
29www.luxoft.com
Build2
 Inspired by cargo from Rust
 Replaces cmake and make
 Mixes all abstraction levels (configure, build, deploy, testing, etc.), not unix way.
 Uses own Makefile like syntax for project description
 Modern and interesting view, maybe these guys have a clue.
30www.luxoft.com
Final idea
 Use cmake, it is great.
 CMake should not do package management.
 Cmake should not depend on specific package management.
 You can have backup package management in cmake, but it is not
recommended.
 Docker is an easy way to establish build infrastructure, but it is not a
dependency manager, so it is not a production solution.
 There is a difference between internal and external dependencies.
 But even an internal dependency should be a separate project.
Thank You!

More Related Content

PPTX
Composer for Magento 1.x and Magento 2
PPTX
Do's and Do not's about p2
PPTX
Zend con 2016 bdd with behat for beginners
PDF
Analysis of-quality-of-pkgs-in-packagist-univ-20171024
PDF
Maven tutorial
PDF
Php Dependency Management with Composer ZendCon 2017
PPTX
Discovery the p2 API (updated to Indigo)
PPTX
Discovering the p2 API
Composer for Magento 1.x and Magento 2
Do's and Do not's about p2
Zend con 2016 bdd with behat for beginners
Analysis of-quality-of-pkgs-in-packagist-univ-20171024
Maven tutorial
Php Dependency Management with Composer ZendCon 2017
Discovery the p2 API (updated to Indigo)
Discovering the p2 API

What's hot (18)

PPTX
What is CocoaPods and how to setup?
PPTX
Javascript Essentials - Cisco Live Barcelona 2019
PDF
L’enjeu du mobile pour le développeur Web, et comment Mozilla va vous aider
PPTX
Phalcon - Giant Killer
PDF
Capistrano deploy Magento project in an efficient way
PDF
Getting started-with-zend-framework
PDF
Intro to development sites and site migration
ODP
Migrating to Git: Rethinking the Commit
PPT
Maven Overview
PDF
Drupal Continuous Integration (European Drupal Days 2015)
PDF
DockerCon EU 2018 - Dockerfile Best Practices
PPT
Getting Started With Jenkins And Drupal
PPTX
LVPHP.org
PDF
Continuous Integration and Deployment Patterns for Magento
PDF
Building a Drupal site with Git
PDF
Webex Devices xAPI - DEVNET_2071 - Cisco Live - San Diego 2019
PPTX
Drupal Continuous Integration with Jenkins - Deploy
What is CocoaPods and how to setup?
Javascript Essentials - Cisco Live Barcelona 2019
L’enjeu du mobile pour le développeur Web, et comment Mozilla va vous aider
Phalcon - Giant Killer
Capistrano deploy Magento project in an efficient way
Getting started-with-zend-framework
Intro to development sites and site migration
Migrating to Git: Rethinking the Commit
Maven Overview
Drupal Continuous Integration (European Drupal Days 2015)
DockerCon EU 2018 - Dockerfile Best Practices
Getting Started With Jenkins And Drupal
LVPHP.org
Continuous Integration and Deployment Patterns for Magento
Building a Drupal site with Git
Webex Devices xAPI - DEVNET_2071 - Cisco Live - San Diego 2019
Drupal Continuous Integration with Jenkins - Deploy
Ad

Similar to Aleksandr Kutsan "Managing Dependencies in C++" (20)

PDF
Containerizing legacy applications
PPTX
Laravel Crud Tutorial Basic Step by Stepy S
PDF
Modern Gentlemen's WordPress
PPTX
Tribal Nova Docker feedback
PDF
WordPress modern development
PDF
Lean Drupal Repositories with Composer and Drush
PDF
sveltekit-en.pdf
PDF
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
PDF
Digital Fabrication Studio v.0.2: Information
PDF
Introduction to Docker - Vellore Institute of Technology
PPTX
1 app 2 developers 3 servers
PDF
A Shift from Monolith to Microservice using Docker
PDF
CD in kubernetes using helm and ksonnet. Stas Kolenkin
PDF
Introduction to Docker - VIT Campus
PDF
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...
PPTX
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
PPTX
Composer
PDF
Composer & Drupal
PDF
Php Dependency Management with Composer ZendCon 2016
PPT
Setting up the hyperledger composer in ubuntu
Containerizing legacy applications
Laravel Crud Tutorial Basic Step by Stepy S
Modern Gentlemen's WordPress
Tribal Nova Docker feedback
WordPress modern development
Lean Drupal Repositories with Composer and Drush
sveltekit-en.pdf
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
Digital Fabrication Studio v.0.2: Information
Introduction to Docker - Vellore Institute of Technology
1 app 2 developers 3 servers
A Shift from Monolith to Microservice using Docker
CD in kubernetes using helm and ksonnet. Stas Kolenkin
Introduction to Docker - VIT Campus
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...
Chris OBrien - Pitfalls when developing with the SharePoint Framework (SPFx)
Composer
Composer & Drupal
Php Dependency Management with Composer ZendCon 2016
Setting up the hyperledger composer in ubuntu
Ad

More from LogeekNightUkraine (20)

PPTX
Face recognition with c++
PPTX
C++20 features
PPTX
Autonomous driving on your developer pc. technologies, approaches, future
PDF
Orkhan Gasimov "High Performance System Design"
PPTX
Vitalii Korzh "Managed Workflows or How to Master Data"
PDF
Yevhen Tatarynov "From POC to High-Performance .NET applications"
PDF
Oleksii Kuchuk "Reading gauge values with open cv imgproc"
PDF
Oleksandr Kutsan "Using katai struct to describe the process of working with ...
PDF
Pavlo Zhdanov "Mastering solid and base principles for software design"
PDF
Serhii Zemlianyi "Error Retries with Exponential Backoff Using RabbitMQ"
PDF
Iurii Antykhovych "Java and performance tools and toys"
PDF
Eugene Bova "Dapr (Distributed Application Runtime) in a Microservices Archit...
PDF
Yevhen Tatarynov "My .NET Application Allocates too Much Memory. What Can I Do?"
PDF
Alexandr Golyak, Nikolay Chertkov "Automotive Testing vs Test Automatio"
PPTX
Michal Kordas "Docker: Good, Bad or Both"
PPTX
Kolomiyets Dmytro "Dealing with Multiple Caches, When Developing Microservices"
PPTX
Shestakov Illia "The Sandbox Theory"
PPTX
Dmytro Kochergin “Autotest with CYPRESS”
PPTX
Ivan Dryzhyruk “Ducks Don’t Like Bugs”
PDF
Nhu Viet Nguyen "Why C++ is Becoming a Necessity for QA Automation"
Face recognition with c++
C++20 features
Autonomous driving on your developer pc. technologies, approaches, future
Orkhan Gasimov "High Performance System Design"
Vitalii Korzh "Managed Workflows or How to Master Data"
Yevhen Tatarynov "From POC to High-Performance .NET applications"
Oleksii Kuchuk "Reading gauge values with open cv imgproc"
Oleksandr Kutsan "Using katai struct to describe the process of working with ...
Pavlo Zhdanov "Mastering solid and base principles for software design"
Serhii Zemlianyi "Error Retries with Exponential Backoff Using RabbitMQ"
Iurii Antykhovych "Java and performance tools and toys"
Eugene Bova "Dapr (Distributed Application Runtime) in a Microservices Archit...
Yevhen Tatarynov "My .NET Application Allocates too Much Memory. What Can I Do?"
Alexandr Golyak, Nikolay Chertkov "Automotive Testing vs Test Automatio"
Michal Kordas "Docker: Good, Bad or Both"
Kolomiyets Dmytro "Dealing with Multiple Caches, When Developing Microservices"
Shestakov Illia "The Sandbox Theory"
Dmytro Kochergin “Autotest with CYPRESS”
Ivan Dryzhyruk “Ducks Don’t Like Bugs”
Nhu Viet Nguyen "Why C++ is Becoming a Necessity for QA Automation"

Recently uploaded (20)

PDF
Volvo ecr88 excavator specs Manual Download
PDF
Challenges in Sim 2 Real. Tutorial on Simulation Environments.
PPTX
TOEFL ITP Grammar_ Clausessssssssssssssssss.pptx
PDF
Volvo ecr88 problems Manual Download.pdf
PDF
120725175041.pdfhjjjjjjjjjjjjjjjjjjjjjjh
PDF
Honda Dealership SNS Evaluation pdf/ppts
PDF
Caterpillar Cat 315C Excavator (Prefix CJC) Service Repair Manual Instant Dow...
PDF
computer system to create, modify, analyse or optimize an engineering design.
PDF
Volvo EC300D L EC300DL excavator weight Manuals.pdf
PPTX
Robot_ppt_YRG[1] [Read-Only]bestppt.pptx
PDF
How Much does a Volvo EC290C NL EC290CNL Weight.pdf
PDF
How much does a e145 excavator weight.pdf
PDF
Journal Meraj.pdfuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
PDF
Volvo ecr58 problems Repair Manual Pdf Download
PPTX
capstoneoooooooooooooooooooooooooooooooooo
PPTX
Fire Fighting Unit IV industrial safety.pptx
PDF
What are dimensions of the Volvo ECR235cl.pdf
PDF
Renesas R-Car_Cockpit_overview210214-Gen4.pdf
PDF
Presentation.pdf ...............gjtn....tdubsr..........
PDF
Volvo EC290C NL EC290CNL excavator weight.pdf
Volvo ecr88 excavator specs Manual Download
Challenges in Sim 2 Real. Tutorial on Simulation Environments.
TOEFL ITP Grammar_ Clausessssssssssssssssss.pptx
Volvo ecr88 problems Manual Download.pdf
120725175041.pdfhjjjjjjjjjjjjjjjjjjjjjjh
Honda Dealership SNS Evaluation pdf/ppts
Caterpillar Cat 315C Excavator (Prefix CJC) Service Repair Manual Instant Dow...
computer system to create, modify, analyse or optimize an engineering design.
Volvo EC300D L EC300DL excavator weight Manuals.pdf
Robot_ppt_YRG[1] [Read-Only]bestppt.pptx
How Much does a Volvo EC290C NL EC290CNL Weight.pdf
How much does a e145 excavator weight.pdf
Journal Meraj.pdfuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
Volvo ecr58 problems Repair Manual Pdf Download
capstoneoooooooooooooooooooooooooooooooooo
Fire Fighting Unit IV industrial safety.pptx
What are dimensions of the Volvo ECR235cl.pdf
Renesas R-Car_Cockpit_overview210214-Gen4.pdf
Presentation.pdf ...............gjtn....tdubsr..........
Volvo EC290C NL EC290CNL excavator weight.pdf

Aleksandr Kutsan "Managing Dependencies in C++"

  • 1. Managing Dependenciesin C++ Kutsan Aleksandr 2020-11-26
  • 2. 2www.luxoft.com Problems in life  From time to time I can see gtest gmock sources in projects, weird.  Many times I totally don’t understand dependencies of the project when I start working with it.  Building project on another environment or cross- compilation becomes painful.  After some system changes project in not compliable or works in correctly.
  • 3. 3www.luxoft.com Presentation Manual Dependencies types Corporate Deck Compile time dependencies Need to be installed to developer workstation, CI/CD server. Required for building applications. Compile and runtime dependencies *-dev libraries and header need to be installed on developer workstation and CI/CD servers. Required for building applications. Library also required for application runtime. Usually a shared library. Only runtime dependencies Usually IPC services like Dbus, vsomeip, rabbitmq. In case if application is some kind of a framework/extension/plugin, runtime dependency can be the pluggable application.
  • 4. 4www.luxoft.com Compile time dependencies management approaches  Store dependencies sources within application sources  Fetch dependencies sources before compilation  Use pre-installed dependencies on the system  Fetch dependencies binaries before compilation
  • 5. 5www.luxoft.com Store dependencies sources near the application sources  You should take care about fetching security patches of the dependencies.  Dependencies may have their dependencies.  A lot of code to store.  Code of the dependency is now your code, and you should take care of it.  You can be sure that you have all assets for program compilation.  Don’t need internet to compile a program.  Compilation takes extremely long time.  Dependencies is part of the program, but developers would not like to recompile it even after a clean build. Need to create a separate compile target that will install dependencies.  Bad idea to install dependencies to the system during compilation.  Dependencies may have different compile/configure approaches, so it may be tricky to integrate it to your build system.
  • 6. 6www.luxoft.com Fetch dependencies sources during compilation  You need internet to build our system  Now you don’t have to apply security patches yourself.  Servers are sometimes down.  In 5/10/20 years appropriate sources may not be accessible via specified links.  Compilation is still too long.  You still need to find out how to install dependencies but not pollute the system with it.  Build approach still may be different.  If you use git for fetching sources, you should never use master branch - use specific tag instead.
  • 7. 7www.luxoft.com Fetch dependencies binaries during compilation  You need internet to build our system.  Now you don’t have to apply security patches yourself.  Servers are sometimes down.  In 5/10/20 years appropriate sources may be not accessible by specified links.  You still need to find out how to install dependencies but not pollute the system with it.
  • 8. 8www.luxoft.com  Project is clear and contains only meaningful sources. That is nice.  You require a developer to modify the system for application compilation.  Dependencies on the system may have a different version.  Dependencies on the system may be stored by unexpected paths: /opt, /home, etc.  Dependencies may be patched or even “infected”. Do you really trust the user environment? Use preinstalled compile time dependencies
  • 9. 9www.luxoft.com  Project is clear and contains only meaningful sources. That is nice.  Developer may build a container or fetch container binaries.  Developer may recreate an environment on a local workstation and build as needed.  Can be tricky to integrate with IDE.  Build container can be extremely heavy, but I don’t feel like it’s an issue.  Containers are not created for building in most cases: such usage is a bit of a hack. Pack dependencies with container
  • 11. 11www.luxoft.com  User desktop application  Plugin/Shared library  Web application  Embedded application  System service  Kernel module Project types
  • 12. 12www.luxoft.com  Cross-compilation might be required  Several cross-compilation targets might be required.  Different compile options require different dependencies:  Unit tests ON OFF  Component tests ON OFF  Some hardware/drivers usage ON/OFF  Coverage, debug, linters, sanitizers, etc. Compile options and targets
  • 14. 14www.luxoft.com  Almost always cross-compilation is needed  Output may be a firmware, not a binary.  Yocto is widely used for such type of compilation.  SDK layers should contain all required dependencies.  You may need a team that takes care of SDK.  Development environment may be delivered with docker or nix. Embedded apps dependency management
  • 15. 15www.luxoft.com  User should have an ability to compile it without major efforts.  Build system should follow modern industry standards: cmake / make  Users might want to use their own version of dependencies.  Configure errors should be transparent. Desktop/System apps dependency management
  • 16. 16www.luxoft.com  You should provide Docker container with preinstalled environment for building applications.  You should use modern industry standards: cmake / make  You should use a modern cmake targets approach. It will be useful for embedding your app into another app.  If user has already installed dependencies on the system with correct versions – use it.  If dependencies are missed, use Fetch_content to download dependencies sources.  Keep several backup URLs for dependencies fetching  Keep forks of dependencies in case official repo is not available  User should have an ability to redefine a search path for dependencies.  Do not mix a dependency with application code. At least keep them in different folders or use submodules.  Application cmakes.txt should not contain more than cmake find_package. Mixed approach for most of cases of lib/system/desktop apps
  • 17. 17www.luxoft.com Compile + runtime dependencies  Require preinstalled dependencies.  Compile and deliver dependencies with the application.  You may face DLL hell.  You may deliver the application as flatpack/snap/brew/  You may deliver the application via docker container.
  • 18. 18www.luxoft.com  It is an industry standard  So many ways to add projects:  Submodule + add_subdirectory  ExternalProject_Add  find_package  Use modern cmake. Follow https://gist.github.com/mbinna/c61dbb39bca0e4fb7d1f73b0d66a4fd1  You can use FetchContent and ExternalProjectAdd, but only for small pet projects.  Create .cmake file for each dependency and then include it.  Try not to use custom variables - instead use standard CMAKE_PREFIX_PATH,CMAKE_INSTALL_PREFIX, etc …  Leave the ability to use locally installed dependencies on the system. Closer to code: cmake
  • 19. 19www.luxoft.com  You are not using a dependency as a dependency – you are integrating it to your project. It may affect it with build flags, exported variables, etc.  Dependencies might have their own dependencies – it can lead to version mismatch What’s wrong with add_subdirectory, FetchContent and ExternalProject add
  • 20. 20www.luxoft.com  Problem that I can see there: Mixing dependency management and application compilation.  Configure → Build → Compile→ Link  Maybe something else before “Configure”? Another level of abstraction can resolve any problem
  • 22. 22www.luxoft.com So many ways to solutions  Conan  Maven  Meson  apt/rpm/pacman/brew  Nix  Buckaroo  Build2  Docker  Vcpkg  Yocto  CPM  Venv  NuGet
  • 23. 23www.luxoft.com Conan  Modern approach  Runs before cmake  Distributed (you can have our own bintray)  Fetch dependencies binaries instead of sources  Easily integrates with cmake in many different ways.  Does not require major modifications of cmake. find_package is working.  Sometimes some things are not working :-)  Patching dependencies is possible but hard.  Packages have various prebuild configurations  Do not pollute the system  Wonderful for desktop/library projects with popular dependencies like boost/opencv/poco/etc.
  • 24. 24www.luxoft.com Nix package manager  Not specific for C++ (contains enough software to make NixOS distro)  The biggest package database  Distributed, allows to contain own local caches  Contains own functional language for package description  Nix can even give you a compiler. nix-shell qtcreator gcc cmake boost and start development :-)  Creating nixfile for the project allows to create a development environment that does not depend on the OS (except Windows)  Easily allows a full rebuild on local workstation  nix-shell -p hello will open shell with hello program copied from cache  nix-shell -p hello --option build-use-substitutes false will build hello program with dependencies locally
  • 25. 25www.luxoft.com Nix package manager  Not specific for C++ ( contains enough software to make NixOS distro)  The biggest package database  Distributed, allow to contain own local caches  Contains own functional language for package description  Nix can even give you a compiler. nix-shell qtcreator gcc cmake boost and start development :-)  Creating nixfile for the project allows to create a development environment that doesn’t depend on the OS (except Windows)  Does not require integration with cmake. Emulates native package installation, but doesn’t pollute the system.  Easily allows a full rebuild on local workstation  nix-shell -p hello will open shell with hello program copied from cache  nix-shell -p hello --option build-use-substitutes false will build hello program with dependencies locally
  • 26. 26www.luxoft.com vcpkg  Mostly same as previous ones  Centralized  Integrates to cmake via TOOL_CHAIN file  Limited functionality (issue with building a shared lib)  Maintained by Microsoft
  • 27. 27www.luxoft.com vcpkg  Mostly same as previous ones  Centralized  Integrates to cmake via TOOL_CHAIN file  Limited functionality (issue with building a shared lib)  Maintained by Microsoft
  • 28. 28www.luxoft.com Build2  Inspired by cargo from Rust  Replaces cmake and make  Mixes all abstraction levels (configure, build, deploy, testing, etc.), not unix way.  Uses own Makefile like syntax for project description  Modern and interesting view, maybe these guys have a clue.
  • 29. 29www.luxoft.com Build2  Inspired by cargo from Rust  Replaces cmake and make  Mixes all abstraction levels (configure, build, deploy, testing, etc.), not unix way.  Uses own Makefile like syntax for project description  Modern and interesting view, maybe these guys have a clue.
  • 30. 30www.luxoft.com Final idea  Use cmake, it is great.  CMake should not do package management.  Cmake should not depend on specific package management.  You can have backup package management in cmake, but it is not recommended.  Docker is an easy way to establish build infrastructure, but it is not a dependency manager, so it is not a production solution.  There is a difference between internal and external dependencies.  But even an internal dependency should be a separate project.