[CMake] Fwd: File(write and add_custom_command
norulez at me.com
norulez at me.com
Fri Dec 23 10:15:59 EST 2011
Anfang der weitergeleiteten E‑Mail:
> Von: norulez at me.com
> Datum: 23. Dezember 2011 16:15:37 MEZ
> An: David Cole <david.cole at kitware.com>
> Betreff: Re: [CMake] File(write and add_custom_command
>
> I'll give it a try
>
> Great thanks
>
> Am 23.12.2011 um 16:10 schrieb David Cole <david.cole at kitware.com>:
>
>> You cannot put a function in CMakeLists.txt and then simply call that
>> function with add_custom_command.
>>
>> add_custom_command runs a command line tool. The custom command runs
>> later at build time. It does not run while cmake is running, it runs
>> later.
>>
>> What you can do is write a CMake script file like this:
>>
>> # begin CallXyz.cmake
>> function(xyz arg1 arg2 ...)
>> ...
>> endfunction()
>>
>> xyz("arg1value" "arg2value")
>> # end CallXyz.cmake
>>
>> And then use cmake -P like I said in my previous reply.
>>
>> Is there a problem with hosting this function in its own file? Seems
>> like a reasonable thing to do to me...
>>
>>
>> On Fri, Dec 23, 2011 at 10:02 AM, <norulez at me.com> wrote:
>>> Thanks,
>>>
>>> When i create a function, can i call it with add_custom_command to avoid extra files?
>>>
>>> Best Regards
>>>
>>> Am 23.12.2011 um 15:29 schrieb David Cole <david.cole at kitware.com>:
>>>
>>>> If you need to, pass -D args as well:
>>>>
>>>> add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/output.txt
>>>> COMMAND ${CMAKE_COMMAND}
>>>> -Dfilename=${CMAKE_CURRENT_BINARY_DIR}/output.txt -P
>>>> ${dir}/filewrite.cmake
>>>> DEPENDS ${dir}/filewrite.cmake ${other_files_too_maybe}
>>>> )
>>>>
>>>>
>>>> On Fri, Dec 23, 2011 at 9:28 AM, David Cole <david.cole at kitware.com> wrote:
>>>>> Yes.
>>>>>
>>>>> Put it in a *.cmake script file, and then call:
>>>>>
>>>>> add_custom_command(OUTPUT ...
>>>>> COMMAND ${CMAKE_COMMAND} -P ${dir}/filewrite.cmake
>>>>> DEPENDS ${dir}/filewrite.cmake ${other_files_too_maybe}
>>>>> )
>>>>>
>>>>> You cannot call it directly from custom command, because it needs a
>>>>> CMake process around it. If you want to call CMake at build time to
>>>>> run a -P script, it's quite reasonable to do so.
>>>>>
>>>>>
>>>>> HTH,
>>>>> David
>>>>>
>>>>>
>>>>> On Fri, Dec 23, 2011 at 9:22 AM, <norulez at me.com> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> is it possible to use file(write...) for a add_custom_command or add_custom_target?
>>>>>>
>>>>>> Thanks in advance
>>>>>>
>>>>>> Best Regards
>>>>>> NuRulez
>>>>>>
>>>>>> P.S.: Merry Christmas and a happy new year
>>>>>> --
>>>>>>
>>>>>> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20111223/fb330b47/attachment-0001.htm>
More information about the CMake
mailing list