[CMake] add_custom_commmand TARGET is unknown
Nils Gladitz
nilsgladitz at gmail.com
Thu Apr 16 16:08:24 EDT 2015
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
More information about the CMake
mailing list