In this situation where you aren’t looking to create another library, you can just use the target defined in the parent CMakeLists.txt, the executable MyTarget
in this case. As long as the target has been defined, you can add additional sources to it with target_sources
. So no, there’s no local target you have to worry about.
You likely could define a separate target to contain the sources if you wanted, but I would imagine that’s only interesting in situations where you want to apply those sources to multiple targets. This is likely more complicated than what you’re looking for, but leverages the same target_sources
command.
If instead you are looking to organize files and are using a generator that supports filters, such as Visual Studio, you can always use a source_group
to group stuff in other_src
into a separate filter.