pcl
pcl copied to clipboard
Can't link pcl components while compiling with RelWithDebInfo
Describe the bug
When compiling PCL with CMAKE_BUILD_TYPE to RelWithDebInfo, PCLConfig.cmake doesn't find pcl components.
Expected behavior
I would expect that the find_library in PCLConfig would also search for ${pcl_component}rd
Current Behavior
The find_library only search for Debug and Release suffixes.
To Reproduce
Build PCL with RelWithDebInfo and then link it to your project.
Your Environment:
- OS: Windows 11
- Compiler: VS 2019
- PCL Version 1.11 but I don't think this is resolved on master
Edit: I think the same would happen with MinSizeRel build
Edit2: This bug is only on Windows build
@Faroito What is the exact error message you get? Can you perhaps post CMake's log?
I get a lot of undefined references such as error LNK2019: unresolved external symbol "void __cdecl pcl::console::print(enum pcl::console::VERBOSITY_LEVEL,char const *,...)" (?print@console@pcl@@YAXW4VERBOSITY_LEVEL@12@PEBDZZ) referenced in function "protected: virtual void __cdecl pcl::IterativeClosestPoint<struct pcl::PointXYZ,struct when compiling my project against PCL
None of the pcl libraries are in PCL_LIBRARIES cmake variable.
To fix it, I added
set(PCL_RELWITHDEBINFO_SUFFIX "@CMAKE_RELWITHDEBINFO_POSTFIX@")
and
find_library(PCL_${COMPONENT}_LIBRARY ${pcl_component}${PCL_RELWITHDEBINFO_SUFFIX}
HINTS ${PCL_LIBRARY_DIRS}
DOC "path to ${pcl_component} library RelWithDebInfo"
NO_DEFAULT_PATH)
in PCLConfig.cmake.in
I can make a pull request if needed
Adding code in PCLConfig.cmake.in for RelWithDebInfo and MinSizeRel sounds logical to me, but I don't really have experience with Windows, so tagging @larshg and @UnaNancyOwen
Anyway I think what you suggested isn't sufficient yet: cmake would have to check which of the four library types are available and set the target properties of ${pcl_component} accordingly. In your suggestion, RelWithDebInfo would simply overwrite Release, correct?
Possibly related: https://github.com/PointCloudLibrary/pcl/pull/3055
Anyway I think what you suggested isn't sufficient yet: cmake would have to check which of the four library types are available and set the target properties of ${pcl_component} accordingly. In your suggestion, RelWithDebInfo would simply overwrite Release, correct?
That is right, I just did a quick fix for my use case.
Fixed by https://github.com/PointCloudLibrary/pcl/pull/6089