cmake: fix a nasty bug in our CMake files

before adding a potentially empty list of targets or dependencies, we
first have to test on the length of the list;
this finally closes #131 (we really have to do these checks)