[FindRSSDK] On MSVC, invoking find_package(RSSDK)
silently adds /NODEFAULTLIB:LIBCMTD to the linker flags
#4253
Labels
effort: low
Rough estimate of time needed to fix/implement/solve
good first issue
Skills/areas of expertise needed to tackle the issue
kind: bug
Type of issue
kind: todo
Type of issue
module: cmake
platform: windows
skill: cmake
Skills/areas of expertise needed to tackle the issue
Describe the bug
On MSVC, invoking
find_package(RSSDK)
silently adds /NODEFAULTLIB:LIBCMTD to the linker flags, due to this line:https://github.com/PointCloudLibrary/pcl/blob/pcl-1.11.0/cmake/Modules/FindRSSDK.cmake#L69 . It is not clear why that is needed, and it can create problems tricky to debug.
Context
I notice that line of code by inspection, and I found it strange that a
Find<pkg>.cmake
script modifies the linker flags even if the dependency is not actually used.Expected behavior
I would expect
Find<pkg>.cmake
not to have side effects beside setting variables and defining imported target.Current Behavior
Whenever
find_package(RSSDK)
is invoked, it silently adds/NODEFAULTLIB:LIBCMTD
to the linker flags, even ifRSSSDK
is not found.To Reproduce
The reported behaviour is dangerous in general, and it was found by inspection of the code and by a related problem on an not easy to reproduce system.
Screenshots/Code snippets
In order to help explain your problem, please consider adding
Your Environment (please complete the following information):
Possible Solution
Probably that line can be just removed, but it would be probably make sense to first test compilation with
RSSDK
enabled, if that is still supported.Additional context
I actually encountered this problem by compiling an old version of PCL with an old version of vcpkg with an old version of Visual Studio, in particular in that case the error was the following:
Click to see details
This is not something I was able to reproduce on a modern enviroment, but in any case that hidden
/NODEFAULTLIB:LIBCMTD
hidden can create problems also for other reasons. Also in that enviroment, it was sufficient to setENABLE_RSSDK
toOFF
to avoid the problem.The text was updated successfully, but these errors were encountered: