1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-21 10:13:43 +03:00

0031582: Configuration, CMake - OCCT fails to build with VTK 9.0

Handle "VTK::" prefix instead of "vtk" used by previous VTK versions for targets.
Corrected unexpected location of endif() and broken indentation.
Obsolete $VTK_USE_FILE is no more included (basing on VTK version check).

Standard_WarningsDisable.hxx/Standard_WarningsRestore.hxx pair is now used to suppress VTK warnings instead of partial disabling.
This commit is contained in:
kgv 2020-08-17 12:58:31 +03:00 committed by bugmaster
parent ce9aefc8aa
commit 8e16477b50
13 changed files with 110 additions and 131 deletions

View File

@ -323,7 +323,7 @@ endif()
# Update list of used VTK libraries if OpenGL2 Rendering BackEnd is used. # Update list of used VTK libraries if OpenGL2 Rendering BackEnd is used.
# Add VTK_OPENGL2_BACKEND definition. # Add VTK_OPENGL2_BACKEND definition.
if("${VTK_RENDERING_BACKEND}" STREQUAL "OpenGL2") if("${VTK_RENDERING_BACKEND}" STREQUAL "OpenGL2" OR IS_VTK_9XX)
add_definitions(-DVTK_OPENGL2_BACKEND) add_definitions(-DVTK_OPENGL2_BACKEND)
foreach (VTK_EXCLUDE_LIBRARY vtkRenderingOpenGL vtkRenderingFreeTypeOpenGL) foreach (VTK_EXCLUDE_LIBRARY vtkRenderingOpenGL vtkRenderingFreeTypeOpenGL)
list (FIND USED_TOOLKITS_BY_CURRENT_PROJECT "${VTK_EXCLUDE_LIBRARY}" IS_VTK_OPENGL_FOUND) list (FIND USED_TOOLKITS_BY_CURRENT_PROJECT "${VTK_EXCLUDE_LIBRARY}" IS_VTK_OPENGL_FOUND)
@ -347,6 +347,9 @@ else()
endif() endif()
if (BUILD_SHARED_LIBS) if (BUILD_SHARED_LIBS)
if(IS_VTK_9XX)
string (REGEX REPLACE "vtk" "VTK::" USED_TOOLKITS_BY_CURRENT_PROJECT "${USED_TOOLKITS_BY_CURRENT_PROJECT}")
endif()
target_link_libraries (${PROJECT_NAME} ${USED_TOOLKITS_BY_CURRENT_PROJECT} ${USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT}) target_link_libraries (${PROJECT_NAME} ${USED_TOOLKITS_BY_CURRENT_PROJECT} ${USED_EXTERNAL_LIBS_BY_CURRENT_PROJECT})
endif() endif()

View File

@ -66,10 +66,15 @@ if (3RDPARTY_VTK_DIR AND EXISTS "${3RDPARTY_VTK_DIR}")
set (ENV{VTK_DIR} ${CACHED_VTK_DIR}) set (ENV{VTK_DIR} ${CACHED_VTK_DIR})
endif() endif()
unset (IS_VTK_9XX)
if (VTK_FOUND) if (VTK_FOUND)
message ("VTK version (${VTK_VERSION})")
if(VTK_MAJOR_VERSION EQUAL 8 AND VTK_MINOR_VERSION GREATER 9 OR VTK_MAJOR_VERSION GREATER 8)
set (IS_VTK_9XX 1)
else()
# add compiler flags, preprocessor definitions, include and link dirs # add compiler flags, preprocessor definitions, include and link dirs
include (${VTK_USE_FILE}) include (${VTK_USE_FILE})
endif()
if (VTK_LIBRARIES) if (VTK_LIBRARIES)
@ -81,8 +86,15 @@ if (VTK_FOUND)
# endif() # endif()
foreach (VTK_LIBRARY ${VTK_LIBRARIES}) foreach (VTK_LIBRARY ${VTK_LIBRARIES})
if (IS_VTK_9XX)
string (REGEX MATCH "^VTK::" IS_VTK_LIBRARY ${VTK_LIBRARY})
else()
string (REGEX MATCH "^vtk" IS_VTK_LIBRARY ${VTK_LIBRARY}) string (REGEX MATCH "^vtk" IS_VTK_LIBRARY ${VTK_LIBRARY})
if (IS_VTK_LIBRARY AND TARGET ${VTK_LIBRARY}) endif()
if (NOT IS_VTK_LIBRARY OR NOT TARGET ${VTK_LIBRARY})
continue()
endif()
# get paths from corresponding variables # get paths from corresponding variables
if (${VTK_LIBRARY}_INCLUDE_DIRS AND EXISTS "${${VTK_LIBRARY}_INCLUDE_DIRS}") if (${VTK_LIBRARY}_INCLUDE_DIRS AND EXISTS "${${VTK_LIBRARY}_INCLUDE_DIRS}")
list (APPEND 3RDPARTY_VTK_INCLUDE_DIRS "${${VTK_LIBRARY}_INCLUDE_DIRS}") list (APPEND 3RDPARTY_VTK_INCLUDE_DIRS "${${VTK_LIBRARY}_INCLUDE_DIRS}")
@ -101,7 +113,6 @@ if (VTK_FOUND)
# get paths from corresponding properties # get paths from corresponding properties
get_target_property (TARGET_VTK_IMPORT_CONFS ${VTK_LIBRARY} IMPORTED_CONFIGURATIONS) get_target_property (TARGET_VTK_IMPORT_CONFS ${VTK_LIBRARY} IMPORTED_CONFIGURATIONS)
if (TARGET_VTK_IMPORT_CONFS) if (TARGET_VTK_IMPORT_CONFS)
list (GET TARGET_VTK_IMPORT_CONFS 0 CHOSEN_IMPORT_CONF) list (GET TARGET_VTK_IMPORT_CONFS 0 CHOSEN_IMPORT_CONF)
@ -155,8 +166,6 @@ if (VTK_FOUND)
endif() endif()
endif() endif()
endif() endif()
endif()
endif()
endforeach() endforeach()
endif() endif()
@ -187,6 +196,7 @@ if (VTK_FOUND)
endif() endif()
endif() endif()
# endif() # endif()
endif()
if (3RDPARTY_VTK_INCLUDE_DIR AND EXISTS "${3RDPARTY_VTK_INCLUDE_DIR}") if (3RDPARTY_VTK_INCLUDE_DIR AND EXISTS "${3RDPARTY_VTK_INCLUDE_DIR}")
list (APPEND 3RDPARTY_INCLUDE_DIRS ${3RDPARTY_VTK_INCLUDE_DIR}) list (APPEND 3RDPARTY_INCLUDE_DIRS ${3RDPARTY_VTK_INCLUDE_DIR})

View File

@ -51,10 +51,7 @@
#include <IVtkDraw_Interactor.hxx> #include <IVtkDraw_Interactor.hxx>
// prevent disabling some MSVC warning messages by VTK headers // prevent disabling some MSVC warning messages by VTK headers
#ifdef _MSC_VER #include <Standard_WarningsDisable.hxx>
#pragma warning(push)
#pragma warning(disable: 4244)
#endif
#include <vtkAlgorithmOutput.h> #include <vtkAlgorithmOutput.h>
#include <vtkAppendPolyData.h> #include <vtkAppendPolyData.h>
#include <vtkBMPWriter.h> #include <vtkBMPWriter.h>
@ -88,9 +85,7 @@
#include <vtkXOpenGLRenderWindow.h> #include <vtkXOpenGLRenderWindow.h>
#include <tk.h> #include <tk.h>
#endif #endif
#ifdef _MSC_VER #include <Standard_WarningsRestore.hxx>
#pragma warning(pop)
#endif
#if (VTK_MAJOR_VERSION > 8) || (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 1) #if (VTK_MAJOR_VERSION > 8) || (VTK_MAJOR_VERSION == 8 && VTK_MINOR_VERSION >= 1)
#define HAVE_VTK_SRGB #define HAVE_VTK_SRGB

View File

@ -16,9 +16,7 @@
#include <IVtkDraw_HighlightAndSelectionPipeline.hxx> #include <IVtkDraw_HighlightAndSelectionPipeline.hxx>
// prevent disabling some MSVC warning messages by VTK headers // prevent disabling some MSVC warning messages by VTK headers
#ifdef _MSC_VER #include <Standard_WarningsDisable.hxx>
#pragma warning(push)
#endif
#include <vtkRenderer.h> #include <vtkRenderer.h>
#include <vtkActor.h> #include <vtkActor.h>
#include <vtkPolyDataMapper.h> #include <vtkPolyDataMapper.h>
@ -26,16 +24,13 @@
#include <vtkAppendPolyData.h> #include <vtkAppendPolyData.h>
#include <vtkProperty.h> #include <vtkProperty.h>
#include <vtkRenderWindow.h> #include <vtkRenderWindow.h>
#ifdef _MSC_VER #include <Standard_WarningsRestore.hxx>
#pragma warning(pop)
#endif
#include <IVtkOCC_Shape.hxx> #include <IVtkOCC_Shape.hxx>
#include <IVtkTools_DisplayModeFilter.hxx> #include <IVtkTools_DisplayModeFilter.hxx>
#include <IVtkTools_ShapeDataSource.hxx> #include <IVtkTools_ShapeDataSource.hxx>
#include <IVtkTools_ShapeObject.hxx> #include <IVtkTools_ShapeObject.hxx>
IMPLEMENT_STANDARD_RTTIEXT(IVtkDraw_HighlightAndSelectionPipeline,Standard_Transient) IMPLEMENT_STANDARD_RTTIEXT(IVtkDraw_HighlightAndSelectionPipeline,Standard_Transient)
//=========================================================== //===========================================================

View File

@ -22,17 +22,13 @@
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
// prevent disabling some MSVC warning messages by VTK headers // prevent disabling some MSVC warning messages by VTK headers
#ifdef _MSC_VER #include <Standard_WarningsDisable.hxx>
#pragma warning(push)
#endif
#include <vtkActor.h> #include <vtkActor.h>
#include <vtkPolyData.h> #include <vtkPolyData.h>
#include <vtkPolyDataMapper.h> #include <vtkPolyDataMapper.h>
#include <vtkRenderer.h> #include <vtkRenderer.h>
#include <vtkSmartPointer.h> #include <vtkSmartPointer.h>
#ifdef _MSC_VER #include <Standard_WarningsRestore.hxx>
#pragma warning(pop)
#endif
#include <IVtk_Types.hxx> #include <IVtk_Types.hxx>
#include <IVtkTools_DisplayModeFilter.hxx> #include <IVtkTools_DisplayModeFilter.hxx>

View File

@ -14,9 +14,7 @@
// commercial license or contractual agreement. // commercial license or contractual agreement.
// prevent disabling some MSVC warning messages by VTK headers // prevent disabling some MSVC warning messages by VTK headers
#ifdef _MSC_VER #include <Standard_WarningsDisable.hxx>
#pragma warning(push)
#endif
#ifdef _WIN32 #ifdef _WIN32
#include <vtkWin32RenderWindowInteractor.h> #include <vtkWin32RenderWindowInteractor.h>
#include <vtkWin32OpenGLRenderWindow.h> #include <vtkWin32OpenGLRenderWindow.h>
@ -30,13 +28,10 @@
#include <vtkCommand.h> #include <vtkCommand.h>
#include <vtkObjectFactory.h> #include <vtkObjectFactory.h>
#include <vtkSmartPointer.h> #include <vtkSmartPointer.h>
#include <Standard_WarningsRestore.hxx>
#include <IVtkDraw_Interactor.hxx> #include <IVtkDraw_Interactor.hxx>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#include <IVtkTools_ShapePicker.hxx> #include <IVtkTools_ShapePicker.hxx>
#include <IVtkTools_SubPolyDataFilter.hxx> #include <IVtkTools_SubPolyDataFilter.hxx>
#include <IVtkTools_DisplayModeFilter.hxx> #include <IVtkTools_DisplayModeFilter.hxx>

View File

@ -31,14 +31,10 @@
#endif #endif
// prevent disabling some MSVC warning messages by VTK headers // prevent disabling some MSVC warning messages by VTK headers
#ifdef _MSC_VER #include <Standard_WarningsDisable.hxx>
#pragma warning(push)
#endif
#include <vtkRenderWindowInteractor.h> #include <vtkRenderWindowInteractor.h>
#include <vtkSmartPointer.h> #include <vtkSmartPointer.h>
#ifdef _MSC_VER #include <Standard_WarningsRestore.hxx>
#pragma warning(pop)
#endif
#include <IVtkTools_ShapePicker.hxx> #include <IVtkTools_ShapePicker.hxx>
#include <IVtkDraw_HighlightAndSelectionPipeline.hxx> #include <IVtkDraw_HighlightAndSelectionPipeline.hxx>

View File

@ -19,7 +19,10 @@
#include <IVtkTools.hxx> #include <IVtkTools.hxx>
#include <IVtkOCC_Shape.hxx> #include <IVtkOCC_Shape.hxx>
#include <IVtkVTK_ShapeData.hxx> #include <IVtkVTK_ShapeData.hxx>
#include <Standard_WarningsDisable.hxx>
#include <vtkPolyDataAlgorithm.h> #include <vtkPolyDataAlgorithm.h>
#include <Standard_WarningsRestore.hxx>
class vtkIdTypeArray; class vtkIdTypeArray;
class vtkPolyData; class vtkPolyData;

View File

@ -20,15 +20,11 @@
#include <IVtkOCC_Shape.hxx> #include <IVtkOCC_Shape.hxx>
// prevent disabling some MSVC warning messages by VTK headers // prevent disabling some MSVC warning messages by VTK headers
#ifdef _MSC_VER #include <Standard_WarningsDisable.hxx>
#pragma warning(push)
#endif
#include <vtkDataObject.h> #include <vtkDataObject.h>
#include <vtkSetGet.h> #include <vtkSetGet.h>
#include <vtkWeakPointer.h> #include <vtkWeakPointer.h>
#ifdef _MSC_VER #include <Standard_WarningsRestore.hxx>
#pragma warning(pop)
#endif
class vtkActor; class vtkActor;
class vtkDataSet; class vtkDataSet;

View File

@ -21,14 +21,10 @@
#include <IVtkOCC_ShapePickerAlgo.hxx> #include <IVtkOCC_ShapePickerAlgo.hxx>
// prevent disabling some MSVC warning messages by VTK headers // prevent disabling some MSVC warning messages by VTK headers
#ifdef _MSC_VER #include <Standard_WarningsDisable.hxx>
#pragma warning(push)
#endif
#include <vtkAbstractPropPicker.h> #include <vtkAbstractPropPicker.h>
#include <vtkSmartPointer.h> #include <vtkSmartPointer.h>
#ifdef _MSC_VER #include <Standard_WarningsRestore.hxx>
#pragma warning(pop)
#endif
class vtkRenderer; class vtkRenderer;
class vtkActorCollection; class vtkActorCollection;

View File

@ -18,7 +18,9 @@
#include <IVtkTools.hxx> #include <IVtkTools.hxx>
#include "vtkPolyDataAlgorithm.h" #include <Standard_WarningsDisable.hxx>
#include <vtkPolyDataAlgorithm.h>
#include <Standard_WarningsRestore.hxx>
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(push) #pragma warning(push)

View File

@ -16,17 +16,13 @@
#include <IVtkVTK_ShapeData.hxx> #include <IVtkVTK_ShapeData.hxx>
// prevent disabling some MSVC warning messages by VTK headers // prevent disabling some MSVC warning messages by VTK headers
#ifdef _MSC_VER #include <Standard_WarningsDisable.hxx>
#pragma warning(push)
#endif
#include <vtkCellData.h> #include <vtkCellData.h>
#include <vtkDoubleArray.h> #include <vtkDoubleArray.h>
#include <vtkIdList.h> #include <vtkIdList.h>
#include <vtkPoints.h> #include <vtkPoints.h>
#include <vtkPolyData.h> #include <vtkPolyData.h>
#ifdef _MSC_VER #include <Standard_WarningsRestore.hxx>
#pragma warning(pop)
#endif
IMPLEMENT_STANDARD_RTTIEXT(IVtkVTK_ShapeData,IVtk_IShapeData) IMPLEMENT_STANDARD_RTTIEXT(IVtkVTK_ShapeData,IVtk_IShapeData)

View File

@ -19,15 +19,11 @@
#include <IVtk_IShapeData.hxx> #include <IVtk_IShapeData.hxx>
// prevent disabling some MSVC warning messages by VTK headers // prevent disabling some MSVC warning messages by VTK headers
#ifdef _MSC_VER #include <Standard_WarningsDisable.hxx>
#pragma warning(push)
#endif
#include <vtkPolyData.h> #include <vtkPolyData.h>
#include <vtkSmartPointer.h> #include <vtkSmartPointer.h>
#include <vtkIdTypeArray.h> #include <vtkIdTypeArray.h>
#ifdef _MSC_VER #include <Standard_WarningsRestore.hxx>
#pragma warning(pop)
#endif
class vtkIdTypeArray; class vtkIdTypeArray;