0029056: Configuration - It is not possible to install VTK products
authorski <ski@opencascade.com>
Mon, 28 Aug 2017 13:16:37 +0000 (16:16 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 30 Aug 2017 10:52:48 +0000 (13:52 +0300)
Added installation of vtk.

CMakeLists.txt
adm/cmake/occt_toolkit.cmake
adm/cmake/occt_toolkit_tool.cmake
adm/cmake/vardescr.cmake
adm/cmake/vtk.cmake

index 9954ab4..23ad2d6 100644 (file)
@@ -515,6 +515,7 @@ endif()
 # VTK
 if (USE_VTK)
   add_definitions (-DHAVE_VTK)
+  set (OCCT_VTK_USED_TARGETS "" CACHE INTERNAL "" FORCE)
   OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/vtk")
 else()
   OCCT_CHECK_AND_UNSET_GROUP ("3RDPARTY_VTK")
index 0dce048..57c9269 100644 (file)
@@ -213,6 +213,9 @@ foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS})
     
     if (NOT "${TK_FOUND}" STREQUAL "" OR NOT "${VTK_FOUND}" STREQUAL "")
       list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT ${USED_ITEM})
+      if (NOT "${VTK_FOUND}" STREQUAL "" AND BUILD_SHARED_LIBS AND INSTALL_VTK AND COMMAND OCCT_INSTALL_VTK)
+        OCCT_INSTALL_VTK(${USED_ITEM})
+      endif()
     else()
       string (REGEX MATCH "^CSF_" CSF_FOUND ${USED_ITEM})
       if ("${CSF_FOUND}" STREQUAL "")
index 24c9a2c..f289675 100644 (file)
@@ -245,6 +245,9 @@ foreach (USED_ITEM ${USED_EXTERNLIB_AND_TOOLKITS})
     
     if (NOT "${TK_FOUND}" STREQUAL "" OR NOT "${VTK_FOUND}" STREQUAL "")
       list (APPEND USED_TOOLKITS_BY_CURRENT_PROJECT ${USED_ITEM})
+      if (NOT "${VTK_FOUND}" STREQUAL "" AND BUILD_SHARED_LIBS AND INSTALL_VTK AND COMMAND OCCT_INSTALL_VTK)
+        OCCT_INSTALL_VTK(${USED_ITEM})
+      endif()
     else()
       string (REGEX MATCH "^CSF_" CSF_FOUND ${USED_ITEM})
       if ("${CSF_FOUND}" STREQUAL "")
index 331c6e4..6fb0395 100644 (file)
@@ -91,8 +91,7 @@ INSTALL_MESSAGE (INSTALL_GL2PS            "GL2PS binaries")
 INSTALL_MESSAGE (INSTALL_TBB              "TBB binaries")
 INSTALL_MESSAGE (INSTALL_TCL              "TCL binaries")
 INSTALL_MESSAGE (INSTALL_TK               "TK binaries")
-
-#INSTALL_MESSAGE (INSTALL_VTK              "VTK binaries ")
+INSTALL_MESSAGE (INSTALL_VTK              "VTK binaries ")
 
 # build variables
 macro (BUILD_MODULE_MESSAGE BUILD_MODULE_TARGET_VARIABLE BUILD_MODULE_TARGET_STRING)
index cd4103e..f9e268b 100644 (file)
@@ -1,8 +1,8 @@
 # vtk
 
-#if (NOT DEFINED INSTALL_VTK)
-#  set (INSTALL_VTK OFF CACHE BOOL "${INSTALL_VTK_DESCR}")
-#endif()
+if (NOT DEFINED INSTALL_VTK)
+  set (INSTALL_VTK OFF CACHE BOOL "${INSTALL_VTK_DESCR}")
+endif()
 
 # vtk directory
 if (NOT DEFINED 3RDPARTY_VTK_DIR)
@@ -210,11 +210,86 @@ if (BUILD_SHARED_LIBS)
   endif()
 endif()
 
+# Install vtk library using vtk targets
+macro (OCCT_INSTALL_VTK VTK_LIBRARY_NAME)
+  # Check that input library name contains "vtk" prefix
+  string (REGEX MATCH "^vtk" IS_VTK_LIBRARY ${VTK_LIBRARY_NAME})
+  # Check that input library was not already installed
+  list (FIND OCCT_VTK_USED_TARGETS ${VTK_LIBRARY_NAME} VTK_LIBRARY_IS_USED)
+  if (BUILD_SHARED_LIBS AND INSTALL_VTK AND TARGET ${VTK_LIBRARY_NAME} AND VTK_LIBRARY_IS_USED EQUAL -1 AND IS_VTK_LIBRARY)
+    OCCT_MAKE_OS_WITH_BITNESS()
+
+    # Get configuration of vtk
+    get_target_property (TARGET_VTK_IMPORT_CONFS ${VTK_LIBRARY_NAME} IMPORTED_CONFIGURATIONS)
+    list (GET TARGET_VTK_IMPORT_CONFS 0 CHOSEN_IMPORT_CONF)
+
+    # Get dependencies for current input library
+    get_property(VTK_LIBRARY_PATH       TARGET ${VTK_LIBRARY_NAME} PROPERTY LOCATION)
+    get_property(VTK_DEPEND             TARGET ${VTK_LIBRARY_NAME} PROPERTY IMPORTED_LINK_DEPENDENT_LIBRARIES_${CHOSEN_IMPORT_CONF})
+    get_property(VTK_IMPORTED_INTERFACE TARGET ${VTK_LIBRARY_NAME} PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES_${CHOSEN_IMPORT_CONF})
+    get_property(VTK_INTERFACE          TARGET ${VTK_LIBRARY_NAME} PROPERTY INTERFACE_LINK_LIBRARIES)
+    list (APPEND VTK_DEPEND ${VTK_INTERFACE} ${VTK_IMPORTED_INTERFACE})
+
+    # Install
+    if (WIN32)
+      if (SINGLE_GENERATOR)
+        install (FILES "${VTK_LIBRARY_PATH}" DESTINATION "${INSTALL_DIR_BIN}")
+      else()
+        install (FILES "${VTK_LIBRARY_PATH}"
+                 CONFIGURATIONS Release
+                 DESTINATION "${INSTALL_DIR_BIN}")
+        install (FILES "${VTK_LIBRARY_PATH}"
+                 CONFIGURATIONS RelWithDebInfo
+                 DESTINATION "${INSTALL_DIR_BIN}i")
+        install (FILES "${VTK_LIBRARY_PATH}"
+                 CONFIGURATIONS Debug
+                 DESTINATION "${INSTALL_DIR_BIN}d")
+      endif()
+    else()
+      get_filename_component(3RDPARTY_VTK_LIBRARY_ABS ${VTK_LIBRARY_PATH} REALPATH)
+
+      if (SINGLE_GENERATOR)
+        install (FILES "${3RDPARTY_VTK_LIBRARY_ABS}"
+                 DESTINATION "${INSTALL_DIR_LIB}")
+      else()
+        install (FILES "${3RDPARTY_VTK_LIBRARY_ABS}"
+                 CONFIGURATIONS Release
+                 DESTINATION "${INSTALL_DIR_LIB}")
+        install (FILES "${3RDPARTY_VTK_LIBRARY_ABS}"
+                 CONFIGURATIONS RelWithDebInfo
+                 DESTINATION "${INSTALL_DIR_LIB}i")
+        install (FILES "${3RDPARTY_VTK_LIBRARY_ABS}"
+                 CONFIGURATIONS Debug
+                 DESTINATION "${INSTALL_DIR_LIB}d")
+      endif()
+    endif()
+
+    set (USED_3RDPARTY_VTK_DIR "")
+
+    # Mark current library as already installed
+    list (APPEND OCCT_VTK_USED_TARGETS ${VTK_LIBRARY_NAME})
+    set (OCCT_VTK_USED_TARGETS "${OCCT_VTK_USED_TARGETS}" CACHE INTERNAL "" FORCE)
+
+    # Recursively install all depended libraries
+    foreach(VTK_TARGET ${VTK_DEPEND})
+      OCCT_INSTALL_VTK(${VTK_TARGET})
+    endforeach()
+  endif()
+endmacro()
+
+if (NOT BUILD_SHARED_LIBS)
+  OCCT_CHECK_AND_UNSET(3RDPARTY_VTK_DLL_DIR)
+  OCCT_CHECK_AND_UNSET(3RDPARTY_VTK_LIBRARY_DIR)
+  OCCT_CHECK_AND_UNSET(INSTALL_VTK)
+endif()
+
 # the library directory for using by the executable
-if (WIN32)
-  set (USED_3RDPARTY_VTK_DIR ${3RDPARTY_VTK_DLL_DIR})
-else()
-  set (USED_3RDPARTY_VTK_DIR ${3RDPARTY_VTK_LIBRARY_DIR})
+if (NOT INSTALL_VTK)
+  if (WIN32)
+    set (USED_3RDPARTY_VTK_DIR ${3RDPARTY_VTK_DLL_DIR})
+  else()
+    set (USED_3RDPARTY_VTK_DIR ${3RDPARTY_VTK_LIBRARY_DIR})
+  endif()
 endif()
 
 OCCT_CHECK_AND_UNSET (VTK_INCLUDE_DIRS)