[CMake] How do you handle recursive dependencies in CMake

Sven Baars s.baars at rug.nl
Tue Jun 28 06:35:45 EDT 2016


Hey Ray,

Project A is used by many projects, and so is project B. So
ExternalProject is not the right solution. I just want to be able to fix
project B in such a way that people, including myself, can easily use it
without knowledge of where project A is located. The packages will all
be used mostly on supercomputers, where users never have rights to
install anything, and even if they install them as a module, it is still
in a non-standard path. As you can see from the example, this works fine
for project B which depends on A, but not for project C which depends on
B. Even if you set the PATH correctly.

Sven

On 06/28/2016 12:25 PM, Raymond Wan wrote:
> Hi Sven,
>
>
> On Tue, Jun 28, 2016 at 6:03 PM, Sven Baars <s.baars at rug.nl> wrote:
>> The packages I use are installed in a non-standard path, because I don't
>> have access to the system directories on most systems I work on, but are
>> used by many other libraries. They are also all separate packages, not
>> packages in the same source tree. I did not see my attachment on the
>> mailing list archive, so instead I just put it on Github. It can be
>> found here:
>>
>> https://github.com/Sbte/cmake-example
>>
>> I hope the example shows my workflow, and also what doesn't work for me.
>
> Hmmmm, in that case, I should probably remain quiet as this is not
> quite something I've had to do.
>
> Maybe the only advice I can give is, if you plan to distribute your
> work to others, what are your expectations in terms of where do you
> think users should install these dependencies.
>
> For example, if it's a system-level directory, then maybe you can
> consider a FIND_PACKAGE solution which has a list of default paths to
> search.  When you're developing on your own computer, you just change
> the default path to include paths in your home directory.
>
> There is also the ExternalProject () directive which you could
> consider [https://cmake.org/cmake/help/v3.3/module/ExternalProject.html]
> .  This would retrieve the dependencies from outside sources (i.e.,
> repositories) and build them.  This would keep everything within the
> same build/ path and I haven't done that (and didn't mention it
> before) because all of my packages are within the same source tree.
>
> So, still not quite your situation, though.
>
> I hope this helps!  Perhaps others can chime in and help you with
> exactly what you're stuck with...
>
> Ray



More information about the CMake mailing list