[CMake] ExternalData in sources

Simon Rit simon.rit at creatis.insa-lyon.fr
Thu Jun 13 06:13:23 EDT 2013


Hi,
Thanks for your answer. I don't think I follow you. The real file
would be downloaded in the directory ExternalData_OBJECT_STORES that
would stay in the binary directory. But I want a link in my source
directory to the downloaded file.
For example, I want to download bigfile.bin in my source directory at
make time. I add bigfile.bin-md5 that I commit to the git and add
bigfile.bin / bigfile.bin-stamp in the .gitignore file. When I
compile, that would tell him to link the real file in
ExternalData_OBJECT_STORES to bigfile.bin. Where does it transform it
again and again?
I agree with you that this seems to be silly if you do 2 builds of the
same source tree. But one could avoid overwriting the links by
pointing all builds to the same ExternalData_OBJECT_STORES.
Simon

On Tue, Jun 11, 2013 at 6:58 PM, Brad King <brad.king at kitware.com> wrote:
> On 6/11/2013 2:42 AM, Simon Rit wrote:
>> My intention was to add link to the binary files in the source
>> directory and to add them in the .gitignore files. I tried to set
>> these two variables :
>>   set(ExternalData_SOURCE_ROOT ${CMAKE_SOURCE_DIR}/examples)
>>   set(ExternalData_BINARY_ROOT ${CMAKE_SOURCE_DIR}/examples)
>> but cmake prevents me from doing that with the message:
>>   ExternalData_LINK_CONTENT cannot be used in-source
>>
>> Could someone explain me why? Is there a workaround for what I want to
>> do?
>
> The ExternalData_LINK_CONTENT setting tells the module to transform
> any "real" data file into a content link to simplify adding them.
> If you set the source and binary root to the same path then after
> building the "real" files will be present and the module will
> transform them again and again.
>
> If you're populating content links by hand then you do not need
> to set ExternalData_LINK_CONTENT at all.
>
> I recommend against setting ExternalData_BINARY_ROOT inside the
> source tree in general.  It is populated with build outputs and
> so belongs in the build tree.  Whatever command lines receive
> paths to the files can get them from the build tree instead of
> the source tree.  The DATA{} references automatically get replaced
> with the path to the "real" file.
>
> -Brad


More information about the CMake mailing list