I added the "if statement" check before the add_dependencies(), like you suggested and also added:

add_dependencies(ublox_gps ublox_msgs_generate_messages_cpp)

back to the ublox_gps/CMakeLists.txt file.


In the ublox_msgs/CMakeLists.txt file, why can you only use this:

add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_gencpp)

but not the following?

add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_generate_messages_cpp)