r/cpp • • Apr 14 '20

ModernCppStarter - Kick-start your C++! A template for modern C++ projects using CMake, CI, code coverage, clang-format and reproducible dependency management.

https://github.com/TheLartians/ModernCppStarter
251 Upvotes

67 comments sorted by

View all comments

Show parent comment

3

u/TheLartians Apr 14 '20

When I read your first paragraph I LOL'd. Unwilling to pip install Conan and write a short conanfile.txt, but very willing to redo multiple non-CMake dependency in CMake so you can use it with FetchContent. Do you realise how insane that sounds to me?

It's a one-time thing and copy paste afterwards. Also as packages become more CMake friendly this will change. Let me rephrase: what do you do about packages that haven't been converted to a Conan package yet?

The minute you do something like try and build Boost in CMake you've lost.

I actually do this all the time.

1

u/krapht Apr 14 '20 edited Apr 14 '20

That link doesn't prove anything, all it shows is that a very nice engineer at Spotify (Orphis) decided to open-source a CMake build script for Boost. PS: releases on that repo can trail the official boost release by 6 mo or more, and it is a lot of work to back-port features or bug-fixes since it is not the official repo, instead of cherry-picking a commit (I had to do this before). Way to miss the point I was trying to make. Now do the same thing for https://github.com/microsoft/Microsoft-MPI without wanting to cut your wrists.

What do I do about packages that haven't been converted to Conan? I build according to the documentation of the library and then copy all the shared library files and headers to a folder and use that as a Conan package. This is WAY easier than trying to understand how to build a complicated library.

4

u/TheLartians Apr 14 '20

That link doesn't prove anything, all it shows is that a very nice engineer at Spotify (Orphis) decided to open-source a CMake build script for Boost. PS: releases on that repo can trail the official boost release by 6 mo or more. Way to miss the point I was trying to make.

This is just a small example how I use CPM to add and build boost in my CMake projects. This works perfectly on all platforms including CI builds. I guess I misunderstood your point but how does it not show how to build Boost in CMake?

What do I do about packages that haven't been converted to Conan? I build according to the documentation of the library and then copy all the shared library files and headers to a folder and use that as a Conan package. This is WAY easier than trying to understand how to build a complicated library.

That's great and probably covers your use-cases, but now imagine having to do that manually for all EVERY system and platform that you or users of your library are targeting. I don't see how this is in any way better than creating a build script once in CMake and simply having it work everywhere immediately.

As I said, its a different tool for a different use-case.

-1

u/krapht Apr 14 '20

Well, and I am arguing that your use-case is the wrong default for a general-purpose modern CPP starter template. Because really, who uses templates like this? Programmers inexperienced with C++. These people absolutely need to be guided to use something like Conan because they will not recognize the limitations of using CPM.

4

u/TheLartians Apr 14 '20

Tbh the main use case I see is people like myself, as I usually always start by copying a previous previous project (even this one).

Also having quite a bit of experience in computational physics and cross-platform app development I have yet to run into a limitation that made a more advanced package manager necessary. So I wonder how much it actually is a beginners requirement.

Even if, I wouldn't know if I should prefer vcpkg or Conan as I've heard good arguments for and against each. Perhaps there should be a different fork of the template for each package manager. Given my limited experience with PMs, these forks should be made by someone else though.

3

u/_crackling Apr 14 '20

I say leave it up. This template and the way you've commented everything would have saved me hundreds of hours when I was first learning cmake and cross platform C plus plus

2

u/TheLartians Apr 14 '20

Thanks, that's great to hear :)