[CMake] [BUG] add_custom_command(TARGET ...) can't see in scope target

Iosif Neitzke iosif.neitzke+cmake at gmail.com
Tue Aug 4 17:32:21 EDT 2015


And:

"A target created in the same directory (CMakeLists.txt file) that
specifies any output of the custom command as a source file is given a
rule to generate the file using the command at build time."

http://www.cmake.org/cmake/help/v3.3/command/add_custom_command.html

But it's not super clear in the documentation.

On Tue, Aug 4, 2015 at 4:24 PM, Nils Gladitz <nilsgladitz at gmail.com> wrote:
> On 04.08.2015 23:15, Dan Liew wrote:
>>>
>>> foolib is defined in this CMakeLists.txt:
>>>
>>> https://github.com/delcypher/cmake_add_custom_command_bug/blob/master/lib/CMakeLists.txt
>>>
>>> That is the (only) context in which you can extend the definition of the
>>> target with custom commands.
>>
>> Since when?
>
>
> As far as I know it has always been this way.
>
>>   I haven't seen that documented anywhere. IMHO this
>> behavior is counter-intuitive, in general I expect the scope of a
>> target to not depend on the cmake command I am trying to use.
>
>
> I think it is sensible that the definition of a target is scoped to one
> single directory.
> Where the definition of a target consists of e.g. sources, properties,
> dependencies and custom commands related to the target.
>
> You can reference/query global targets in other directories but you can not
> change them.
>
> Nils
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list