[build/cmake] Incorrect IMPORTED_LOCATION for Windows DLLs in PCL CMake config
Describe the bug
A CMake property is being incorrectly set on the PCL targets, causing $<TARGET_RUNTIME_DLLS:exe> CMake generator expressions to find PCL .libs when it should be the .dlls on Windows.
In PCLConfig.cmake.in, the following is done for PCL component targets:
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}"
)
else()
set_target_properties(${pcl_component}
PROPERTIES
IMPORTED_LOCATION "${PCL_${COMPONENT}_LIBRARY}"
IMPORTED_IMPLIB "${PCL_${COMPONENT}_LIBRARY}"
)
endif()
The IMPORTED_LOCATION properties above should be the location of the library DLL, but they're pointing to the .lib.
Context
$<TARGET_RUNTIME_DLLS:exe> CMake expressions provide a way to copy dependent DLLs when buildling/installing on Windows, making it convenient to deploy an app and it's dependencies together.
Expected behavior
The full path to any required PCL component .dll should be returned with a $<TARGET_RUNTIME_DLLS:exe> CMake expression.
Current Behavior
The path to the required PCL .lib is returned instead.
Your Environment (please complete the following information):
- OS: Windows 10
- Compiler: MSVC
- PCL Version 1.15.1
Possible Solution This fixes things for me locally on a Release build but would need updated to support debug, handling cases where the DLL is not found, etc.
Find the DLL for the PCL component:
set(PCL_DLL_DIR "${PCL_ROOT}/bin")
find_file(PCL_${COMPONENT}_DLL_PATH
NAMES ${pcl_component}.dll ${pcl_component}${PCL_RELEASE_SUFFIX}.dll ${pcl_component}${PCL_RELWITHDEBINFO_SUFFIX}.dll ${pcl_component}${PCL_MINSIZEREL_SUFFIX}.dll
HINTS ${PCL_DLL_DIR}
NO_DEFAULT_PATH)
Set IMPORTED_LOCATION with the found DLL:
else()
set_target_properties(${pcl_component}
PROPERTIES
IMPORTED_LOCATION "${PCL_${COMPONENT}_DLL_PATH}"
IMPORTED_IMPLIB "${PCL_${COMPONENT}_LIBRARY}"
)
endif()
@larshg @UnaNancyOwen Can you confirm? I am not familiar enough with Windows and the dll/lib system
Sorry, I don't have the development environment on hand, so I can't conform it right away. However, it seems like a valid point. We need to see if it actually works. Please create and submit pull request. (If possible, please attach a confirmation method.) Thanks,