-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Fix searching for dll paths, instead of adding .lib path. #6410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -632,21 +632,70 @@ foreach(component ${PCL_TO_FIND_COMPONENTS}) | |||||||||||||||||||||||||||||||
| endforeach() | ||||||||||||||||||||||||||||||||
| if(_is_header_only EQUAL -1) | ||||||||||||||||||||||||||||||||
| add_library(${pcl_component} @PCL_LIB_TYPE@ IMPORTED) | ||||||||||||||||||||||||||||||||
| if(PCL_${COMPONENT}_LIBRARY_DEBUG) | ||||||||||||||||||||||||||||||||
| set_target_properties(${pcl_component} | ||||||||||||||||||||||||||||||||
| PROPERTIES | ||||||||||||||||||||||||||||||||
| IMPORTED_CONFIGURATIONS "RELEASE;DEBUG" | ||||||||||||||||||||||||||||||||
| IMPORTED_LOCATION_RELEASE "${PCL_${COMPONENT}_LIBRARY}" | ||||||||||||||||||||||||||||||||
| IMPORTED_LOCATION_DEBUG "${PCL_${COMPONENT}_LIBRARY_DEBUG}" | ||||||||||||||||||||||||||||||||
| IMPORTED_IMPLIB_RELEASE "${PCL_${COMPONENT}_LIBRARY}" | ||||||||||||||||||||||||||||||||
| IMPORTED_IMPLIB_DEBUG "${PCL_${COMPONENT}_LIBRARY_DEBUG}" | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if(WIN32 AND NOT MINGW) | ||||||||||||||||||||||||||||||||
| # On Windows, shared libraries are split into .dll (runtime) and .lib (import library). | ||||||||||||||||||||||||||||||||
| # find dll paths | ||||||||||||||||||||||||||||||||
| find_file(PCL_${COMPONENT}_DLL_PATH | ||||||||||||||||||||||||||||||||
| NAMES | ||||||||||||||||||||||||||||||||
| ${pcl_component}${PCL_RELEASE_SUFFIX}.dll | ||||||||||||||||||||||||||||||||
| ${pcl_component}${PCL_RELWITHDEBINFO_SUFFIX}.dll | ||||||||||||||||||||||||||||||||
| ${pcl_component}${PCL_MINSIZEREL_SUFFIX}.dll | ||||||||||||||||||||||||||||||||
| HINTS "${PCL_ROOT}/bin" | ||||||||||||||||||||||||||||||||
| NO_DEFAULT_PATH) | ||||||||||||||||||||||||||||||||
| find_file(PCL_${COMPONENT}_DLL_PATH_DEBUG | ||||||||||||||||||||||||||||||||
| NAMES ${pcl_component}${PCL_DEBUG_SUFFIX}.dll | ||||||||||||||||||||||||||||||||
| HINTS "${PCL_ROOT}/bin" | ||||||||||||||||||||||||||||||||
| NO_DEFAULT_PATH) | ||||||||||||||||||||||||||||||||
|
Comment on lines
+640
to
+651
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if ("${component}" STREQUAL "io") | ||||||||||||||||||||||||||||||||
| find_file(PCL_${COMPONENT}_DLL_PATH | ||||||||||||||||||||||||||||||||
| NAMES | ||||||||||||||||||||||||||||||||
| pcl_io_ply${PCL_RELEASE_SUFFIX}.dll | ||||||||||||||||||||||||||||||||
| pcl_io_ply${PCL_RELWITHDEBINFO_SUFFIX}.dll | ||||||||||||||||||||||||||||||||
| pcl_io_ply${PCL_MINSIZEREL_SUFFIX}.dll | ||||||||||||||||||||||||||||||||
| HINTS "${PCL_ROOT}/bin" | ||||||||||||||||||||||||||||||||
| NO_DEFAULT_PATH) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| find_file(PCL_${COMPONENT}_DLL_PATH_DEBUG | ||||||||||||||||||||||||||||||||
| NAMES ${pcl_component}${PCL_DEBUG_SUFFIX}.dll | ||||||||||||||||||||||||||||||||
| HINTS "${PCL_ROOT}/bin" | ||||||||||||||||||||||||||||||||
| NO_DEFAULT_PATH) | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
| if ("${component}" STREQUAL "io") | |
| find_file(PCL_${COMPONENT}_DLL_PATH | |
| NAMES | |
| pcl_io_ply${PCL_RELEASE_SUFFIX}.dll | |
| pcl_io_ply${PCL_RELWITHDEBINFO_SUFFIX}.dll | |
| pcl_io_ply${PCL_MINSIZEREL_SUFFIX}.dll | |
| HINTS "${PCL_ROOT}/bin" | |
| NO_DEFAULT_PATH) | |
| find_file(PCL_${COMPONENT}_DLL_PATH_DEBUG | |
| NAMES ${pcl_component}${PCL_DEBUG_SUFFIX}.dll | |
| HINTS "${PCL_ROOT}/bin" | |
| NO_DEFAULT_PATH) | |
| endif() |
Copilot
AI
Feb 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code doesn't handle the case where only debug libraries and DLLs are available (analogous to lines 588-590 for .lib files). When only debug is available, PCL_${COMPONENT}LIBRARY_DEBUG will be set, causing the code to enter the dual-configuration branch at line 667. However, PCL${COMPONENT}_DLL_PATH (release) may not be found, leading to an empty or NOTFOUND value being set for IMPORTED_LOCATION_RELEASE.
Consider adding similar fallback logic for DLL paths: if PCL_${COMPONENT}DLL_PATH is not found but PCL${COMPONENT}_DLL_PATH_DEBUG is found, use the debug DLL path as a fallback for release builds on Windows.
Outdated
Copilot
AI
Feb 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The DLL search logic should only be applied when PCL is built as shared libraries. When PCL is built as static libraries (PCL_SHARED_LIBS is OFF), there are no DLLs to find, and the code should use the .lib files for IMPORTED_LOCATION instead.
Consider wrapping the DLL search and the Windows-specific set_target_properties calls in a condition that checks PCL_SHARED_LIBS. When PCL_SHARED_LIBS is OFF, the Windows path should behave like the non-Windows path at lines 684-698, using PCL_${COMPONENT}_LIBRARY for IMPORTED_LOCATION.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The find_file results for DLL paths are not validated before being used in set_target_properties. If a DLL is not found, the variables PCL_${COMPONENT}DLL_PATH or PCL${COMPONENT}_DLL_PATH_DEBUG will be empty or set to NOTFOUND, which could result in invalid IMPORTED_LOCATION properties.
Consider adding validation after the find_file calls, such as checking if the variables are defined and not empty, and providing appropriate error messages or fallback behavior if the DLLs cannot be found. This is especially important for shared library builds on Windows where the DLLs are required for runtime.