This is the first legitimately good tutorial series on CMake I've found. Even still, it makes me question why C++ devs have put up with an annoyingly complex build system for so many years.
Thanks for this clear tuto, much clearer than the existing examples adressed in the thousands stackoverflow forums. Little suggestion: should be easier for viewers to not give twice "say-hello" label to your directories, because it is hard to see with which CMakeLists you are working.
What's the difference between writing `"${CMAKE_CURRENT_SOURCE_DIR}/src"` and just writing `src` or `./src/`? All of these seem to work when I try them. Is there some subtle corner case that the first one avoids?
5:57 at the right of your screen, you have your 2 folders and your targets inside but on my side i have tens of "continuous" and "nightly" targets that display. Do you know how i can have the same rendering as you ?
Thanks for the awesome video! I got one question though. What was the purpose behind naming the subdirectory „say-hello“, then putting „src/say-hello“ in there, naming the latter the same as the first? My first approach would be „Libraries/src/some_library“. Is there a benefit from building a subdirectory for every single library in the main project folder and then going „/src/that_exact_same_library“ inside every of these subdirectories? Thanks in advance! Edit: Than != Then
5:40 if you didn't have the subdirectory, you'd include the header directly. No problem if you only have one library, but if you have multiple libraries all having a header named util.h, I wouldn't know how to include it other than changing the target_include_directory(). I guess it's just for clients to have sort of a namespace of includes.
very clear tutorial. How to use target_link_libraries to create a new target (.so file) that depends on libraries added from other CMaklists.txt files? i understand that bellow 3.13 this is not possible, but is there a workaround that?
Hey vector-of-bool.. I followed through your tutorial and have double checked that I followed the exact steps you did but still seem to not be able to link the library I am not using ninja for builds just the unix make with gcc and g++. If you have any advice on what it could be please let me know. Thank you for the videos! they have been a big help and getting me started with CMake
Same here. I can't link the library, I keep getting: fatal error: say-hello/hello.hpp: No such file or directory when compiling the main program. Maybe Ninja is needed for this?
Thank you very much for this tutorial which makes it easy to learn. Can you please increase the font or please provide access to the all example projects to refer it again :)
Thank you. These videos are pretty darn helpful. If you have time, can you address external dependencies (for example, a miniature version of wget needing curl+OpenSSL, cross platform)?
Thanks for the tutorial. One question. If a have a condition to add a subdirectory how to set the flags while building from vs code? e.g. if(TEST_ENABLED) add_subdirectory(test-folder) endif()
Hi there, do we need any special extension in VSC to make SAY_HELLO_VERSION being recognized in both places? I followed the tutorial (with MacOS) but I saw the red squiggly line underneath (as well as under say-hello/hello.hpp). The file can be compiled and ran but just no IntelliSense there... Anybody got any ideas on why that might be the case?
I've got this problem too, would love if someone can figure this out. For me, only the SAY_HELLO_VERSION part is doing that, and nothing else. CMake Configure doesn't fix it either.
So PRIVATE means only accessed by the target, INTERFACE means only accessed by other that depends on the target, while PUBLIC means the target and all other stuff that depends on the target can access it...?
I don't think it is anymore a requirement that the add_subdirectory of the library needs to come first, order no longer matters (probably are more modern version of cmake needed).
quesiton in include path for this library for example: if i add target_include_directories(say-hello PUBLIC ${CMAKE_CURRENT_SRC_DIR}/src/say-hello) in this form then in the main.cpp #inlcude "hello.hpp" Should be enough right?
So I'm using the CMake Tools extension on VSCode, on Windows, but my IntelliSense isn't as responsive as his. For example, if I create the preprocessor definition on the CMakeLists, and I use SAY_HELLO_VERSION on my .cpp-s, Intellisense says it doesn't exists... but if I click on the Build button for the extension to build this, everything works, and _then_ Intellisense actually knows about SAY_HELLO_VERSION, and correctly displays its tooltip. Anyone else having this problem and know how to fix it? Thanks.
Hi, I was following along with your tutorial, but I came across an issue, and it is that my main.cpp cannot find the includes files that you are pointing to. Would you mind to help me out on how to structure it in a way it can actually work...
Both will work in C++, but the ".h" file extension is from C. C++ recognizes it for legacy reasons, I believe. In C++, the extension for header files should be ".hpp"
OMG, THE vector-of-bool!? I rely on your CMake extension everyday for work and hobby projects! Thank you for the hard work mate!
This is the first legitimately good tutorial series on CMake I've found. Even still, it makes me question why C++ devs have put up with an annoyingly complex build system for so many years.
because they like pain
@@andriusdaraskevicius by they you mean also you... right? and yes, me.
@@ivan0kurnia Well that's why I'm here 😏
@@andriusdaraskevicius Yeah, that's a common trait among us.
Thank you, this is very helpful. This is the kind of practical knowledge that university doesn't teach.
Thanks for this clear tuto, much clearer than the existing examples adressed in the thousands stackoverflow forums.
Little suggestion: should be easier for viewers to not give twice "say-hello" label to your directories, because it is hard to see with which CMakeLists you are working.
I love the Alan Tutorial reference.
This is gold!! Thanks a whole lot and hope you'll make more tutorials in the future. Oh and your extension rocks!!!!
What's the difference between writing `"${CMAKE_CURRENT_SOURCE_DIR}/src"` and just writing `src` or `./src/`? All of these seem to work when I try them. Is there some subtle corner case that the first one avoids?
5:57 at the right of your screen, you have your 2 folders and your targets inside but on my side i have tens of "continuous" and "nightly" targets that display. Do you know how i can have the same rendering as you ?
Brilliant! Finally solved my issue of using libraries with VSCode and Cmake.
Thanks alot! Understanding of PUBLIC/PRIVATE/INTERFACE was most useful for me!
Best CMake video I've ever seen, thanks!
THE vector-of-bool, how do you bulid all projects so quick at 00:07:55. Do you use some shortcuts? Also, could you share this project? Thanks.
Thanks for the awesome video!
I got one question though. What was the purpose behind naming the subdirectory „say-hello“, then putting „src/say-hello“ in there, naming the latter the same as the first? My first approach would be „Libraries/src/some_library“. Is there a benefit from building a subdirectory for every single library in the main project folder and then going „/src/that_exact_same_library“ inside every of these subdirectories?
Thanks in advance!
Edit: Than != Then
5:40 if you didn't have the subdirectory, you'd include the header directly. No problem if you only have one library, but if you have multiple libraries all having a header named util.h, I wouldn't know how to include it other than changing the target_include_directory(). I guess it's just for clients to have sort of a namespace of includes.
@@observant6953 Damn that totally makes sense, thanks a lot!
Very nice tutorial. It would be nice to decrease the resolution of your desktop or increase the font size because its hard to see.
Thanks! Duly noted.
It's better explained than official documentation or any answer of stackoverflow lol. I literally fight for about 2 hours with this.
This helped me so much i can finally make some subdirectories THANK GOD
Thank you for the video. Your efforts help me to do my graduation project.
You are so cool.
I pronounce src as "serse" too! One of us, one of us!
very clear tutorial. How to use target_link_libraries to create a new target (.so file) that depends on libraries added from other CMaklists.txt files?
i understand that bellow 3.13 this is not possible, but is there a workaround that?
Hey vector-of-bool.. I followed through your tutorial and have double checked that I followed the exact steps you did but still seem to not be able to link the library I am not using ninja for builds just the unix make with gcc and g++. If you have any advice on what it could be please let me know. Thank you for the videos! they have been a big help and getting me started with CMake
Same here. I can't link the library, I keep getting: fatal error: say-hello/hello.hpp: No such file or directory when compiling the main program. Maybe Ninja is needed for this?
No, ninja was not needed after all. I had written target_link_directories instead of target_include_directories. It works great now!
@@ZirJo OMG, IT IS THE SAME. Thank you so much
This is so helpful. Thanks for saving me a lot of time.
Thank you very much for this tutorial which makes it easy to learn. Can you please increase the font or please provide access to the all example projects to refer it again :)
Absolutely amazing videos, thanks so much. A slight suggestion: maybe make the text a little larger, it can be a bit harder to see sometimes
Thank you. These videos are pretty darn helpful. If you have time, can you address external dependencies (for example, a miniature version of wget needing curl+OpenSSL, cross platform)?
I'm glad these videos are helping you. I will definitely be covering external dependencies in the future! Stay tuned...
Thanks for the tutorial.
One question. If a have a condition to add a subdirectory how to set the flags while building from vs code?
e.g.
if(TEST_ENABLED)
add_subdirectory(test-folder)
endif()
Hi there, do we need any special extension in VSC to make SAY_HELLO_VERSION being recognized in both places? I followed the tutorial (with MacOS) but I saw the red squiggly line underneath (as well as under say-hello/hello.hpp). The file can be compiled and ran but just no IntelliSense there... Anybody got any ideas on why that might be the case?
I've got this problem too, would love if someone can figure this out.
For me, only the SAY_HELLO_VERSION part is doing that, and nothing else. CMake Configure doesn't fix it either.
I wish I can like the video twice man ! thank you :D
So PRIVATE means only accessed by the target, INTERFACE means only accessed by other that depends on the target, while PUBLIC means the target and all other stuff that depends on the target can access it...?
Hey helpful video, could you tell me the settings you are using in visual studio code
I don't think it is anymore a requirement that the add_subdirectory of the library needs to come first, order no longer matters (probably are more modern version of cmake needed).
I don't understand why we need to create: "say-hello/src/say-hello" to contain files *hpp and *cpp?
Do I need to copy commands such as set(CMAKE_CXX_STANDARD 17) to each individual CMakeLists.txt file or only at the top level?
this was insanely helpful. Thank you!!
Thank you. This series is excellent :)
quesiton in include path for this library
for example: if i add
target_include_directories(say-hello PUBLIC ${CMAKE_CURRENT_SRC_DIR}/src/say-hello) in this form
then in the main.cpp #inlcude "hello.hpp" Should be enough right?
Intellisense doesn't actually recognize SAY_HELLO_VERSION, but it runs fine and works. What could be the problem?
Same here, this is really annoying
Incredible work! Thks!
How can I use ninja in VSCODE?
thanks for a wonderful lecture
These videos are very helpful. Please can you make your source code available?
So I'm using the CMake Tools extension on VSCode, on Windows, but my IntelliSense isn't as responsive as his. For example, if I create the preprocessor definition on the CMakeLists, and I use SAY_HELLO_VERSION on my .cpp-s, Intellisense says it doesn't exists... but if I click on the Build button for the extension to build this, everything works, and _then_ Intellisense actually knows about SAY_HELLO_VERSION, and correctly displays its tooltip.
Anyone else having this problem and know how to fix it? Thanks.
hello! have you found the solution?
Thanks for another good video. However, I would love a link to the project, so you don't have to go back and forth so many times
Great work :) super helpful
Pretty good, Clion freak out with subproject though, sad
Thank you very much for this tutorial. It help me a lot! =D
Hi, I was following along with your tutorial, but I came across an issue, and it is that my main.cpp cannot find the includes files that you are pointing to. Would you mind to help me out on how to structure it in a way it can actually work...
goodjob bro, thanks so much
Very helpful thank you
Thanks a lot. How to use the CMAKE plugin in VS CODE by the way?
install cmake extension, go to command pallete and write Cmake: quick start, write what you need in the generated CMakelists.txt file. Done
awesome
Thanks Man!
shit just got real
why .hpp and not .h?
Both will work in C++, but the ".h" file extension is from C. C++ recognizes it for legacy reasons, I believe. In C++, the extension for header files should be ".hpp"
Tutorial content is great! But the tutorial could be explained a bit better... afternoon brain needed to watch a few times
target_include_directories(say-hello PUBLIC $)