Skip to content
0:00 / 0:00

#cmake#cppcon#fetchcontent

Deep CMake for Library Authors - Craig Scott - CppCon 2019

CppCon

189K subscribers • 101 videos on Hallway • Conference channel

YouTube
  • Recommended by 1 person: 1 on Stack Overflow and its sister sites.
  • Presented by Craig Scott, author of Professional CMake
  • Linked in the descriptionCppCon/CppCon2019

Advanced. Deep dive for people who know the field.

39K views7 years ago1 recommendation

Systems programmingTools and practiceBuild systems and packagingC++

Craig Scott presents a roadmap for C++ library authors to handle symbol visibility, versioning, and cross-platform deployment using CMake.

CppCon.org — Discussion & Comments: reddit.com/r/cpp/ — Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2019 — This talk presents a road map for C++ library authors grappling with cross-platform aspects of library development and deployment. It highlights key CMake features that every cross-platform library project should be using and digs deeper into the platform-specific quirks and conventions behind them. The material presented will give library authors more robust control over their API, smoother integration with major platforms and packaging systems, and more convenient inclusion by other projects. The presentation will firstly examine how symbol visibility, library versioning and API evolution can be handled coherently across all major platforms and compilers. CMake provides dedicated features for these that are easy to use, but with the deeper understanding provided by this talk, library authors will be able to make these areas work together more seamlessly and avoid future maintenance and compatibility issues. We will then explore how platform and vendor differences affect the installed directory layout for projects with libraries. CMake features for transparently handling the different conventions and policies will be presented, including recent CMake improvements which simplify this task. The importance of RPATH/RUNPATH functionality for improved runtime robustness and ease of use will also be explained, along with some associated support CMake provides. Along the way, the talk will mention a number of specific things that CMake library projects should do or avoid to make themselves easy for other projects to consume. This will include versioning support for CMake config package files, guidance on defining install components and accounting for the different ways that projects may incorporate yours into their build. — Craig Scott Crascit Pty Ltd Founder Craig is a CMake co-maintainer and author of the book “Professional CMake: A Practical Guide”. He has been developing cross-platform C++ software since 2001, targeting most major platforms and working on large scale frameworks, scientific algorithm development, Qt GUI applications, backend services and embedded devices. He is the company founder of Crascit Pty Ltd, through which he offers consulting services related to CMake, C++ and build/release processes. — Videos Filmed & Edited by Bash Films: BashFilms.com Work at Hudson River Trading (HRT): tinyurl.com/safxfctf

Why it's here

1 person recommends this

What people say. Recommended for its advice on avoiding target name clashes when using CMake FetchContent.

Moments people linked to

Alex Reinkingon Stack Overflow • Recommends

On “How can I avoid clashes with targets "imported" with FetchContent_MakeAvailable?”

…he names of the targets in other black-box projects, whether included via find_package , add_subdirectory , or FetchContent . Thus, for now, it is incumbent on you to avoid name-clashes in targets, install components, test names, and anywhere else this could be a problem. Craig Scott says as much in his (very good) talk at CppCon 2019, see here: link to this video The convention he proposes is to use names that are prefixed with SomeProj_ . He doesn't suggest to literally use ${PROJECT_NAME}_ , and I wouldn't either, because doing so makes the code harder to read and grep (which is extremely useful for understanding a 3rd-party build). To be a good add_subdirectory or FetchContent citizen, howeve…
6View the answer

u/d1722825in r/C_Programming • Mentions

On “I made a simple program arguments generating library in C, looking for feedback”

I am not a fan of the insane amount of macros... The variables you use inside the macros should be very unique name of you insert user code into the macro, too. Eg. the user could easily have a variable named `sub` and if he would try to use it in `pug_switch_on_subcommand_s` he would be surprised. The `1 << flag` could be an issue, too. A program could have more than 32 / 64 flags, or someone could specify the values for the flag enums (eg. `enum difficulty { easy = 50, hard = 100 };`). In both cases the result would be an UB (and a very confused programmer). (If you have `pug_to_flag` anyways why don't use it in `pug_switch_on_flag_s`?) Please do not do `typedef int i32;`, there is the…

u/d1722825in r/C_Programming • Mentions

On “Cmake alternative?”

CMake should be easy to use. Make sure you use a recent enough version, minimum something like 3.19, if you see any tutorial or example with lower version, just ignore it. Check out the More Modern CMake" talk: [video An the CMake for library authors, if you are making your own library: [video