The generator is called during build time, so the files do not even exist when CMake runs.
CMake needs to know which files it shall compile and link, so they need to explicitly listed. Otherwise it can’t generate the build rules for them.
which explains the issue of generated source files.
You’ll discover that using add_custom_command is better than add_custom_target provided that you can give the list of generated files ahead of time.
NB: if ${CMAKE_CURRENT_SOURCE_DIR}/node_generation_main.py is yours may be you can make it spit out the list of generated files in order to avoid the file(GLOB_RECURSE generated_files ... which is not executed soon enough (at configure time and not build time).
Question
(1) Should I spit out the file names of the generated files as full path or relative path ? One line for each file or concatenated in a single line (as a CMake list string?) ?
(2) How should I then pass that information to add_executable ? Any pseudo code example ?
I would generate a file that is of a known filename that #include’s the other files generated. This path can then be added to the source listing for the executable. If you do statically know the list of files that will be created, that would be better, but it seems that (based on the glob), the set of files depends on the content of that json file.
(1) since the generator is yours you can make it generate a list file that can be included using https://cmake.org/cmake/help/latest/command/include.html, so the content of the generated file may defined a CMake variable, e.g. GENERATED_FILES which contains the list of generated file.
You can
include(generated_file.cmake OPTIONAL)
so that inclusion would not break if file is not there, but you’ll have to run cmake twice to get it right.
or you statically know the list of file (as @ben.boeckel said)