[CMake] failing target

David Cole david.cole at kitware.com
Tue Mar 6 10:29:45 EST 2012


On Tue, Mar 6, 2012 at 10:24 AM, Andrea Crotti
<andrea.crotti.0 at gmail.com> wrote:
> On 03/06/2012 02:07 PM, Andrea Crotti wrote:
>>
>>
>>
>> I opened a thread some time ago about this, and I actually thought it
>> was a bug in the documentation, because then why everything works
>> otherwise?
>>
>> This simple example which I produced
>>
>> add_custom_target(a
>>  ${CMAKE_COMMAND} -E echo "a"
>>  )
>>
>> add_custom_target(b
>>  ${CMAKE_COMMAND} -E echo "b"
>>  DEPENDS a
>>  )
>>
>>
>> does exactly what would be expected, even if there files a or b don't
>> exist.
>> So I might suppose that this intra-target dependencies work but not
>> always,
>> is that correct?
>
>
> I tried to substitute the wrong DEPENDS with the add_dependencies and it
> seems to work now.
> That doesn't explain why it works on Windows and my other Linux box, but
> well if that's the correct
> way to do it I'll stick with that..
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake


The explanation is simple: if you have two targets and they run in
*random* order, then it will be "correct" 50% of the time... Or
perhaps 100% on one platform and 0% on another. That's likely what you
were seeing when you thought that it worked sometimes.

With the dependencies specified correctly with add_dependencies, you
should now see it work 100% of the time.


More information about the CMake mailing list