[Insight-developers] ExternalData evaluation of DATA{} without a test

Brad King brad.king at kitware.com
Thu Jun 30 10:06:39 EDT 2011


Hi Dan,

Bill mentioned that you asked about referencing external data without adding it
to a test command line.  This is already possible.  See the documentation in
the ExternalData module itself:

  http://itk.org/gitweb?p=ITK.git;a=blob;f=CMake/ExternalData.cmake;hb=v4.0a08#l16

In particular, look at the ExternalData_Expand_Arguments function:

  # The 'ExternalData_Expand_Arguments' function evaluates DATA{} references
  # in its arguments and constructs a new list of arguments:
  #  ExternalData_Expand_Arguments(
  #    <target>   # Name of data management target
  #    <outVar>   # Output variable
  #    [args...]  # Input arguments, DATA{} allowed
  #    )

Here is how to use it in CMake code:

  # Add rule to fetch DATA{}.  Stores in "in_png" variable the
  # location of data after build.
  ExternalData_Expand_Arguments(MyData in_png DATA{Input/in.png})

  # ... configure_file ... to put @in_png@ in test source

  # At end of configuration, add target to download data.
  ExternalData_Add_Target(MyData)

the MyData target will contain the download rules at build time.  The same
target can be used for tests and direct calls to Expand_Arguments.  For
example, in ITK one could write

  ExternalData_Expand_Arguments(ITKData in_png DATA{Input/in.png})

and the main ITKData target will download the data.

-Brad


More information about the Insight-developers mailing list