[CMake] Can imported libraries depend on ExternalProject targets?
Kent Williams
nkwmailinglists at gmail.com
Tue Jun 26 11:20:45 EDT 2012
I meant to say 'the approach you use doesn't work, because imported
libraries are targets to are targets to which you CANNOT add
dependencies."
On Tue, Jun 26, 2012 at 9:33 AM, Kent Williams
<nkwmailinglists at gmail.com> wrote:
> That seems like it should work, but it actually does not.
>
> There's two types of precedence in CMake.
>
> 1. Textual -- as CMake munches through a project and its subdirectory,
> it generates a build system where the build order is the same as the
> textual order. In a single process build, for example:
>
> project(x)
> add_library(xlib ...)
> add_executable(xexec ...)
>
> 'xlib' will get built before 'xexec'
>
> 2. The dependency graph. Targets which do not depend on any other
> target get built first, then targets that depend on the 'leaf'
> targets. In the example above, adding
>
> target_link_libraries(xexec xlib)
>
> will make 'xexec' depend on 'xlib', and even if you build using more
> than one process (i.e. make -j 8), xexec will be built after xlib.
>
> I've verified that the approach you use below doesn't work, because
> imported libraries are targets to which you can add dependencies. I
> tried this approach and it didn't work -- in fact that is what my
> original e-mail is about.
>
> David Cole indicated in essence, I was doing it wrong. My position is
> that it's the only way to do it without completely revamping the ITK
> build system, which is above my pay grade.
>
> I thought of a sneaky workaround: Create a dummy library, with one
> object file that does nothing, and will never actually be loaded.
> Make the dummy library depend on the ExternalProject target, and add
> it to library list along with the ExternalProject's libraries.
>
> But that seems kind of ugly, creating a library no program actually needs.
>
> On Sat, Jun 23, 2012 at 9:06 AM, Stefan Reuschl <lists at stefanreuschl.de> wrote:
>>
>> The following once worked fine for me using CMake 2.8.8:
>>
>> ExternalProject_Add( ep )
>> add_library( epLib IMPORTED )
>> set_target_properties( epLib PROPERTIES IMPORTED_LOCATION ... )
>> add_dependencies( epLib ep )
>>
More information about the CMake
mailing list