How to use FetchContent_Populate
and a custom unpack function? In my case there is a nested tar archive that needs to be unpacked.
Sounds like you want to have it download the archive, but not unpack it, then add your own custom command to do the unpacking. You can use the DOWNLOAD_NO_EXTRACT
option to do the first part (the ExternalProject
docs explain how to use it). Then you could add a custom step using ExternalProject_AddStep()
with the COMMAND
that invokes your custom unpacker. Make sure to set up the dependencies between your custom step and the ones to come before and after it so that you get it invoked when required.
Does that mean I need to do this entirely with ExternalProject
instead of FetchContent
? So effectively the download step happens as part of the build step instead of at the configure step?
Ugh, yes, sorry, I mixed two things. Had my head buried in other things. What I mentioned would be appropriate for using ExternalProject, but not quite for FetchContent. You can still use the DOWNLOAD_NO_EXTRACT
keyword, but instead of adding a custom step, I guess you could abuse the PATCH_COMMAND
to do the unpacking for you instead.
I kept FetchContent_Populate
but added a UPDATE_COMMAND
to do a second unpack of the tar file.