Kitware implemented these good guesses in find_package and they actually may save you a lot of work if you use a common library in a popular S.O.
![chai3d cmake linux dependencies chai3d cmake linux dependencies](https://img-blog.csdnimg.cn/20200304132501363.png)
However, it can make good guesses based on popular operating systems and common practices of developers. Obviously, there is no way to find all dependencies in all the version/distribution of all operating system in the world. This confused me a lot the first time I saw it, since I wonder how CMake could know, just from a simple name, where to locate all the include and library files of the dependency. Supposedly, finding external dependencies is as simple and magically as calling the find_package like this:įind_package (YourExternalDependencyName) I want to remark “aid in finding ”, as opposed to “automatically finding”, since the former is only true under certain conditions, not always applying to your situation. CMake uses the find_package command to aid in finding the external dependencies.
![chai3d cmake linux dependencies chai3d cmake linux dependencies](https://1.bp.blogspot.com/-wx0M_wTRQ18/V3xcjWhmSuI/AAAAAAAAAeg/wjiDoj3JBjUulrUvFpiuvHdEnaZPjWxwgCLcB/s1600/kxisi-0706-1112.png)
TODO: input a description of how handling internal dependencies.Įxternal dependencies is when everything gets tricky. Those are rather easy to handle, because you know beforehand where they are going to be. Internal dependencies are the libraries that you create within your project. There are two kinds of dependencies in CMake, internal dependencies and external dependencies.
![chai3d cmake linux dependencies chai3d cmake linux dependencies](https://devblogs.microsoft.com/cppblog/wp-content/uploads/sites/9/2020/01/intellisense.png)
That’s why I advise you to take half a day (or in my case couple days) to properly understand how CMake find dependencies. You must understand the system deeply or be prepared to suffer several headaches. When looking to manage dependencies using CMake abandon any hope for quick tricks and rapid fixes. After struggling all day yesterday with dependencies in CMake, this is what I got so far: