I have a source layout like this:
project
|------ CMakeLists.txt (The TOP Cmake)
|------ Exe_C (For cortexM3)
| |----- CMakeList.txt
| |----- src
| | cortex_main.c
| |----- include
| | various.h files
|------ Exe_R (For RiscV)
| |----- CMakeList.txt
| |----- src
| | riscv_main.c
| |----- include
| | various.h files
|
|------ hardware_drivers
| |----- CMakeList.txt
| |----- include/driver
| | Generic .H driver files
| |----- src_generic
| | generic driver src
| |----- src_cortexM
| | cortexM3 only src
| |----- src_riscV
| | riscv only src
| ---- app_common
| |----- CMakeList.txt
| |----- src
| | common source files
| | for all exes
| |----- include
| | common include files
| | for all exes
|----- feature_FOO (also a Feature BAR)
| |----- CMakeList.txt
| |---- src
| | src files for FOO
| |---- include
| | src files for FOO
So the top level CMAKE file takes a command line -D EXE=EXE_C or -D EXE=EXE_C, then includes() not add_directory() a ${EXE_NAME}-config.cmake file that is unique to the specific app.
The intent is that ${EXE_NAME}-config.cmake knows what Drivers it needs, it knows what CPU it requires, and what DRIVER files it wants and what Features (FOO or BAR) that it should have.
By cmake-requirement, the TOP LEVEL Cmakefile must define a PROJECT().
The ${EXE_NAME}-config.cmake does an add_executable()
And the other CMake files are trying to add SOURCES to the executable but I cannot.
when I do, it says: Cannot specify sources for target “NAME” which is not built by this project. This fails for multiple directories…
Question# 1 is my structure ok? Or insane?
Question #2 – how can I print {for debug reason} the TARGET that it thinks it wants to build so that I can debug this? (I’ve spent several days and keep hitting the same problem/wall and it is painful}