Fails to build with PROJ 8.0.0 (proj_api.h removed)
Follow up to #17554 (closed).
VTK fails to build with PROJ 8.0.0 which has removed proj_api.h
.
While suppport for proj.h
has been added, proj_api.h
is also still used:
#if VTK_MODULE_USE_EXTERNAL_vtklibproj
# if VTK_LibPROJ_MAJOR_VERSION >= 5
# include <proj.h>
# endif
# if VTK_LibPROJ_MAJOR_VERSION < 6
# include <projects.h>
# endif
# if VTK_LibPROJ_MAJOR_VERSION >= 6
# define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H 1
# endif
# include <proj_api.h>
# include <geodesic.h>
#else
# include <vtklibproj/src/projects.h>
# include <vtklibproj/src/proj_api.h>
# include <vtklibproj/src/geodesic.h>
#endif
Restricting this to only use proj.h
shows that the code still relies on proj_api.h
features and has not been properly ported to the PROJ 6 API:
/build/vtk9-9.0.1+dfsg1/Geovis/Core/vtkGeoProjection.cxx: In destructor 'virtual vtkGeoProjection::~vtkGeoProjection()':
/build/vtk9-9.0.1+dfsg1/Geovis/Core/vtkGeoProjection.cxx:124:5: error: 'pj_free' was not declared in this scope; did you mean 'free'?
124 | pj_free(this->Projection);
| ^~~~~~~
| free
/build/vtk9-9.0.1+dfsg1/Geovis/Core/vtkGeoProjection.cxx: In member function 'virtual int vtkGeoProjection::UpdateProjection()':
/build/vtk9-9.0.1+dfsg1/Geovis/Core/vtkGeoProjection.cxx:188:5: error: 'pj_free' was not declared in this scope; did you mean 'free'?
188 | pj_free(this->Projection);
| ^~~~~~~
| free
/build/vtk9-9.0.1+dfsg1/Geovis/Core/vtkGeoProjection.cxx:194:24: error: 'pj_init_plus' was not declared in this scope
194 | this->Projection = pj_init_plus(this->PROJ4String);
| ^~~~~~~~~~~~
/build/vtk9-9.0.1+dfsg1/Geovis/Core/vtkGeoProjection.cxx:234:24: error: 'pj_init' was not declared in this scope; did you mean 'u_int'?
234 | this->Projection = pj_init(argSize, const_cast<char**>(pjArgs));
| ^~~~~~~
| u_int
make[4]: *** [Geovis/Core/CMakeFiles/GeovisCore.dir/build.make:111: Geovis/Core/CMakeFiles/GeovisCore.dir/vtkGeoProjection.cxx.o] Error 1
The following patch was used to test the build with PROJ 8.0.0:
--- a/ThirdParty/libproj/vtk_libproj.h.in
+++ b/ThirdParty/libproj/vtk_libproj.h.in
@@ -32,10 +32,10 @@
# if VTK_LibPROJ_MAJOR_VERSION < 6
# include <projects.h>
# endif
-# if VTK_LibPROJ_MAJOR_VERSION >= 6
+# if VTK_LibPROJ_MAJOR_VERSION >= 6 && VTK_LibPROJ_MAJOR_VERSION < 8
# define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H 1
+# include <proj_api.h>
# endif
-# include <proj_api.h>
# include <geodesic.h>
#else
# include <vtklibproj/src/projects.h>