Better CMake Part 6 -- Superbuilds w/ ExternalProject

  Рет қаралды 8,242

Jefferson Amstutz

Jefferson Amstutz

Күн бұрын

Topic time stamps:
0:00 - Intro
1:02 - ExternalProject docs
4:13 - Single project example
9:47 - Observing each step
11:05 - Default build directory layout
12:24 - Watch out for locally used dependencies!
13:08 - Superbuilds for development?
15:09 - Multi-project example
17:05 - Pointing projects to the right place
18:27 - Why no MD5 sums here?
19:33 - Summary
21:03 - Wrap up
--------------------
GitHub: github.com/jeffamstutz
Twitter: / jeffamstutz
Blog: jeffamstutz.io/

Пікірлер: 17
@kebabimpaler
@kebabimpaler Жыл бұрын
I have used external project for many many years. I had no idea that it was capable of doing the half of what you just outlined thank you lol.
@silverqx
@silverqx 11 ай бұрын
I'm at 2:58 in your video and I can tell already that it's a super helpful video thx 👌
@alexiswinters9364
@alexiswinters9364 3 жыл бұрын
I'd really like to see a video about how to generate a CMakeConfig file so that I can use a project in downstream CMake packages.
@jeffersonamstutz
@jeffersonamstutz 3 жыл бұрын
Sounds good! I think I’ll do that as my next topic!
@Kaszanas
@Kaszanas 3 жыл бұрын
Hello! This is great information. Thank You. There is not much info online that is easily accessible on how to handle dependencies like that. I would like to be able to include different dependencies and handle them automatically like shown in this example. Is the CMake code published anywhere? I do not necessarily understand later on how one is supposed to include the built dependencies into the current project.
@krofikS4
@krofikS4 3 жыл бұрын
Thanks for great content! Please keep going. It would interest me, how can I setup CMake such as when I 'make' VS Solution, these follow same structure as if I created them by hand. And by that I mean: setting build directories (for release and debug), showing actual folder structure inside project explorer. Is there any such way to specify layout for VS Solution?
@jeffersonamstutz
@jeffersonamstutz 3 жыл бұрын
Unfortunately I’m not well versed in vanilla VS - I only have built VS projects generated by CMake as I primarily develop code on Linux.
@literaltechbros5833
@literaltechbros5833 2 жыл бұрын
Really great stuff! My only question is, how do you refer to dependencies when you're writing one of the subprojects? For example, if I added build subproject(NAME mySubproject...DEPENDS ON rkcommon) would I automatically be able to include header files from the rkcommon project in my mySubproject project? Or would there be more to it?
@jeffersonamstutz
@jeffersonamstutz 2 жыл бұрын
Each project should use find_package() to go find dependent projects. The superbuild dependency tracking is about making sure each project is built in the correct order -- it doesn't actually affect the underlying project's CMake itself. In this case, all projects which use rkcommon each do their own find_package(rkcommon) and then link exported rkcommon targets, which is where things like include paths and library files get incorporated.
@arkadymagomedov1700
@arkadymagomedov1700 2 жыл бұрын
The "*_ROOT" variables you set manually are required for the find_package, right? I am trying to figure out how to compile a complex library (the one that has external dependencies that have other external dependencies, etc...) to web assembly using emscripten tools. Most libraries rely on find_package. But for emscripten to work all libraries must be compiled with emscripten (duh...).
@jeffersonamstutz
@jeffersonamstutz 2 жыл бұрын
Yes, in the multi-project example you see TBB_ROOT specified as a CMake argument to each project to find the TBB that was extracted locally. As for emscripten, I haven't used that toolchain before so I'm not familiar enough with it to know how one should approach dependencies. I would hope that there's a way to find_package() libraries built with emscripten (?), but I'm not sure how much native CMake can handle that beyond header-only interface libraries. Sounds like an important problem to solve! One thing I've been experimenting with lately are "source libraries" (not sure if there's an official name for it). The idea is that you can use target_sources(${TARGET} INTERFACE sourceA.cpp sourceB.cpp ...) on an CMake interface library target, which will then propagate the cpp files themselves downstream to targets which link it. This is problematic if you don't control all the dependencies, but is definitely an option if you are able. If anything, you could create a superbuild of external projects with your own custom CMakeLists.txt for each project that creates a "source library" of each one manually. However, because there isn't really a build step for these types of "source only" libraries, you could just do it with FetchContent instead all in the furthest downstream consuming project's CMake build.
@arkadymagomedov1700
@arkadymagomedov1700 2 жыл бұрын
@@jeffersonamstutz I do not think it is feasible with FetchContent as it does not set the *_ROOT variable. So if you need a library A which depends on library B, you need to first download and compile library B. Library A uses find_package(B) which would try to look in system folders, which is not desired. FetchContent does not set *_ROOT variables. This guy invented a wheel kzfaq.info/get/bejne/g8yldbZq05vDkY0.html&lc=UgwlVI4oxNHL8Os3fft4AaABAg.9RcmsnQR_6E9RcqDPaKY30 And there is this proposal as well: gitlab.kitware.com/cmake/cmake/-/issues/21687
@illiadubrovin8995
@illiadubrovin8995 9 ай бұрын
superbuild should be first think you hear and learn about cmake.........
@danielt5542
@danielt5542 Жыл бұрын
Hi @jeffersonamstutz, how can I link a library built from ExternalProject_Add into an executable? the target name given by ExternalProject_Add is of type UTILITY and cannot be linked directly using target_link_libraries(app libA)
@jeffersonamstutz
@jeffersonamstutz Жыл бұрын
To get external dependencies into your build you will need find_package(), but ExternalProject runs at build time which is after when CMake would search for it during configuration. The best thing to do is to write your project that builds only itself and maintain a separate CMake superbuild that can string together ExternalProject invocations. You certainly could mix these in the same directory structure by only invoking your executable’s CMake from a parent folder containing the superbuild. You would do this by having the ExternalProject invocation bypass the download step and point directly to your local source directory. Be careful though - it is bad practice to always assume overly rigid dependency handling by requiring that you can only use the deps built locally.
Better CMake Part 7 -- Package Configs for Header Only Libraries
15:32
Jefferson Amstutz
Рет қаралды 6 М.
Simplified CMake Tutorial
27:47
kandodev
Рет қаралды 113 М.
DEFINITELY NOT HAPPENING ON MY WATCH! 😒
00:12
Laro Benz
Рет қаралды 49 МЛН
I CAN’T BELIEVE I LOST 😱
00:46
Topper Guild
Рет қаралды 117 МЛН
Nix - Packaging lib60870 with CMake.
27:02
Jon Ringer
Рет қаралды 1,6 М.
Better CMake Part 10 -- When to use FetchContent
16:14
Jefferson Amstutz
Рет қаралды 4,6 М.
Better CMake Part 3 -- The Basics of Targets
16:23
Jefferson Amstutz
Рет қаралды 19 М.
Why CMake?
13:03
sudocpp
Рет қаралды 25 М.
Rust and RAII Memory Management - Computerphile
24:22
Computerphile
Рет қаралды 220 М.
Vim Tips I Wish I Knew Earlier
23:00
Sebastian Daschner
Рет қаралды 43 М.
Deep CMake for Library Authors - Craig Scott - CppCon 2019
1:01:35