5 ms·
I'm still not convinced there's a good way in cmake to pull in and compile external libraries as dependencies. I know it can be done via a superproject method b
by lfowles 8y ago
I'm still not convinced there's a good way in cmake to pull in and compile external libraries as dependencies. I know it can be done via a superproject method but that's a lot of boilerplate for something that should be straightforward. Everything else is simple and easy until I butt heads with that issue.
- berkut 8y agoIn my experience, ExternalProject_Add() isn't a lot of boilerplate. You specify the source, target dir, and other stuff can be optional.
- lfowles 8y agoIt's been a while since I've done this kind of CMake in anger, but I recall my main gripe with ExternalProject_Add is that it can't leverage that the external project is a CMake project and I still end up hard coding paths.
- svalorzen 8y agoNot sure if this can help you, but I simply use function (AddDependency name) add_subdirectory(${PROJECT_SOURCE_DIR}/deps/${name}) include_directories(${PROJECT_SOURCE_DIR}/deps/${name}/include) endfunction (AddDependency) And then use git submodule to clone all the dependencies I need in the deps folder. Everything then works automagically (assuming that the dependency is built through CMake).
- isaachier 8y agoCheck out https://github.com/ruslo/hunter https://github.com/ruslo/hunter for a fantastic CMake package manager built to solve this issue.
- geokon 8y agoI wrote up a little thing about all the alternatives https://geokon-gh.github.io/hunterintro.html https://geokon-gh.github.io/hunterintro.html. Tldr: Hunter is by far the best options and makes CMake painless. It also solves some multiple-dependency and toolchain issues that are nearly impossible to get right with vanilla CMake