I’ve nearly got VTK compiling with most of the ThirdParty packages turned off. There’s a few errors that are keeping me from 100%, and I’m open to ideas on how to move past them.
The first is encountered in the IOMotionFX code. ThirdParty/pegtl/vtk_pegtl.h claims it can’t find ThirdParty/pegtl/vtk_pegtl.h. PEGTL is correctly found earlier in the process, and the include/library is set in the cache, so I’m sure it’s there, and available.
ThirdParty/pegtl/vtk_pegtl.h:22:23: fatal error: tao/pegtl/contrib/tracer.hpp: No such file or directory
22 | # define VTK_PEGTL(x) <tao/x>
The other error stems from the external libproj module. A similar error -
ThirdParty/libproj/vtk_libproj.h:38:11: fatal error: proj_api.h: No such file or directory
38 | # include <proj_api.h>
| ^~~~~~~~~~~~
Again, the proj include/lib is set in the cache, and this one seems internal to the libproj directory itself.
Before I start digging into the CMake myself I thought I’d see if this had popped up before.
I’m narrowing the errors down to what I suspect are a few misplaced properties on targets. In the IOMotionFX.dir directory I can edit the link.txt file to add the path
-IThirdParty/pegtl/vtkpegtl/include to the CXX_FLAGS inside the flags.txt and the IOMotionFX module builds fine.
I’m using the 9.0.1 from the release page on github. I can try master to see fi that resolves anything. Has there been a lot of time between that tag and HEAD?
Master seemed to build fine, save for that one include. I’m building it as an external package, and here was the failure in the build-err.log
In file included from /home/bentleykw/src/SupportPackages/build/vtk/src/vtk/IO/MotionFX/vtkMotionFXCFGGrammar.h:22,
from /home/bentleykw/src/SupportPackages/build/vtk/src/vtk/IO/MotionFX/vtkMotionFXCFGReader.cxx:40:
/home/bentleykw/src/SupportPackages/build/vtk/src/vtk-build/ThirdParty/pegtl/vtk_pegtl.h:22:23: fatal error: tao/pegtl/contrib/tracer.hpp: No such file or directory
# define VTK_PEGTL(x) <tao/x>
^
to the end of /home/bentleykw/src/SupportPackages/build/vtk/src/vtk-build/IO/MotionFX/CMakeFiles/IOMotionFX.dir/flags.make, which I believe translates to
I still think there’s probably a target or include directory that’s missing or misplaced in the IO/MotionFX dir somewhere, but that gets me going. All other dependencies are local.
Just to add a little bit more, in the ThirdParty/vtkpegtl CMakeListst.txt, the comment below raises a little suspicion as to why it’s not finding the headers.
# features used by the PEGTL
target_compile_features(pegtl
INTERFACE
cxx_std_11)
# Not installing headers explicitly. This is not meant to be part of the VTK API.
It only answers it if the code trying to use it is outside of VTK. If that’s the case, yes, pegtl is not a public third party dependency of VTK. If it is code inside of VTK that is failing, something else is going wrong (though it works just fine in our CI with an external pegtl).
I also encountered the issue described in the opening thread. On Gentoo Linux we’re restricting pegtl to versions <3, because VTK didn’t build with >=pegtl-3, but I never cared too much about digging into it. We had a PR, later reverted, which included a patch for this[1], however I never tested whether the patch works due to it’s immediate revert.
While packaging v9.2.2, I was trying whether I could update the dependency to versions >=3 and found this error, using pegtl-3.2.5 or pegtl-3.2.1.
So it looks like VTK needs >=pegtl-2.0.0 but is actually not compatible with >=pegtl-3, or at least >=pegtl-3.2. Building against 2.8.3, which is also available on Gentoo works.
Is your CI running against the same version as the internal pegtl library, i.e. 2.8.3? Or have you tried building against a newer version (>=3) of an external pegtl?
If VTK is restricted to versions of pegtl <3, is there a way in the cmake logic, to not only provide a minimum version, but also a maximum version?
I think specifying 2.8...2.9999 might work. Would need testing.
Our external libraries CI is on Fedora 34, so it might not have pegtl 3. Looking, I see that even Fedora 38 has 2.8.3…not sure of the reason there (probably similar issues Gentoo is seeing?). Looks like it according to this issue.
I tested this and changed VERSION 2.0.0 to VERSION 2.0.0...2.9999 in the EXTERNAL section of vtk_module_third_party in ThirdParty/pegtl/CMakeLists.txt. This results in a warning
CMake Warning (dev) at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:447 (message):
`find_package()` specify a version range but the module PEGTL does not
support this capability. Only the lower endpoint of the range will be
used.
Call Stack (most recent call first):
CMake/FindPEGTL.cmake:38 (find_package_handle_standard_args)
CMake/vtkModule.cmake:4572 (find_package)
CMake/vtkModule.cmake:5172 (vtk_module_find_package)
CMake/vtkModule.cmake:5043 (vtk_module_third_party_external)
ThirdParty/pegtl/CMakeLists.txt:1 (vtk_module_third_party)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found PEGTL: /usr/include/tao (found suitable version "3.2.5", minimum required is "2.0.0")
It looks like the CMake/FindPEGTL.cmake module has to be adapted as well to accept a version range, but should be possible to use this syntax.
Being a header only library, it makes me wonder they couldn’t update. Thought this would be a lot easier on a binary distribution than in a source based distribution as the package only needs to be available on the package maintainers machine at build time. We also have only usbguard as the only other package in the main tree which needs pegtl, which has been updated to support pegtl-3.
I will test whether the patch I mentioned above will build and then see how to handle this further.