How to CMake Good - 1c - Subdirectories and Target Interface Properties

Поділитися
Вставка
  • Опубліковано 18 гру 2024

КОМЕНТАРІ • 80

  • @scotthutchinson9769
    @scotthutchinson9769 6 років тому +46

    OMG, THE vector-of-bool!? I rely on your CMake extension everyday for work and hobby projects! Thank you for the hard work mate!

  • @LimitedWard
    @LimitedWard 4 роки тому +12

    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.

    • @andriusdaraskevicius
      @andriusdaraskevicius 4 роки тому +8

      because they like pain

    • @ivan0kurnia
      @ivan0kurnia 3 роки тому

      @@andriusdaraskevicius by they you mean also you... right? and yes, me.

    • @andriusdaraskevicius
      @andriusdaraskevicius 3 роки тому +1

      @@ivan0kurnia Well that's why I'm here 😏

    • @fededevi1985
      @fededevi1985 2 роки тому

      @@andriusdaraskevicius Yeah, that's a common trait among us.

  • @kalebbruwer
    @kalebbruwer 4 роки тому +4

    Thank you, this is very helpful. This is the kind of practical knowledge that university doesn't teach.

  • @marcmoreno7111
    @marcmoreno7111 Рік тому

    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.

  • @kenziemac130
    @kenziemac130 5 років тому +4

    I love the Alan Tutorial reference.

  • @nazarottto
    @nazarottto 4 роки тому +3

    This is gold!! Thanks a whole lot and hope you'll make more tutorials in the future. Oh and your extension rocks!!!!

  • @oconnor663
    @oconnor663 4 роки тому +3

    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?

  • @AL-kb3cb
    @AL-kb3cb 2 роки тому

    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 ?

  • @jacobyoung6876
    @jacobyoung6876 2 роки тому

    Brilliant! Finally solved my issue of using libraries with VSCode and Cmake.

  • @petrkassadinovich2705
    @petrkassadinovich2705 4 роки тому

    Thanks alot! Understanding of PUBLIC/PRIVATE/INTERFACE was most useful for me!

  • @Gloryisfood
    @Gloryisfood 3 роки тому

    Best CMake video I've ever seen, thanks!

  • @raymondcui3932
    @raymondcui3932 4 роки тому

    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.

  • @gerkirschbaum
    @gerkirschbaum 4 роки тому +2

    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

    • @observant6953
      @observant6953 2 роки тому +1

      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.

    • @gerkirschbaum
      @gerkirschbaum 2 роки тому

      @@observant6953 Damn that totally makes sense, thanks a lot!

  • @EEEEMMMMKKKK
    @EEEEMMMMKKKK 6 років тому +5

    Very nice tutorial. It would be nice to decrease the resolution of your desktop or increase the font size because its hard to see.

  • @Pkroc138
    @Pkroc138 4 роки тому

    It's better explained than official documentation or any answer of stackoverflow lol. I literally fight for about 2 hours with this.

  • @apocalypt0723
    @apocalypt0723 4 роки тому +1

    This helped me so much i can finally make some subdirectories THANK GOD

  • @КитТэлвинд
    @КитТэлвинд 2 роки тому

    Thank you for the video. Your efforts help me to do my graduation project.
    You are so cool.

  • @SevenRiderAirForce
    @SevenRiderAirForce 3 роки тому

    I pronounce src as "serse" too! One of us, one of us!

  • @bassamry
    @bassamry 2 роки тому

    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?

  • @pjorourke0514
    @pjorourke0514 4 роки тому +2

    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

    • @ZirJo
      @ZirJo 4 роки тому

      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?

    • @ZirJo
      @ZirJo 4 роки тому +1

      No, ninja was not needed after all. I had written target_link_directories instead of target_include_directories. It works great now!

    • @daifengli6479
      @daifengli6479 2 роки тому

      @@ZirJo OMG, IT IS THE SAME. Thank you so much

  • @y29k15
    @y29k15 Рік тому

    This is so helpful. Thanks for saving me a lot of time.

  • @shanmukhasreedhar9067
    @shanmukhasreedhar9067 4 роки тому +1

    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 :)

  • @tomnichlson
    @tomnichlson 4 роки тому +1

    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

  • @talignmen
    @talignmen 6 років тому +1

    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)?

    • @vector-of-bool1005
      @vector-of-bool1005  6 років тому +2

      I'm glad these videos are helping you. I will definitely be covering external dependencies in the future! Stay tuned...

  • @djraju2
    @djraju2 3 роки тому

    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()

  • @williamxtc8054
    @williamxtc8054 4 роки тому +1

    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?

    • @psun256
      @psun256 4 роки тому

      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.

  • @mahmoudmahdi93
    @mahmoudmahdi93 4 роки тому

    I wish I can like the video twice man ! thank you :D

  • @richiekho8938
    @richiekho8938 2 роки тому

    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...?

  • @hishamnoaman1005
    @hishamnoaman1005 4 роки тому

    Hey helpful video, could you tell me the settings you are using in visual studio code

  • @lievendecock5836
    @lievendecock5836 5 років тому

    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).

  • @tulinh7426
    @tulinh7426 3 роки тому

    I don't understand why we need to create: "say-hello/src/say-hello" to contain files *hpp and *cpp?

  • @ChristopherPisz
    @ChristopherPisz 4 роки тому

    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?

  • @sammyiboi
    @sammyiboi 4 роки тому +1

    this was insanely helpful. Thank you!!

  • @pallabmaji5088
    @pallabmaji5088 5 років тому

    Thank you. This series is excellent :)

  • @LOB2023
    @LOB2023 5 років тому

    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?

  • @psun256
    @psun256 4 роки тому

    Intellisense doesn't actually recognize SAY_HELLO_VERSION, but it runs fine and works. What could be the problem?

  • @eugeniovoss7941
    @eugeniovoss7941 3 роки тому

    Incredible work! Thks!

  • @mirniazahmed7708
    @mirniazahmed7708 2 роки тому

    How can I use ninja in VSCODE?

  • @ponnlaksmi2903
    @ponnlaksmi2903 5 років тому +1

    thanks for a wonderful lecture

  • @davidaldrich449
    @davidaldrich449 5 років тому

    These videos are very helpful. Please can you make your source code available?

  • @antoniovelazquez9869
    @antoniovelazquez9869 3 роки тому

    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.

    • @unknowneemny
      @unknowneemny Рік тому

      hello! have you found the solution?

  • @allangjtterupernst6437
    @allangjtterupernst6437 2 роки тому

    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

  • @mohamedel-hamzawy9132
    @mohamedel-hamzawy9132 4 роки тому

    Great work :) super helpful

  • @Kabodanki
    @Kabodanki 5 років тому +1

    Pretty good, Clion freak out with subproject though, sad

  • @enemy537
    @enemy537 6 років тому

    Thank you very much for this tutorial. It help me a lot! =D

  • @santiagotorres6929
    @santiagotorres6929 3 роки тому +1

    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...

  • @sythanh14
    @sythanh14 5 років тому

    goodjob bro, thanks so much

  • @Destroyer19941995
    @Destroyer19941995 3 роки тому

    Very helpful thank you

  • @leimao1707
    @leimao1707 5 років тому

    Thanks a lot. How to use the CMAKE plugin in VS CODE by the way?

    • @SyntaxSemantic
      @SyntaxSemantic 5 років тому

      install cmake extension, go to command pallete and write Cmake: quick start, write what you need in the generated CMakelists.txt file. Done

  • @quant-prep2843
    @quant-prep2843 2 роки тому

    awesome

  • @buddhasarchive8385
    @buddhasarchive8385 5 років тому

    Thanks Man!

  • @fahd2372
    @fahd2372 3 роки тому

    shit just got real

  • @ac11dc110
    @ac11dc110 4 роки тому

    why .hpp and not .h?

    • @ZirJo
      @ZirJo 4 роки тому +1

      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"

  • @Truthsetsyoufree100
    @Truthsetsyoufree100 4 роки тому

    Tutorial content is great! But the tutorial could be explained a bit better... afternoon brain needed to watch a few times

  • @ytronik
    @ytronik 2 роки тому

    target_include_directories(say-hello PUBLIC $)