diff --git a/PCLConfig.cmake.in b/PCLConfig.cmake.in index 851f5f1377a..32189f7168d 100644 --- a/PCLConfig.cmake.in +++ b/PCLConfig.cmake.in @@ -448,6 +448,21 @@ else(PCL_FIND_COMPONENTS) set(PCL_FIND_ALL 1) endif(PCL_FIND_COMPONENTS) +# We do not need to find components that have been found already, e.g. during previous invocation +# of find_package(PCL). Filter them out. +foreach(component ${PCL_TO_FIND_COMPONENTS}) + string(TOUPPER "${component}" COMPONENT) + if(NOT PCL_${COMPONENT}_FOUND) + list(APPEND _PCL_TO_FIND_COMPONENTS ${component}) + endif() +endforeach() +set(PCL_TO_FIND_COMPONENTS ${_PCL_TO_FIND_COMPONENTS}) +unset(_PCL_TO_FIND_COMPONENTS) + +if(NOT PCL_TO_FIND_COMPONENTS) + return() +endif() + compute_dependencies(PCL_TO_FIND_COMPONENTS) # compute external dependencies per component