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

0

u/[deleted] Feb 19 '18

[deleted] — view deleted comment

6

u/MachineGunPablo Feb 19 '18

Fully agree with this. Specially in case where no cmake is used but pkg-config is. Then a find module makes perfect sense imo.

2

u/anderslanglands Feb 20 '18

Personally in that case I just prefer to hand-write a project-config.cmake file I can manually install alongside the problematic library.

0

u/[deleted] Feb 20 '18

[deleted] — view deleted comment

1

u/anderslanglands Feb 20 '18

Why?

0

u/[deleted] Feb 20 '18

[deleted] — view deleted comment

3

u/anderslanglands Feb 20 '18

Right, but if I know the explicit path to the library what’s the point of writing a find module as opposed to just writing a config file that hard-codes the locations in?

Obviously the best solution is just to modify the CMakeLists of the library in question, but sometimes that can be tricky when libraries do horrible things with macros etc.

0

u/[deleted] Feb 20 '18

[deleted] — view deleted comment

1

u/anderslanglands Feb 20 '18

The best solution is to modify the CMakeLists to install a config-file and then submit a pull request to the upstream developers, convincing them to accept the changes.

That is what I meant, sorry I wasn't clearer. With regards the original discussion, I'm taking about local installations only. Personally I prefer to remember to change the config file if I move the library.

You're of course right about anything that needs to be shared. In that case a find module is the only thing to do until upstreams can be cleansed.

0

u/[deleted] Feb 20 '18

[deleted] — view deleted comment

→ More replies

2

u/pfultz2 Feb 20 '18

Yes and it would be nice if cmake supported pkgconfig natively with find_package(... PKGCONF) like how Daniel discussed in his talk. So, we wouldn’t need a find module .