[CMake] problem with add_custom command

ankit jain ankitguddu at gmail.com
Wed Mar 25 05:28:14 EDT 2009


2009/3/25 Michael Wild <themiwi at gmail.com>

>
> On 25. Mar, 2009, at 9:33, ankit jain wrote:
>
> 2009/3/25 Michael Wild <themiwi at gmail.com>
>>
>
> [...]
>
>
>>> What I usually do is this:
>>>
>>> add_custom_command( OUTPUT ${TARDIR}/t1
>>> COMMAND ${CMAKE_COMMAND} -E tar xvf ${TARDIR}/mytar.tar
>>> WORKING_DIRECTORY ${TARDIR}
>>> COMMENT "Extracting ${TARDIR}/mytar.tar"
>>> VERBATIM
>>> )
>>>
>>> add_custom_target( extract_mytar
>>> DEPENDS ${TARDIR}/t1
>>> )
>>>
>>> This tells CMake how to obtain the file ${TARDIR}/t1 by unpacking
>>> mytar.tar. Then it adds a target which depends on that file. You then can
>>> have other targets depend on that by using add_dependencies.
>>>
>>>
>>
>> Thanks for your suggestions it works but the problem is that iam making a
>> library which requires some source files which will come after extracting
>> it
>> from tar.
>>
>> In that making an custom target for it and then add_dependencies to that
>> library to this custom build target does not solve the purpose.
>>
>> then how to include those files which is required by the library which
>> came
>> from tar.
>>
>
>
> if you add all the files from the tar archive to the OUTPUT list of
> add_custom_command, CMake should automatically set the GENERATED property of
> those file to TRUE. If you don't want to do that, you still can set that
> property manually, using e.g.:
>
> set_source_files_properties( ${TARDIR}/t1 ${TARDIR}/t2 PROPERTIES GENERATED
> TRUE )
>
> you then can use those files in a normal add_library or add_executable
> command. if you use the first approach (listing all files in the OUTPUT
> list), you don't even need the custom target, since CMake then will know how
> to "create" these files (by invoking the custom command).
>
>
Is there any way by which we just give the name of folder where files has
extracted and add_library command will take it by some means it is becoz if
we dont know what files will be genrated inside that folder or if there are
large no.of files then listing them in OUTPUT is really cumbersome..


ankit

>
> michael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090325/4eb9cee2/attachment.htm>


More information about the CMake mailing list