CMake: explicitly specify list of source files · Issue #881 ...
github.com › SuperTux › supertuxJul 20, 2018 · At the moment, we are using GLOB to collect a list of source files from our tree (CMakeLists.txt). The CMake documentation says this is bad practice: Note: We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed then the generated build system cannot know when to ask CMake to regenerate.
c++ - CMake generate list of source files without glob ...
stackoverflow.com › questions › 45090926Jul 14, 2017 · Then you can just include() this generated CMake file. Instructions in the CMake file could be using target_sources() for a known target. CMakeLists.txt: add_executable(myexe "") include(sourcelist) sourcelist.cmake: target_sources(myexe PRIVATE mysourcefile1.cpp mysourcefile2.cpp ) Or via appending to a variable: CMakeLists.txt: include(sourcelist) add_executable(myexe ${sources}) sourcelist.cmake:
aux_source_directory — CMake 3.23.0-rc3 Documentation
cmake.org › cmake › helpaux_source_directory (<dir> <variable>) Collects the names of all the source files in the specified directory and stores the list in the <variable> provided. This command is intended to be used by projects that use explicit template instantiation. Template instantiation files can be stored in a Templates subdirectory and collected automatically using this command to avoid manually listing all instantiations.
How to use all *.c files in a directory with the Cmake build ...
stackoverflow.com › questions › 2110795Jan 21, 2010 · AUX_SOURCE_DIRECTORY (dir VARIABLE) Collects the names of all the source files in the specified directory and stores the list in the variable provided. This command is intended to be used by projects that use explicit template instantiation. Template instantiation files can be stored in a "Templates" subdirectory and collected automatically using this command to avoid manually listing all instantiations.