When I ran "cmake .." in bin, cmake complained that it could not find source file src1.h in add_executable. What is wrong here?
Alex hit several of these points, but to wrap it up together:
A couple of things...
There's no need for a CMakeLists.txt in a directory if it's not actually going to do anything. i.e. if you're not adding targets or executing any other CMake code then just traversing the directories doesn't serve any particular purpose.
The list of source files that a target uses to build don't have to necessarily be full paths, they can be absolute or relative paths, but the relative paths need to be relative to where the target is created, i.e. the add_executable(...) call. So in your case, the target is "exec" in the "src" folder so all paths to source files, if relative paths and not absolute paths, need to be relative to the src directory.
include_directories is the older style CMake and will apply to all targets created after it. Use target_include_directories instead for the more modern target-centric approach of having commands only apply to the appropriate target instead of globally.
Rather than use a list of sources, you can also use the target_sources command to programmatically add source files to a target based on necessary logic. The same restriction applies though that the sources added need to be relative to the target location or an absolute path.
The preferred project layout for CMake is to really have out-of-source builds. So instead having bin as a sub-directory of your project, just eliminate that level entirely. You can certainly create your structure however you want but that's the suggested and preferred way of organising.
Combining these things, you could have nested CMakeLists.txt in which the subdirectories are explicitly adding the sources:
Both are valid, the first is overkill for this simple example but illustrates a way of doing things that can be helpful with much more complex projects. Either way, you also have a build directory completely detached and outside your source tree instead of a sub-directory.