@@ -633,8 +633,9 @@ foreach(component ${PCL_TO_FIND_COMPONENTS})
633633 if (_is_header_only EQUAL -1)
634634 add_library (${pcl_component} @PCL_LIB_TYPE@ IMPORTED )
635635
636- if (WIN32 AND NOT MINGW)
637- # On Windows, shared libraries are split into .dll (runtime) and .lib (import library).
636+ if (WIN32 AND NOT MINGW AND PCL_SHARED_LIBS)
637+ # On Windows with shared libraries, .dll (runtime) and .lib (import library)
638+ # are separate artifacts.
638639 # find dll paths
639640 find_file (PCL_${COMPONENT}_DLL_PATH
640641 NAMES
@@ -643,30 +644,48 @@ foreach(component ${PCL_TO_FIND_COMPONENTS})
643644 ${pcl_component}${PCL_MINSIZEREL_SUFFIX} .dll
644645 HINTS "${PCL_ROOT} /bin"
645646 NO_DEFAULT_PATH )
647+ mark_as_advanced (PCL_${COMPONENT}_DLL_PATH )
646648 find_file (PCL_${COMPONENT}_DLL_PATH_DEBUG
647649 NAMES ${pcl_component}${PCL_DEBUG_SUFFIX} .dll
648650 HINTS "${PCL_ROOT} /bin"
649651 NO_DEFAULT_PATH )
652+ mark_as_advanced (PCL_${COMPONENT}_DLL_PATH_DEBUG )
650653
651654 if (PCL_${COMPONENT} _LIBRARY_DEBUG)
652655 set_target_properties (${pcl_component}
653656 PROPERTIES
654657 IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
655- IMPORTED_LOCATION_RELEASE "${PCL_${COMPONENT} _DLL_PATH}"
656- IMPORTED_LOCATION_DEBUG "${PCL_${COMPONENT} _DLL_PATH_DEBUG}"
657658 IMPORTED_IMPLIB_RELEASE "${PCL_${COMPONENT} _LIBRARY}"
658659 IMPORTED_IMPLIB_DEBUG "${PCL_${COMPONENT} _LIBRARY_DEBUG}"
659660 )
661+ if (PCL_${COMPONENT} _DLL_PATH)
662+ set_target_properties (${pcl_component} PROPERTIES
663+ IMPORTED_LOCATION_RELEASE "${PCL_${COMPONENT} _DLL_PATH}" )
664+ else ()
665+ pcl_message (WARNING "Could not find release DLL for ${pcl_component} . Runtime path will not be set." )
666+ endif ()
667+ if (PCL_${COMPONENT} _DLL_PATH_DEBUG)
668+ set_target_properties (${pcl_component} PROPERTIES
669+ IMPORTED_LOCATION_DEBUG "${PCL_${COMPONENT} _DLL_PATH_DEBUG}" )
670+ else ()
671+ pcl_message (WARNING "Could not find debug DLL for ${pcl_component} . Runtime path will not be set." )
672+ endif ()
660673 else ()
661674 set_target_properties (${pcl_component}
662675 PROPERTIES
663- IMPORTED_LOCATION "${PCL_${COMPONENT} _DLL_PATH}"
664676 IMPORTED_IMPLIB "${PCL_${COMPONENT} _LIBRARY}"
665677 )
678+ if (PCL_${COMPONENT} _DLL_PATH)
679+ set_target_properties (${pcl_component} PROPERTIES
680+ IMPORTED_LOCATION "${PCL_${COMPONENT} _DLL_PATH}" )
681+ else ()
682+ pcl_message (WARNING "Could not find DLL for ${pcl_component} . Runtime path will not be set." )
683+ endif ()
666684 endif ()
667685 else ()
668- # On Linux/macOS/MINGW, the shared library (.so/.dylib) is both the
669- # link-time and runtime artifact, so IMPORTED_LOCATION is sufficient.
686+ # On Linux/macOS/MINGW, or when PCL is built as static libraries,
687+ # the library file is both the link-time and runtime artifact,
688+ # so IMPORTED_LOCATION is sufficient.
670689 if (PCL_${COMPONENT} _LIBRARY_DEBUG)
671690 set_target_properties (${pcl_component}
672691 PROPERTIES
0 commit comments