10 ms·
Build2 – A C++ Build Toolchain and Package Manager
- RcouF1uZ4gsC 10y agoNice 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
- christianlefty 10y agothis is awesome we need the maven of cpp
- dom0 10y ago> maven of cpp Oh dear god no. Can we please have a way more sane manager than a maven of cpp?
- archgoon 10y agoWhat are the problems you encountered with maven (I've only used it a few times)?
- TakerofVita 10y agoWhat we really need is the cargo of C++
- saghm 10y agoIt's staggering to me how much time and effort we have to put into our build system for our C++ project at work. Having come to the C++ world after learning Rust, I'm constantly pining for the dead-simple "just works" nature of Cargo.
- pjmlp 10y agoI am still waiting for Cargo to be able to do what we do in our C++ builds, specially in what concerns build time. Lack of support for binary libraries, specially among projects is a big deal breaker. Watching the same dependencies being compiled multiple times isn't fun. Yes, downloading the libraries, placing them in some directory and configuring paths might take some time. But afterwards, C++ builds are quite fast as they just link to the provided libraries, instead of building the world every single time.
- saghm 10y agoThat's fair, although "building the world every single time" seems like a bit of an exaggeration, since cargo only recompiles dependencies if they're updated (or you specifically clean your build). The project I work on has relatively few dependencies, so the benefits of not having to specifically define different targets and spend time and effort supporting different toolchain- and platform-specific minutiae feels like it would be a big win for us.
- mlvljr 10y agoWhy not use qmake, chaps? It's rather simple and cross-platform, and YOU (who was going to answer, it needs Qt) is wrong, btw :) But yeah, yeah, everyone and their dog intends to continue torturing himself and their users with CMake spgahetti and bugs, of course. Real life, no time to avoid mistakes!
- ryandrake 10y agoUgh. Hate to be Debby Downer. I mean, nice effort, but one of the crappy things about some of these newish languages is how each of them comes with their own package manager baggage that is different from the package manager that all the rest of your software is installed through. So I have my Debian setup and I'm happily using apt to install all my software. Now ruby comes along and I need some libraries and have to go and install everything with gem. And I can't use apt to see what gems I have installed and vice versa! Argh!!! Now I have to write some python code and here comes pip... And node/npm... and on and on. apt-get install libx11-dev is just fine for my C and C++ development needs, thankyouverymuch. I don't see the value in yet another incompatible package manager.
- ioquatix 10y agoThe reality is that these tools add value that extends beyond mere package management. You are right though, if you just use them to install things, and not as part of a development process, they might seem superfluous.
- tyoverby 10y agoLet's say that you and I both create a library. You try to publish your C++ library to the standard debian repository, and I'll try to publish mine to cpam, npm, pip, etc... If you actually manage to get your library included, then we can compare how long it takes to update your library.
- paulddraper 10y agoSure. I publish to deb repos all the time. (I've found Bintray to be the easiest.)
- tyoverby 10y agoI didn't say "a" deb repo, I said "the standard debian repository". Just like when I'm talking about NPM, I'm talking about the main NPM repository, not my company's private NPM server.
- unix 10y agowhy not use github for package repository?
- seabrookmx 10y agoDo you mean git? Not sure what difference github makes over vanilla git in this case.. GoLang kind of does this (via "go get") and it sucks for multiple reasons: -you can only distribute packages as source, meaning you need to compile them yourself (this has pros and cons, but it would be nice to be able to distribute binaries if you want) -your dependencies reference a commit hash, and unless you micromanage your dependencies and constantly look at the github repository's tags, you have no semantic versioning, making it a lot more likely you'll encounter breakages -there's no way for your dependencies to specify dependencies, unless they're using git submodules (very few projects do), and even with submodules, you can't share dependencies across packages The list goes on.. Git is for source control. Package managers offer a lot of different (and awesome IMO) features. Lack of package management is one of my biggest gripes with GoLang honestly.
- DonbunEf7 10y agoWhy would I use this instead of Nix?
- pfultz2 10y agoLast time I looked at Nix it had a problem with dealing with cross-compilation. The problem is mainly that many packages still use autotools which does not have a descriptive toolchain. Ultimately, it could provide a descriptive toolchain and then map that toolchain to the different build systems, which is similar to what cget does, but perhaps a separate tool to do this could be helpful so this could be shared among different package managers.
- humanrebar 10y agoI've been by this page a few times. It's interesting to see work in this area, but there are only 15 packages on cppget.org. Obvious ones (boost, protobuf, folly, etc.) are missing from the list. Is this still in some sort of alpha state with respect to new package submissions? Or is nobody volunteering to maintain the missing packages?
- m-j-fox 10y agoI feel like the name bpkg is taken. BSD uses it and a search shows there's a Bash package manager that calls itself bpkg also. Maybe call it cpkg?
- jokoon 10y agoAny compiler already supporting some experimental version of modules? If library devs could start trying those out, it might give it some traction...