[CMake] problem with add_custom command

David Cole david.cole at kitware.com
Wed Nov 25 06:52:08 EST 2009


"cmake -E tar xvf" is implemented...

Does this happen with other tar files, or just that one?


On Tue, Nov 24, 2009 at 11:07 PM, Brian Davis <bitminer at gmail.com> wrote:

> So I found this thread below and tried the command at the promp (Win7):
>
> cmake -E tar xvf
>
> CMake Error: Problem with tar_open(): No such file or directory
> CMake Error: Problem extracting tar: ${TARDIR}/mytar.tar
>
> cmake -E tar xvf openssl-0.9.8a.tar
>
> CMake Error: Problem with tar_open(): No such file or directory
> CMake Error: Problem extracting tar: openssl-0.9.8a.tar
>
> so I do a:
>
> CMake Error: cmake version 2.8.0
> Usage: cmake -E [command] [arguments ...]
> Available commands:
>   chdir dir cmd [args]...   - run command in a given directory
>   rename oldname newname    - rename a file or directory (on one volume)
>   copy file destination     - copy file to destination (either file or
> directory)
>   copy_if_different in-file out-file  - copy file if input has changed
>   copy_directory source destination   - copy directory 'source' content to
> directory 'destination'
>   compare_files file1 file2 - check if file1 is same as file2
>   echo [string]...          - displays arguments as text
>   echo_append [string]...   - displays arguments as text but no new line
>   environment               - display the current enviroment
>   make_directory dir        - create a directory
>   md5sum file1 [...]        - compute md5sum of files
>   remove_directory dir      - remove a directory and its contents
>   remove [-f] file1 file2 ... - remove the file(s), use -f to force it
>   tar [cxt][vfz] file.tar file/dir1 file/dir2 ... - create a tar archive
>   time command [args] ...   - run command and return elapsed time
>   touch file                - touch a file.
>   touch_nocreate file       - touch a file but do not create it.
>   build build_dir           - build the project in build_dir.
>   write_regv key value      - write registry value
>   delete_regv key           - delete registry value
>   comspec                   - on windows 9x use this for RunCommand
>
> And I pay particular attention to
>
>   tar [cxt][vfz] file.tar file/dir1 file/dir2 ... - create a tar archive
>
> and notice no xvf option.
>
> Is tar xvf implemnted?
>
> If so why tar and no untar?  Curious.
>
> Brian
>
>
> On 25. Mar, 2009, at 10:28, ankit jain wrote:
>
> 2009/3/25 Michael Wild <themiwi-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org><themiwi-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org>
>
>
> On 25. Mar, 2009, at 9:33, ankit jain wrote:
>
> 2009/3/25 Michael Wild <themiwi-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org><themiwi-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org>
>
>
>
> [...]
>
>
> 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
>
>
> you could use
>
> execute_process(
>   COMMAND ${CMAKE_COMMAND} -E tar tf ${TARDIR}/mytar.tar
>   OUTPUT_VARIABLE tar_files
>   )
>
> to get a list of files contained in the tar file. However, I don't
> recommend this. It is much safer to really write the files out. If it hurts
> your eyes to put it in the CMakeLists.txt file, you can put the list in e.g.
> a file called files.cmake and INCLUDE that one from your CMakeLists.txt.
>
> DON'T use file(GLOB ...) or similar. That's a pretty bad idea...
>
> Michael
> _______________________________________________
> 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
>
>
> --
> Brian J. Davis
>
>
> _______________________________________________
> 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/20091125/abbc9a9a/attachment.htm>


More information about the CMake mailing list