Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 66 additions & 14 deletions PCLConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -632,21 +632,73 @@ 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 AND PCL_SHARED_LIBS)
# On Windows with shared libraries, .dll (runtime) and .lib (import library)
# are separate artifacts.
# 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)
mark_as_advanced(PCL_${COMPONENT}_DLL_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
Copy link

Copilot AI Feb 27, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +640 to +651
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newly introduced DLL path variables PCL_${COMPONENT}DLL_PATH and PCL${COMPONENT}DLL_PATH_DEBUG should be marked as advanced, similar to how other found paths like PCL${COMPONENT}_LIBRARY are marked at line 621. This follows the established pattern in the codebase and prevents these cache variables from cluttering the CMake GUI.

Copilot uses AI. Check for mistakes.
mark_as_advanced(PCL_${COMPONENT}_DLL_PATH_DEBUG)

if(PCL_${COMPONENT}_LIBRARY_DEBUG)
set_target_properties(${pcl_component}
PROPERTIES
IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
IMPORTED_IMPLIB_RELEASE "${PCL_${COMPONENT}_LIBRARY}"
IMPORTED_IMPLIB_DEBUG "${PCL_${COMPONENT}_LIBRARY_DEBUG}"
)
if(PCL_${COMPONENT}_DLL_PATH)
set_target_properties(${pcl_component} PROPERTIES
IMPORTED_LOCATION_RELEASE "${PCL_${COMPONENT}_DLL_PATH}")
else()
pcl_message(WARNING "Could not find release DLL for ${pcl_component}. Runtime path will not be set.")
endif()
if(PCL_${COMPONENT}_DLL_PATH_DEBUG)
set_target_properties(${pcl_component} PROPERTIES
IMPORTED_LOCATION_DEBUG "${PCL_${COMPONENT}_DLL_PATH_DEBUG}")
else()
pcl_message(WARNING "Could not find debug DLL for ${pcl_component}. Runtime path will not be set.")
endif()
else()
set_target_properties(${pcl_component}
PROPERTIES
IMPORTED_IMPLIB "${PCL_${COMPONENT}_LIBRARY}"
)
if(PCL_${COMPONENT}_DLL_PATH)
set_target_properties(${pcl_component} PROPERTIES
IMPORTED_LOCATION "${PCL_${COMPONENT}_DLL_PATH}")
else()
pcl_message(WARNING "Could not find DLL for ${pcl_component}. Runtime path will not be set.")
endif()
endif()
Comment on lines +654 to +684
Copy link

Copilot AI Feb 27, 2026

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.

Copilot uses AI. Check for mistakes.
else()
set_target_properties(${pcl_component}
PROPERTIES
IMPORTED_LOCATION "${PCL_${COMPONENT}_LIBRARY}"
IMPORTED_IMPLIB "${PCL_${COMPONENT}_LIBRARY}"
)
# On Linux/macOS/MINGW, or when PCL is built as static libraries,
# the library file is both the link-time and runtime artifact,
# so IMPORTED_LOCATION is sufficient.
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}"
)
else()
set_target_properties(${pcl_component}
PROPERTIES
IMPORTED_LOCATION "${PCL_${COMPONENT}_LIBRARY}"
)
endif()
endif()
else() # header-only
add_library(${pcl_component} INTERFACE IMPORTED)
Expand Down