[CMake] add_custom_commmand TARGET is unknown

Daniel Dilts diltsman at gmail.com
Thu Apr 16 16:25:55 EDT 2015


You can only add commands to a target that was defined in the current
directory?  So, I would have to have a new target for each directory and
then have a target that depends on all of those targets?

On Thu, Apr 16, 2015 at 1:08 PM, Nils Gladitz <nilsgladitz at gmail.com> wrote:

> On 16.04.2015 22:01, Daniel Dilts wrote:
>
>> I have the following in my lists:
>> if(TARGET CustomTarget)
>>   message("TARGET CustomTarget")
>> else()
>>   message("NOT TARGET CustomTarget")
>> endif()
>> add_custom_command(TARGET CustomTarget PRE_BUILD
>>   COMMAND CustomCommand.exe
>>   USES_TERMINAL
>>   )
>>
>> In my output I get:
>> TARGET CustomTarget
>> CMake Error at Some/Path/CMakeLists.txt:52 (add_custom_command
>> ):
>>   The target name "CustomTarget" is unknown in this context.
>>
>> It seems like the if() shows that there is a target with the desired
>> name.  Am I missing something?
>>
>
> You can only modify a target after it has been defined and in the
> directory (CMakeLists.txt) that defined it.
> The same goes for appending commands to targets.
>
> Nils
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150416/383ba3a8/attachment.html>


More information about the CMake mailing list