I think the variable is probably defined, but empty, both cases produce an error...

A compromise might be to have that variable always contain a phony target which is immediately satisfied (so it doesn't mess with build order), but which allows the `catkin_EXPORTED_TARGETS` variable to always be set to something valid.

That way it's one call, and we don't have to wrap standard CMake code.

I would also note that the `catkin_simple` prototype addresses this by automatically checking the variable and adding the dependencies, but it can only do that because it has a list of all of the targets created, because it wraps all of the CMake `add_*` calls. See:

https://github.com/wjwwood/catkin_simple/blob/master/cmake/catkin_simple-extras.cmake.em#L90

If CMake kept track of targets in a project we could do something like this, but even if we were to get this into CMake we would be talking about 2014 at the earliest before we could depend on that version of CMake and to do so would break backwards compatibility with older versions of Ubuntu. So this is something we can pursue, but not something we can rely on solving the problem in the near future.