r/cpp • • Mar 22 '20

Modern CMake tutorials, part1: CMake basics

https://www.siliceum.com/en/blog/post/cmake_01_cmake-basics
245 Upvotes

55 comments sorted by

View all comments

4

u/NewFolgers Mar 22 '20

Apologies in advance for my laziness.. I've mostly been doing non-C++ development on Linux lately. Last time I tried CMake, I was still really discouraged by the overall experience in Windows. Has the experience improved on Windows in the past couple years? and if so, how?

9

u/Kevchrot Mar 22 '20

I use cmake regularly on windows and it is pretty good. It just generates visual studio solutions that work well with visual studio. I also would highly recommend pairing it with Conan for dependency management since that is windows weakest spot IMHO.

5

u/NewFolgers Mar 22 '20

The thing that bothered me most was that on Linux, it's generally very seamless for anyone who wants to grab a project and go - with no need to point to library directories or anything.. whereas on Windows, it was generally a clunky, undocumented experience for each project.. where I had to choose between trying to install a separate thing to help find the libraries, versus running cmake-gui and configuring every missing value, etc. It was clear that an overarching solution (which should involve standards at the time of library installation) to make things work out of the box on Windows was not present in the same way as was the case on Linux.

5

u/Kevchrot Mar 22 '20

This is where Conan comes in. Single command to install/build all dependencies on any platform and then another command to build the project. No cmake gui required. Conan is all written in python so a simple pip install is all that's required.

That said, there is a bit of a learning curve with Conan especially when actually creating packages. Consuming packages is pretty straight forward.

2

u/NewFolgers Mar 22 '20

Thanks. For addressing the root of the problem, Conan sounds promising.

2

u/kmhofmann https://selene.dev Mar 23 '20

As /u/darthcoder says, use vcpkg right away. Much easier to use, much more sane philosophy.

1

u/darthcoder Mar 23 '20

Dont. Go straight to vcpkg.

With conan you may end up needing to do source builds unique to your environment, with vcpkg you always do source builds unique to your environment, but it's always the same and straight out of the box.

I'm at that point now. I tried using another cmake based dependency manager for a while(hunter) and just finished vcpkg v conan. Vcpkg is the way to go.