Open traversaro opened 4 years ago
PR would need low effort, but the test setup might take time (and effort)
Its been around since its first introduction in https://github.com/PointCloudLibrary/pcl/pull/1401. I have not encountered many issues about this, either myself or here on the issue tracker for the last 5 years.
As I can read it disables the use of static runtime in debug mode, so you won't mix debug with librealsense release only build (maybe? just guessing). https://support.microsoft.com/en-gb/help/154753/description-of-the-default-c-and-c-libraries-that-a-program-will-link
So this also clarify why I rarely encounter it as I mostly compile with dynamic linking, which uses the MSVCRTD.lib.
But I agree in your assumptions that findXXLib should not add additional compiler/linker flags. Can be done later if it was found and is required.
So this also clarify why I rarely encounter it as I mostly compile with dynamic linking, which uses the MSVCRTD.lib.
Good catch, indeed I was compiling with shared library linking but with MTd
(i.e. static runtime), and that explain why I encountered the bug. As you can see in the error log, it seems that the linking error is on boost::unique_lock<class boost::mutex>
, so it may be possible that with past boost version this was not a problem.
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
~~~ The use of BOOST_*_ENDIAN and BOOST_BYTE_ORDER is deprecated. Please includeThis 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.