Firstly, check the name of your cpp files and make sure they are the same as in the CMakeList.txt;
Secondly, make sure add_dependencies() is called at the right place. If you have read carefully the CMakeList.txt, you will find two calls of add_dependencies() at different places. One is before add_executable() and the other is after. The first one is for "Add cmake target dependencies of the library ", and the later is for "Add cmake target dependencies of the executable".
It is clear that the call place of add_dependencies() depends on the type of your nodes.