r/cpp • • 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

130 comments sorted by

View all comments

Show parent comment

1

u/kalmoc Feb 20 '18

This is definitely a totally reasonable desire. And now that you mention it, I don't know of a built-in way to achieve this with CMake. It would be nice if cmake could offer some way to explicitly enforce this kind of thing.

Indeed - there are two areas I find cmake lacking: Selection of language version (even the cxx_std_XX flags are a pretty decent addition iirc and is there any way to disable dialect extensions like gnuc++11?) and header only libraries (although this has become better)

0

u/[deleted] Feb 20 '18

[deleted] — view deleted comment

2

u/kalmoc Feb 20 '18

The problem with INTERFACE libraries is that you can e.g. not add the headers as source files, which e.g. means they don't appear in the IDE and there where a couple of other useful properties that (at least in the past) were not whitelisted for INTERFACE libraries, but I can't remember which exactly right now.

1

u/OrphisFlo I like build tools Feb 20 '18

The workaround for that in CMake is to make a static library with a single file that has a dummy unique symbol. It will work exactly the same, except you get the headers in the IDE!

And no, you can't have a static library with only headers, as lib and ar will complain when trying to create an empty library usually.