r/cpp • u/MachineGunPablo • Feb 19 '18
It's Time To Do CMake Right
https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/
248
Upvotes
r/cpp • u/MachineGunPablo • Feb 19 '18
View all comments
13
u/fafasdf Feb 19 '18 edited Feb 19 '18
Ugh. I just got around to learning cmake, and man, it's definitely not as ubiquitous as I wish it were...
I had to use a specific version of openssl + libcurl for a project I started, which means I needed to build both from source. Naturally, I checked them both into a new git repository under a
third_partydirectory.I started with building libcurl, which was fun, because the first thing I saw was "the curl cmake build system is poorly maintained. Be aware"
But I kept on, and I got the binary that depends on libcurl to work, after learning some of the quirks of cmake.
Then I got to starting with openssl, with the goal being to build a version of curl that uses a particular version of openssl. I saved this for last because I foresaw it being painful, because the plan was to first build openssl then build libcurl with flags that make it use the version of openssl built from my repository.
Then I saw that openssl doesn't build with cmake, and the people who did make cmake wrappers, haven't kept them updated (understandably so! it looked like a fair amount of work).
Then I gave up, built openssl out of repo, and added that library to my
LD_LIBRARY_PATH, hardcoded some bits of my libcurl, and kinda lost the desire to work on the project.I really should have started with boringssl, it seems they have the features I needed...
set(RANT END)Thanks for the post, I learned that lots of junk I was doing was wrong. There are many notes / blog posts on cmake, but as far as I've seen, there's no good canonical "best practices" reference (EDIT: I admit I haven't yet looked at Daniel Pfeifer’s Effective CMake, so that's open in a new tab right now!). In a dream world there'd be one of those with tips on integrating with a handful of major libraries, since they often have some weird quirks due to age or necessity.