Compiling Multi-file C++ Source Code with CMake

preview_player
Показать описание
There are plenty of C++ tutorials around, but most don't cover the essential step of how to compile multiple source files into one program. This video show how, using CMake...

Click here for a summary (and to download the example/template):

Want to learn more CMake? Click the following link:

#programming #tech #softwaredevelopment #cmake #cpp #cpptutorial #cmaketutorial
Рекомендации по теме
Комментарии
Автор

FINALLY! Somebody who described how to include multiple source files!

freznelite
Автор

You have single handedly saved me hours of troubleshooting. Thank you! No Instructor in any of my CS classes or any resources online have talked about how to compile multi-file code and my project kept having so many errors upon building.

Sokenro
Автор

Yeah, after I understood how to work with CMake, all my C++ Projects are CMake Projects.

PS:
3:18 actually you didn't really generate a Makefile. You're on Windows and used MSVC in its default form[it used -G "Visual Studio 16 2019"] -> you actually created a VS Solution.

But I got you haha
I sometimes use Linux, and before moving to using Ninja as my generator, I also had CMake generate Makefiles for me.

Good video. Keep it up.

theintjengineer
Автор

Hii, thank you so much for the video!
I followed your video, and had one doubt...
'add_executable() ' should be kept as it is in the video or should it include the project and source file name that i kept?

divyahegde
Автор

Your videos covering cmake are awesome. Any plans to explain autotools with this kinda detail@ explanations?

alessandro_yt
Автор

How can I select the compiler? 6:21 It does not appers to me.

vinniciusrosa
Автор

Hi, thank you for this tutorial.
I have a question regarding the first part of the video; I've already created the build folder using the " command palette ", and also I use " visual studio " as my compiler, do I need to delete the build folder and do as you did or is there a way to make my compiler compile my files without having to recreate the build folder?
perhaps via the terminal

punchline
Автор

I personally don't get why people like to set a variable for source files. I'd just list them in the add_executable or add_library call directly, or better, use target_sources. That way you can enable modern C++ features like modules fairly easily and use generator expressions for any platform specific files. If the build becomes complicated enough to justify the variable and it cant be simplified, ok, introduce some variables, but I don't think they add any value as a default.

oracleoftroy
Автор

When the filecount gets high, is GLOB the right way to go?

bittondb
Автор

isn't it sad that you actually have to write just another source code just to tell the compiler how it should work?

plattcriceta
welcome to shbcf.ru