Skip to content

Commit 9a87106

Browse files
authored
Fix searching for dll paths, instead of adding .lib path. (#6410)
* Fix searching for dll paths, instead of adding .lib path. * Remove dublicated $. Wrap dll search for windows in "if WIN32". * Don't special case io_ply as it is inserted as a component earlier. * Address suggestion from copilot.
1 parent 8273409 commit 9a87106

File tree

1 file changed

+66
-14
lines changed

1 file changed

+66
-14
lines changed

PCLConfig.cmake.in

Lines changed: 66 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -632,21 +632,73 @@ foreach(component ${PCL_TO_FIND_COMPONENTS})
632632
endforeach()
633633
if(_is_header_only EQUAL -1)
634634
add_library(${pcl_component} @PCL_LIB_TYPE@ IMPORTED)
635-
if(PCL_${COMPONENT}_LIBRARY_DEBUG)
636-
set_target_properties(${pcl_component}
637-
PROPERTIES
638-
IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
639-
IMPORTED_LOCATION_RELEASE "${PCL_${COMPONENT}_LIBRARY}"
640-
IMPORTED_LOCATION_DEBUG "${PCL_${COMPONENT}_LIBRARY_DEBUG}"
641-
IMPORTED_IMPLIB_RELEASE "${PCL_${COMPONENT}_LIBRARY}"
642-
IMPORTED_IMPLIB_DEBUG "${PCL_${COMPONENT}_LIBRARY_DEBUG}"
643-
)
635+
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.
639+
# find dll paths
640+
find_file(PCL_${COMPONENT}_DLL_PATH
641+
NAMES
642+
${pcl_component}${PCL_RELEASE_SUFFIX}.dll
643+
${pcl_component}${PCL_RELWITHDEBINFO_SUFFIX}.dll
644+
${pcl_component}${PCL_MINSIZEREL_SUFFIX}.dll
645+
HINTS "${PCL_ROOT}/bin"
646+
NO_DEFAULT_PATH)
647+
mark_as_advanced(PCL_${COMPONENT}_DLL_PATH)
648+
find_file(PCL_${COMPONENT}_DLL_PATH_DEBUG
649+
NAMES ${pcl_component}${PCL_DEBUG_SUFFIX}.dll
650+
HINTS "${PCL_ROOT}/bin"
651+
NO_DEFAULT_PATH)
652+
mark_as_advanced(PCL_${COMPONENT}_DLL_PATH_DEBUG)
653+
654+
if(PCL_${COMPONENT}_LIBRARY_DEBUG)
655+
set_target_properties(${pcl_component}
656+
PROPERTIES
657+
IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
658+
IMPORTED_IMPLIB_RELEASE "${PCL_${COMPONENT}_LIBRARY}"
659+
IMPORTED_IMPLIB_DEBUG "${PCL_${COMPONENT}_LIBRARY_DEBUG}"
660+
)
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()
673+
else()
674+
set_target_properties(${pcl_component}
675+
PROPERTIES
676+
IMPORTED_IMPLIB "${PCL_${COMPONENT}_LIBRARY}"
677+
)
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()
684+
endif()
644685
else()
645-
set_target_properties(${pcl_component}
646-
PROPERTIES
647-
IMPORTED_LOCATION "${PCL_${COMPONENT}_LIBRARY}"
648-
IMPORTED_IMPLIB "${PCL_${COMPONENT}_LIBRARY}"
649-
)
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.
689+
if(PCL_${COMPONENT}_LIBRARY_DEBUG)
690+
set_target_properties(${pcl_component}
691+
PROPERTIES
692+
IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
693+
IMPORTED_LOCATION_RELEASE "${PCL_${COMPONENT}_LIBRARY}"
694+
IMPORTED_LOCATION_DEBUG "${PCL_${COMPONENT}_LIBRARY_DEBUG}"
695+
)
696+
else()
697+
set_target_properties(${pcl_component}
698+
PROPERTIES
699+
IMPORTED_LOCATION "${PCL_${COMPONENT}_LIBRARY}"
700+
)
701+
endif()
650702
endif()
651703
else() # header-only
652704
add_library(${pcl_component} INTERFACE IMPORTED)

0 commit comments

Comments
 (0)