Forwarding to the list and replying to some parts.
> I removed add_subdirectories and added path to each of the source
> file according to your instruction and things worked! I just have a
> quick question: why should I remove the add_subdirectories in the src
> CMakeLists.txt? I thought add_subdirectories should tell cmake to look
> for files in the directories?
add_subdirectory() tells CMake that there's yet another listfile
(CMakeLists.txt) in a subdirectory, which will be processed recursively
until no further listfiles are found inside. Then the normal procedural
flow continues. So it doesn't say anything about project files, just
that new script code that might involve the project files needs to be
>>> |----- CMakeLists.txt
>>> |----- src --------|------CMakeLists.txt
>>> | |------dir1-----|
>>> |------- src1.h
>>> | |-----CMakeLists.txt
>>> |----bin |-----src2.c
>> It's quite hard to figure out what's going on here, but I assume src1.h
>> is under src/common. Please post the output of 'tree' command next time,
>> if you are on a Unix.
>>> set(src_files src1.h src2.c src3.c)
>> You don't have to add headers as target dependencies unless you program
>> in an IDE (just fyi).
>>> CMakeLists.txt in common and dir1 are empty.
>> So, either partially move your CMake scripts into these subdirectories,
>> or don't do `add_subdirectory()`. For example:
>> add_executable(exec dir1/src1.c dir1/src2.c dir1/src3.c)
>> target_include_directories(exec PRIVATE