set (ENV{VTK_DIR} ${CACHED_VTK_DIR})
endif()
+unset (IS_VTK_9XX)
if (VTK_FOUND)
-
- # add compiler flags, preprocessor definitions, include and link dirs
- include (${VTK_USE_FILE})
+ 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
+ include (${VTK_USE_FILE})
+ endif()
if (VTK_LIBRARIES)
# endif()
foreach (VTK_LIBRARY ${VTK_LIBRARIES})
- string (REGEX MATCH "^vtk" IS_VTK_LIBRARY ${VTK_LIBRARY})
- if (IS_VTK_LIBRARY AND TARGET ${VTK_LIBRARY})
- # get paths from corresponding variables
- if (${VTK_LIBRARY}_INCLUDE_DIRS AND EXISTS "${${VTK_LIBRARY}_INCLUDE_DIRS}")
- list (APPEND 3RDPARTY_VTK_INCLUDE_DIRS "${${VTK_LIBRARY}_INCLUDE_DIRS}")
+ if (IS_VTK_9XX)
+ string (REGEX MATCH "^VTK::" IS_VTK_LIBRARY ${VTK_LIBRARY})
+ else()
+ string (REGEX MATCH "^vtk" IS_VTK_LIBRARY ${VTK_LIBRARY})
+ endif()
+ if (NOT IS_VTK_LIBRARY OR NOT TARGET ${VTK_LIBRARY})
+ continue()
+ endif()
+
+ # get paths from corresponding variables
+ if (${VTK_LIBRARY}_INCLUDE_DIRS AND EXISTS "${${VTK_LIBRARY}_INCLUDE_DIRS}")
+ list (APPEND 3RDPARTY_VTK_INCLUDE_DIRS "${${VTK_LIBRARY}_INCLUDE_DIRS}")
+ endif()
+
+ if (${VTK_LIBRARY}_LIBRARY_DIRS AND EXISTS "${${VTK_LIBRARY}_LIBRARY_DIRS}")
+ list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${${VTK_LIBRARY}_LIBRARY_DIRS}")
+ endif()
+
+ if (${VTK_LIBRARY}_RUNTIME_LIBRARY_DIRS AND EXISTS "${${VTK_LIBRARY}_RUNTIME_LIBRARY_DIRS}")
+ list (APPEND 3RDPARTY_VTK_DLL_DIRS "${${VTK_LIBRARY}_RUNTIME_LIBRARY_DIRS}")
+ if (NOT WIN32)
+ list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${${VTK_LIBRARY}_RUNTIME_LIBRARY_DIRS}")
endif()
+ endif()
- if (${VTK_LIBRARY}_LIBRARY_DIRS AND EXISTS "${${VTK_LIBRARY}_LIBRARY_DIRS}")
- list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${${VTK_LIBRARY}_LIBRARY_DIRS}")
+ # get paths from corresponding properties
+ get_target_property (TARGET_VTK_IMPORT_CONFS ${VTK_LIBRARY} IMPORTED_CONFIGURATIONS)
+ if (TARGET_VTK_IMPORT_CONFS)
+ list (GET TARGET_VTK_IMPORT_CONFS 0 CHOSEN_IMPORT_CONF)
+
+ # todo: choose configuration in connection with the build type
+ #if (CMAKE_BUILD_TYPE)
+ # foreach (IMPORT_CONF ${TARGET_VTK_IMPORT_CONFS})
+ # endforeach()
+ #endif()
+
+ # Work-around against link failure in case if VTK contains dependency
+ # on DirectX: its run-time is always present on Windows, but SDK can
+ # be absent on current workstation, while not actually needed for
+ # OCCT linking.
+ # VTK 6.1 for VC 10
+ get_target_property (TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES ${VTK_LIBRARY} IMPORTED_LINK_INTERFACE_LIBRARIES_${CHOSEN_IMPORT_CONF})
+ if(TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES)
+ string (REGEX MATCH "[^;]*d3d[0-9]+[.]lib" HARDCODED_D3D9_LIB "${TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES}")
+ if (HARDCODED_D3D9_LIB)
+ message (STATUS "Warning: ${HARDCODED_D3D9_LIB} has been removed from imported dependencies of ${VTK_LIBRARY}")
+
+ list (REMOVE_ITEM TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES ${HARDCODED_D3D9_LIB})
+ set_target_properties (${VTK_LIBRARY} PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES_${CHOSEN_IMPORT_CONF} "${TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES}")
endif()
-
- if (${VTK_LIBRARY}_RUNTIME_LIBRARY_DIRS AND EXISTS "${${VTK_LIBRARY}_RUNTIME_LIBRARY_DIRS}")
- list (APPEND 3RDPARTY_VTK_DLL_DIRS "${${VTK_LIBRARY}_RUNTIME_LIBRARY_DIRS}")
- if (NOT WIN32)
- list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${${VTK_LIBRARY}_RUNTIME_LIBRARY_DIRS}")
- endif()
+ endif()
+ # VTK 6.1 for VC 12, 14
+ get_target_property (TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES ${VTK_LIBRARY} INTERFACE_LINK_LIBRARIES)
+ if(TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES)
+ string (REGEX MATCH "[^;]*d3d[0-9]+[.]lib" HARDCODED_D3D9_LIB "${TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES}")
+ if (HARDCODED_D3D9_LIB)
+ message (STATUS "Warning: ${HARDCODED_D3D9_LIB} has been removed from imported dependencies of ${VTK_LIBRARY}")
+
+ list (REMOVE_ITEM TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES ${HARDCODED_D3D9_LIB})
+ set_target_properties (${VTK_LIBRARY} PROPERTIES INTERFACE_LINK_LIBRARIES "${TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES}")
endif()
+ endif()
- # get paths from corresponding properties
- get_target_property (TARGET_VTK_IMPORT_CONFS ${VTK_LIBRARY} IMPORTED_CONFIGURATIONS)
-
- if (TARGET_VTK_IMPORT_CONFS)
- list (GET TARGET_VTK_IMPORT_CONFS 0 CHOSEN_IMPORT_CONF)
-
- # todo: choose configuration in connection with the build type
- #if (CMAKE_BUILD_TYPE)
- # foreach (IMPORT_CONF ${TARGET_VTK_IMPORT_CONFS})
- # endforeach()
- #endif()
-
- # Work-around against link failure in case if VTK contains dependency
- # on DirectX: its run-time is always present on Windows, but SDK can
- # be absent on current workstation, while not actually needed for
- # OCCT linking.
- # VTK 6.1 for VC 10
- get_target_property (TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES ${VTK_LIBRARY} IMPORTED_LINK_INTERFACE_LIBRARIES_${CHOSEN_IMPORT_CONF})
- if(TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES)
- string (REGEX MATCH "[^;]*d3d[0-9]+[.]lib" HARDCODED_D3D9_LIB "${TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES}")
- if (HARDCODED_D3D9_LIB)
- message (STATUS "Warning: ${HARDCODED_D3D9_LIB} has been removed from imported dependencies of ${VTK_LIBRARY}")
-
- list (REMOVE_ITEM TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES ${HARDCODED_D3D9_LIB})
- set_target_properties (${VTK_LIBRARY} PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES_${CHOSEN_IMPORT_CONF} "${TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES}")
- endif()
- endif()
- # VTK 6.1 for VC 12, 14
- get_target_property (TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES ${VTK_LIBRARY} INTERFACE_LINK_LIBRARIES)
- if(TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES)
- string (REGEX MATCH "[^;]*d3d[0-9]+[.]lib" HARDCODED_D3D9_LIB "${TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES}")
- if (HARDCODED_D3D9_LIB)
- message (STATUS "Warning: ${HARDCODED_D3D9_LIB} has been removed from imported dependencies of ${VTK_LIBRARY}")
-
- list (REMOVE_ITEM TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES ${HARDCODED_D3D9_LIB})
- set_target_properties (${VTK_LIBRARY} PROPERTIES INTERFACE_LINK_LIBRARIES "${TARGET_PROPERTY_IMP_LINK_INTERFACE_LIBRARIES}")
- endif()
- endif()
-
- get_target_property (TARGET_PROPERTY_IMP_PATH ${VTK_LIBRARY} IMPORTED_IMPLIB_${CHOSEN_IMPORT_CONF})
- if(TARGET_PROPERTY_IMP_PATH AND EXISTS "${TARGET_PROPERTY_IMP_PATH}")
- get_filename_component (TARGET_PROPERTY_IMP_DIR "${TARGET_PROPERTY_IMP_PATH}" PATH)
- list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${TARGET_PROPERTY_IMP_DIR}")
- endif()
-
- get_target_property (TARGET_PROPERTY_LOCATION_PATH ${VTK_LIBRARY} IMPORTED_LOCATION_${CHOSEN_IMPORT_CONF})
- if(TARGET_PROPERTY_LOCATION_PATH AND EXISTS "${TARGET_PROPERTY_LOCATION_PATH}")
- get_filename_component (TARGET_PROPERTY_LOCATION_DIR "${TARGET_PROPERTY_LOCATION_PATH}" PATH)
-
- if (WIN32)
- list (APPEND 3RDPARTY_VTK_DLL_DIRS "${TARGET_PROPERTY_LOCATION_DIR}")
- else()
- list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${TARGET_PROPERTY_LOCATION_DIR}")
- endif()
- endif()
+ get_target_property (TARGET_PROPERTY_IMP_PATH ${VTK_LIBRARY} IMPORTED_IMPLIB_${CHOSEN_IMPORT_CONF})
+ if(TARGET_PROPERTY_IMP_PATH AND EXISTS "${TARGET_PROPERTY_IMP_PATH}")
+ get_filename_component (TARGET_PROPERTY_IMP_DIR "${TARGET_PROPERTY_IMP_PATH}" PATH)
+ list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${TARGET_PROPERTY_IMP_DIR}")
+ endif()
+
+ get_target_property (TARGET_PROPERTY_LOCATION_PATH ${VTK_LIBRARY} IMPORTED_LOCATION_${CHOSEN_IMPORT_CONF})
+ if(TARGET_PROPERTY_LOCATION_PATH AND EXISTS "${TARGET_PROPERTY_LOCATION_PATH}")
+ get_filename_component (TARGET_PROPERTY_LOCATION_DIR "${TARGET_PROPERTY_LOCATION_PATH}" PATH)
+
+ if (WIN32)
+ list (APPEND 3RDPARTY_VTK_DLL_DIRS "${TARGET_PROPERTY_LOCATION_DIR}")
+ else()
+ list (APPEND 3RDPARTY_VTK_LIBRARY_DIRS "${TARGET_PROPERTY_LOCATION_DIR}")
endif()
endif()
endif()
endif()
endif()
# endif()
+endif()
if (3RDPARTY_VTK_INCLUDE_DIR AND EXISTS "${3RDPARTY_VTK_INCLUDE_DIR}")
list (APPEND 3RDPARTY_INCLUDE_DIRS ${3RDPARTY_VTK_INCLUDE_DIR})