aux_source_directory.rst 1.0 KB

123456789101112131415161718192021222324
  1. aux_source_directory
  2. --------------------
  3. Find all source files in a directory.
  4. ::
  5. aux_source_directory(<dir> <variable>)
  6. Collects the names of all the source files in the specified directory
  7. and stores the list in the ``<variable>`` provided. This command is
  8. intended to be used by projects that use explicit template
  9. instantiation. Template instantiation files can be stored in a
  10. "Templates" subdirectory and collected automatically using this
  11. command to avoid manually listing all instantiations.
  12. It is tempting to use this command to avoid writing the list of source
  13. files for a library or executable target. While this seems to work,
  14. there is no way for CMake to generate a build system that knows when a
  15. new source file has been added. Normally the generated build system
  16. knows when it needs to rerun CMake because the CMakeLists.txt file is
  17. modified to add a new source. When the source is just added to the
  18. directory without modifying this file, one would have to manually
  19. rerun CMake to generate a build system incorporating the new file.