[CMake] external projects and transitive dependencies

Micha Hergarden micha.hergarden at gmail.com
Thu Mar 20 09:26:52 EDT 2014


On 03/20/2014 04:48 AM, Brian Lewis wrote:
> On 2014.03.19, at 07:21, Micha Hergarden wrote:
>
> Hi, thanks for answering. Could you please elaborate a little?
>
>> ExternalProject_Add has a DEPENDS option. What you can do is let X
>> depend on Y
> DEPENDS seems to mean that the external project depends on something
> else. If I wanted to make X depend on Y, wouldn't I use
> ADD_DEPENDENCIES?
>
>> and use the CMAKE_CACHE_ARGS option to provide the include path
> I don't think I understand how to use CMAKE_CACHE_ARGS. It seems to be a
> way to pass information from the calling project to the external project
> via a cache. But I need to send information the other way, from the
> external project back to the caller.
>
>> or use the buildsystem in project X to find the headers itself.
> I'm not sure how to do this. X would need to spelunk around in Y's
> external dependencies, I think?
Hello Brian,

Sorry, it seems I didn't understand your question correctly. I was
talking about one external project depending on another external
project. Say, I have project X which uses Y, and Y is dependant on Z. I
could write someting like:

ExternalProject_Add(
    llvm
    PREFIX ${CMAKE_CURRENT_BINARY_DIR}
    GIT_REPOSITORY http://llvm.org/git/llvm.git
    GIT_TAG origin/master
    DEPENDS clang compiler-rt
    CMAKE_CACHE_ARGS
        -DLLVM_INCLUDE_TOOLS:BOOL=ON
        -DLLVM_INSTALL_TOOLCHAIN_ONLY:BOOL=ON
        -DLLVM_TARGETS_TO_BUILD:STRING=X86;ARM
        -DLLVM_EXTERNAL_CLANG_SOURCE_DIR:PATH=${CLANG_SOURCE}
        -DLLVM_EXTERNAL_COMPILER_RT_SOURCE_DIR:PATH=${COMPILERRT_SOURCE}
        -DCMAKE_INSTALL_PREFIX:PATH=${TOOLING_DIR}
    )

Here I have project llvm, which depends on clang downloading first. So
my project depends on llvm and clang, and this call makes sure llvm is
build with clang.

In this case llm does not have its own externalproject_add call to get
clang. This may not be the case in your project. Perhaps you can let
project y generate a cmake script to pass back to project x?

Regards,
Micha



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 555 bytes
Desc: OpenPGP digital signature
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140320/521abce3/attachment.sig>


More information about the CMake mailing list