HomeНаука и техникаRelated VideosMore From: Jason Turner

C++ Weekly - Ep 78 - Intro to CMake

512 ratings | 30028 views
Support these videos: https://www.patreon.com/lefticus Learning C++ Best Practices: http://shop.oreilly.com/product/0636920049814.do Inheritance and Polymorphism with C++: http://shop.oreilly.com/product/0636920052166.do Follow me on twitter: https://twitter.com/lefticus Source:
Html code for embedding videos on your blog
Text Comments (32)
Ezra Schroeder (1 month ago)
I'm used to managing different environments for python with conda. What do people use to quickly switch between different c/c++ compilers?
Barry Manilowa (1 month ago)
This is terrible. A waste of time. No explanation of what you're doing.
smit patil (5 months ago)
I hate people who use linux in virtualbox .they are noobs
yian dev (5 months ago)
you already lost me ccmake not even available with cmake install on window, ciao arrivederci
Animesh Gupta (4 months ago)
Thank you for posting this.!
yian dev (7 months ago)
how is that editor called?
Fataho (8 months ago)
The most complicated c++ "Hello world" I have ever seen :D Thank you for the tutorial, it was very helpful.
Pau Guillamon (9 months ago)
Great intro! I would like to see more videos about CMake, for instance how to set it up so it runs the unit tests automatically or some more advanced features (folders structure, how to deal with project related scripts needed for runtime, and so on)
Florian Wolters (10 months ago)
I think this is a lean and concise introduction to CMake. Two suggestions (already mentioned in some other comments): - Usage of target_compile_options instead of add_compile_options. The former is the modern (and non-global) way to add compiler options to a target. - Usage of target_compile_features(intro PRIVATE cxx_std_14) instead of target_compile_features. IMO this is much simpler and one does not have to modify the CMakeLists.txt file when language features are added and removed in the C++ source code. IMO future versions of the CMake application should allow abstraction of compiler flags (e.g. for error/warning reporting) via cmake-compile-features so that we do not have to specify compiler-specific flags. The real deal would be something as simple (from the users perspective) as target_compile_errors(intro PRIVATE all_errors all_warnings) (made up example).
SylphDS (10 months ago)
Would you really recommend keeping track of a list of all the language features one uses (in target_compile_features)? It seems like this list might get rather large and would require continued manual updating to keep it actually meaningful, whereas simply setting CMAKE_CXX_STANDARD would not.
Script10k (10 months ago)
I thought exactly the same.
Ernest Rutherford (11 months ago)
i use ninja build. cmake is terrible
Barry Manilowa (1 month ago)
yian dev You're not looking for easy. You're looking for a good tutorial and this one sucks!
yian dev (7 months ago)
any easy tutorial on how to use ninja? or its not for beginners?
Ahmed Moustafa Amin (11 months ago)
nice video, could you make a series of tutorials on cmake for beginners to excel using it, there isn't any tutorials for it on YouTube for years now. thanks
KhanRecordz (11 months ago)
Since around CMake 3.8 you can also make sure that a specific version of c++ is used by passing "cxx_std_##" where ## can be 98, 11, 14 or 17, into the target_compile_features command! :) I often feel that I either don't know the names of the features I need or don't know what features I'm using, so that feels like a nicer way to just encapsulate all of them.
Jason Turner (11 months ago)
Hmm, I thought I mentioned the cxx_std option. Maybe I'll need to do an updated episode to make sure these things are covered.
kwinzman (11 months ago)
Great, concise intro.
Kai Wolf (11 months ago)
Nice, I appreciate your use of modern CMake. There's so much old information online, we definitely need to change that:-) I'm currently in the process of writing a new book about it called 'Effective CMake' on Leanpub which exactly deals with writing effective, modern CMake. Thanks for making these videos!
Lothar Scholz (7 months ago)
Thanks, i might buy it even if i now have mastered cmake. But i still only use it for unit testing inhouse tools etc. Everything in our flagship product needs native IDE build files.
Henri de Feraudy (10 months ago)
The book called Mastering CMake has a lot of bad reviews. So I hope your book will remedy all that! One reason I want to use CMake I'm frustrated at trying to install OpenCV. The installation process via CMake does not find my Anaconda Python, thinks I only have Python 2.7 It gave me a few messages I wasnt sure I was interpreting correctly. I'm guessing that if I understood CMake correctly all that would be easier to fix.
Lectem (11 months ago)
I thought so too, until I saw add_compile_options, why not use target_compile_options ? A bit sad this was missed :/ Otherwise good intro, a big + for showing ccmake and cmake-gui that makes it way easier for people to understand cmake cache
Sakuya Izayoi (11 months ago)
Just to let you know. I am ;)
Kai Wolf (11 months ago)
Also, the link to the book just in case anyone is interested: https://leanpub.com/effective-cmake
Kevin Hjelden (11 months ago)
VS 2017 has native CMake support, so you don't even have to do that last step on windows anymore.
Aakash Mallik (2 months ago)
good lucking using it on linux
Velho Joel (5 months ago)
It's awesome you can just open up folder which contains CMake configuration and it opens up in VS as a Solution
narutofan9999 (6 months ago)
It also doesn't work very well with Resharper++.
Ybalrid (11 months ago)
I tried it and I wasn't that impressed with it. It's not really good when having to specify a lot of variable for complex dependencies, and the "open directory" features ignored the CMakeLists.txt file in one of my projects...
Jason Turner (11 months ago)
Oh snap, I should have tested that. That shall be a followup episode!
sephirostoy (11 months ago)
Visual Studio 2017 comes with a native support for CMake projects, though I didn't test it yet.
Kim (11 months ago)
Awesome! Exactly what I need!

Would you like to comment?

Join YouTube for a free account, or sign in if you are already a member.