6 ms·
Nice work. However, I think the C++ community is best served by standardizing on CMake. It is widely used by many projects, and many IDEs natively support it n
by RcouF1uZ4gsC 10y ago
Nice work. However, I think the C++ community is best served by standardizing on CMake. It is widely used by many projects, and many IDEs natively support it natively (for example Jetbrains Clion, and Microsoft Visual Studio 2017)
In addition, "modern CMake" is much better than classic CMake" and the project is improving with such things like CMake server.
- jbb67 10y agoNo. I tried to install cmake and it wanted to install over 1000 files on my computer. I'm not prepared to install that level of super-bloat just to build a program
- jbb67 10y agoNo. I tried to install cmake and it wanted to install over 1000 files on my computer. I'm not prepared to install that level of super-bloat just to build a program
- mavam 10y agoI've started with and am used to the "old-school" CMake. Is there a good article that showcases some of the more modern features?
- elteto 10y agoAs a new cmake user these two presentations have been essential in getting started with "modern cmake": [0] http://thetoeb.de/2016/08/30/modern-cmake-presentation/ http://thetoeb.de/2016/08/30/modern-cmake-presentation/ [1] https://www.slideshare.net/DanielPfeifer1/cmake-48475415 https://www.slideshare.net/DanielPfeifer1/cmake-48475415 And this blog post also has some good stuff: [2] https://rix0r.nl/blog/2015/08/13/cmake-guide/ https://rix0r.nl/blog/2015/08/13/cmake-guide/
- W0lf 10y agoWell, I'm in the middle of writing a book titled "Effective CMake" [1] where I'm going to explain how to use CMake in a nice and modern way and some of the tricks which are not covered by the (very good) documentation. [1] https://leanpub.com/effective-cmake https://leanpub.com/effective-cmake
- quacker 10y agoCMake is not a package manager or package repository, though. CMake can discover libraries and it can build your code, but that assumes you've already fetched a dependency somehow. Sure, you can use system package managers, but these are different on every platform. I've been writing a simple video game in C++ recently, using CMake to build. I wrote a little bit of code that fetches the few libraries I need in order to have a complete/deterministic build process that works on linux/windows/mac. It lets me change versions (by specifying a new url to a source tarball). Versioned dependency management is so typical and convenient in many other languages and is such a pain in the butt with C++ because CMake is this thing that's sort of good enough. But my CMake experience doesn't compare well at all with maven, pip, gem, cargo, or even npm.
- lmitchell 10y agoYep, I'm a huge fan of this for this reason. I've spent a lot of time in my life messing around with cmake, scons, custom bash scripts... you name it, trying to get around C++'s shitty dependency management. And then recently I picked up Ruby, for the first time in a year or two, to write a little chat bot... 'gem install' is flawless across my Windows desktop and my Linux laptop, easy to depend on a specific version, easy to upgrade, etc. Tbh I'm pretty jealous. e: does anyone know if this has any relation to Boost's b2? I know that was originally based off of jam which is not related but the name is so similar I can't help but think I'm missing something :(
- suby 10y ago'gem install' hasn't worked flawlessly in my experience (on both Windows and Linux). It's more likely than not that I'll have a gem fail to install on me due to some dependency or configuration issue. It's consistent and frustrating enough where I shy away from Ruby now. I like Ruby more than Python as a language, but I will say that I've never had pip fail to install a dependency on me.
- derefr 10y agoA lot of Ruby libraries just happen to use native extensions that rely on OS-packaged libraries being installed. I'm surprised there isn't any part of the gem process that calls `pkg-config`, to verify if a gem will be able to install, given its native dependencies. Having `bundle install` bail out after just a second with "please install libfoo first" would be great, especially for CI. > I've never had pip fail to install a dependency on me `pip install` has never failed me, but `pip install --upgrade` fails for me quite a bit. Especially when I try to use it like `gem upgrade`, with a stanza like pip list --outdated --format=legacy | cut -d' ' -f1 | xargs pip install --upgrade
- eco 10y agoI second what you are saying about modern CMake. When I first switched to CMake years ago I grew to regret it. It worked but it was a total mess. Then a couple years ago I saw someone mention "modern CMake" and I googled around and realized they had implemented a much more sane approach since I first learned it. There is more to it than just this but a lot of the time you can just do a few find_package(library) commands, an add_executable(program [source files]), and finally a target_link_libraries(program [libraries]) to declare your dependencies and everything just works. Include paths are correct. Private dependencies aren't cluttering up stuff downstream. Debug and release version of libraries work as expected. Build flags and compiler definitions only apply to the modules you intended them to apply to. This is why I've been liking the approach Microsoft has been taking with vcpkg. They clearly see which way the wind is blowing. It's not restricted to using CMake but there is a strong preference for it and it uses CMake as its build scripting system. I just barely got done trying it on a large project for dependencies and it worked very well overall. A few commands to install a dozen or so dependencies and a quick change to add the vcpkg CMake toolchain so Visual Studio will pass it to CMake. After that and I can just use Open Folder on my CMake project in Visual Studio 2017 and everything just works. It's still a little rough around the edges but vcpkg seems to be developing at a breakneck speed for how new it is. Dealing with dependencies is the worst part about being a C++ Developer and I'm glad to finally have something that makes it this easy (on one platform at least; I still get to rip my hair out on macOS).
- hellofunk 10y agoI just wrote a bash script collection built on cmake that allows me to build and deploy libraries and modules for easy use in any project I want, without having to worry about all the include paths, linking, etc. I just add the name of the module to a Cmake variable and the scripts do the rest, making sure everything is found and included. Even third parties work nicely this way since I can just build them using my cmake scripts and have them automatically exported as modules for other projects to use. Setting this up was a couple weeks of learning curve but I agree it is worth it to invest in Cmake and also learn the low-level details about how it all fits together since after all we are dealing with a native low-level language, it also pays to see under the hood of these "package managers" and build systems so you can be fluid on any platform where you need to build.
- geokon 10y agoYou can actually do this from within CMake itself with a bit of a hack Here is someone who did something similar: https://crascit.com/2015/07/25/cmake-gtest/ https://crascit.com/2015/07/25/cmake-gtest/ If you're interested I can upload my version a bit later
- pfultz2 10y agoThis sound similar to cmake-get: https://github.com/pfultz2/cmake-get https://github.com/pfultz2/cmake-get
- geokon 10y agoLike the other comment says, you need to have the dependencies already prebuilt. You can say do things like "link to these header and this library" - and the modern-er syntax makes that cleaner but you still can't do a simple "Get this dependency, build it, then link my current project to it" To me this is a very strange and frustrating limitation b/c all the necessary piece are already there! It just doesn't have the functionality to call "build it" in the middle like that for some reason. I actually ended up hacking it in (it's like 50 lines of code) but it's a bit ugly and doesn't work recursively EDIT: It's also very inconvenient to do out-of-source builds with dependencies... constant source of frustration