[CMake] ExternalData in sources

Brad King brad.king at kitware.com
Tue Jun 11 12:58:47 EDT 2013


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