There isn’t a CMake command that auto resolves directories the way you want.
Your best tools for adding files and include directories are
I’d look at this blog post by Craig Scott for handling your source files in a nice way which I have seen accepted in many projects that want to make their CMake code nicer.
Essentially your CMake script would end up looking like this:
project(FOOBAR LANGUAGES C)
Overall I think that’s a nice presentation
Then you have a CMakeLists.txt in src that looks like this (You can obviously do this for as many directories as you want):
target_include_directories(library PRIVATE .)
And potentially if you a nice library author your CMakeLists.txt in your inc directory looks like this:
# Notice the use of PUBLIC!
# Now when a client links against your library they automatically absorb the inc/ include directory
# Which makes their CMake code nicer since they don't need to know how your project is laid out!
target_include_directories(library PUBLIC .)