-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use COMPONENTS
when finding VTK to avoid linking agains unnecessary modules
#3140
Use COMPONENTS
when finding VTK to avoid linking agains unnecessary modules
#3140
Conversation
Ping for test builds if you have time @UnaNancyOwen @SunBlack @claudiofantacci |
I'll test this tomorrow. Ping me otherwise 👍 |
//EDIT: Got compile issue with MSVC 19.16 (debug & release) & VTK 8.2 (didn't saw the error message first, because of a CUDA issue).
Components I build:
Compilation failed for |
Failing on my macOS 10.13.6 with standard options with the following error:
However, it seems that the error is related to Compilation went just fine on mi side with standard options 👍 Compilation fails if I enable
|
cmake/Modules/FindQVTK.cmake
Outdated
@@ -10,6 +10,7 @@ | |||
if(";${VTK_MODULES_ENABLED};" MATCHES ";vtkGUISupportQt;" AND ";${VTK_MODULES_ENABLED};" MATCHES ";vtkRenderingQt;") | |||
set(VTK_USE_QVTK ON) | |||
set(QVTK_LIBRARY vtkRenderingQt vtkGUISupportQt) | |||
list(APPEND PCL_VTK_COMPONENTS vtkRenderingQt vtkGUISupportQt) | |||
else() | |||
unset(QVTK_FOUND) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QVTK_FOUND
will by only unset, but never set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, but it's not used anywhere in the project, so I suppose I'll just drop this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or, I'd rather drop VTK_USE_QVTK
and switch to using VTK_FOUND
in other places.
@@ -367,6 +388,8 @@ if(WITH_VTK AND NOT ANDROID) | |||
# safe to assume OpenGL backend | |||
set(VTK_RENDERING_BACKEND "OpenGL") | |||
endif() | |||
list(APPEND PCL_VTK_COMPONENTS vtkRenderingContext${VTK_RENDERING_BACKEND}) | |||
find_package(VTK COMPONENTS ${PCL_VTK_COMPONENTS}) | |||
message(STATUS "VTK_MAJOR_VERSION ${VTK_MAJOR_VERSION}, rendering backend: ${VTK_RENDERING_BACKEND}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include(${VTK_USE_FILE})
will be only called in case (PCL_SHARED_LIBS OR (NOT (PCL_SHARED_LIBS) AND NOT (VTK_BUILD_SHARED_LIBS)))
returns true., Shouldn't it be always? (You removed some other calls to this include, so it could be an issue now).
//Edit: Just didn't noticed else
tree of this code, that VTK
will be disabled otherwise. Nevertheless this whole code block should be checked. E.g. HAVE_VTK
is undefined in case WITH_VTK
is true, but VTK was not found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E.g. HAVE_VTK is undefined in case WITH_VTK is true, but VTK was not found.
I think this is okay because undefined variables evaluate to false in conditionals.
@claudiofantacci thanks for giving this a try. Let's indeed branch out the OpenMP and CUDA errors to separate issues. @SunBlack also thanks for checking. Unfortunately I can not reproduce your problem on Ubuntu, both In the meantime, I pushed an update that merges |
I had rebuild it today again from scratch and I just had CUDA errors left. When #3152 is merged (and merged into this branch), I can check it again (tomorrow or monday). |
This file is already included in the top-level CMakeLists.
This involves a few smaller changes: * only look for QVTK if Qt itself is enabled * use QVTK_FOUND instead of VTK_USE_QVTK do determine QVTK availability in the rest of the scripts * drop QVTK_LIBRARY since QVTK components are now together with the rest and are linked into pcl_visualization
Rebased on top of current master, ready for new testing. |
This is building for me on OS X. Cannot try CUDA without the commits on #3131. |
Hm, seems like there is a problem when using with non-system VTK (8.2). Although I don't get any linker errors, trying to run binaries results in:
When I build with system VTK (6.3), there is no problem. Looks like linker directories are not properly set... will need to investigate further. |
This has nothing to do with the PR and also affects master. On newer Ubuntu versions the following use-case is not working:
This thread (esp. comment 4) provides an excellent summary of what's wrong, I couldn't explain better. Not sure what to do about this at the moment. But it should not block this PR. |
|
|
Which means, it will need to be fixed patched upstream. Well, something to keep in mind when users come reporting issues related to this. |
It's more complicated than that. I'm not an expert, but as far as I understand generally you don't want to set RPATH on installed libraries, so the default CMake setting is to clear RPATH when installing. So it's not a bug in VTK really, it's by design. What I'm missing is an option to override this behavior for such case as mine. Maybe there is a way and I just haven't found it yet. |
Wouldn't setting |
Release build works and Debug just has a compile error, which is not related to this PR. So everything seems to be fine :)
|
Yep. It's off: $ grep "INSTALL_RPATH:BOOL" < CMakeCache.txt
CMAKE_SKIP_INSTALL_RPATH:BOOL=NO However during installation RPATH is net to
@SunBlack thanks! |
Is Edit: It probably is not set, otherwise it would have been picked up in your grep. |
No, it's not set. If I specify it explicitly: cmake .. -DCMAKE_INSTALL_RPATH=/opt/vtk-8.2.0/lib Then installed libs get RUNPATH set as expected: $ readelf -d /opt/vtk-8.2.0/lib/libvtkCommonCore-8.2.so.1 | grep PATH
0x000000000000001d (RUNPATH) Library runpath: [/opt/vtk-8.2.0/lib] And I can run PCL executables. So we have a hacky solution to offer people, though it's not a PCL problem per se. |
COMPONENTS
when finding VTK to avoid linking agains unnecessary modules
This supersedes #3032 and partially addresses #2969.
Unlike #3032 I decided to not split VTK components in separate dependency lists for IO and Visualization modules. First reason: there would need to be too many of such lists, because in fact Surface module also needs some VTK components, as well as some of the binaries in Tools. Second reason: even if we employ separate lists, it will only improve linking during library build. Once it comes down to
PCLConfig
, there are no mechanics in place to separate which VTK components are needed by which target, thus no gain for downstream projects.For future reference, this is how I found the list of required VTK components. First I set the list to only include something obvious, e.g.
vtkCommonCore
. Then I built the library withninja -k 0 > /tmp/errors
to get errors about undefined references in all libs and executables. Finally, the errors were passed through the following script:This finds all undefined classes, searches in VTK shared objects, and outputs the list of SO files where the missing symbols were found.
This PR also includes a couple of minor cleanup commits.
I tested this on my Ubuntu workstation with both system VTK (6.3) and self-built VTK (8.2). The library with all options on successfully builds, as well as some of my downstream projects that I tried. It would be great if someone with Windows also gives this a try.
Edit: Closes #3032