[CMake] How to depend on an ExternalProject

Rolf Eike Beer eike at sf-mail.de
Fri Oct 8 06:13:54 EDT 2010


>
> On 8. Oct, 2010, at 10:50 , Rolf Eike Beer wrote:
>
>> Hi,
>>
>> I have a problem with ExternalProject and how to depend on that. I'm not
>> absolutely sure I got the CMakeLists.txt right, so I first ask here
>> before
>> filing a bug report.
>>
>> The idea is like this: we have an project that generates a couple of
>> files. In a special configuration of another project we need those files
>> as input for a special build step. Those step will take those files,
>> mangle them and will generate a source file at the end. This is then
>> added
>> as usual to a library (in my example below to a executable, but that
>> doesn't matter). When I run the example below I get:
>>
>> [ 80%] Built target Subdir_Build
>> make[2]: *** No rule to make target `Subdir_Build', needed by `main.c'.
>> Stop.

[...]

> Subdir_Build is a top-level target, and the custom-command can only depend
> on files. You need to add a custom target that depends on main.c and then
> add a dependency of that custom target on Subdir_Build.

The documentation of add_custom_command has this sentence:

 If DEPENDS specifies any target (created by an ADD_* command) a
target-level dependency is created to make sure the target is built
before any target using this custom command.

So if I can't depend on a target this is extremely confusing. Even worse:
the dependency itself _works_, i.e. Subdir_Build always get's properly
build before the depending target. But even then depending target fails.

Eike


More information about the CMake mailing list