Salome HOME
Minimize external dependencies: libxml is NOT a 1st-level dependency for GUI
[modules/gui.git] / adm_local / cmake_files / FindSalomeVTK.cmake
index 6bf4b002bdb3e3da46b94750068974f1091e3753..b2a98adf6fc421b2b953f7c6239b3e23bd99121a 100644 (file)
@@ -1,28 +1,59 @@
+# Copyright (C) 2013  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# Author: Adrien Bruneton
+#
 
-# VTK detection for Salome
+# VTK detection for Salome (see http://www.vtk.org/Wiki/VTK/Build_System_Migration)
+#
+#  !! Please read the generic detection procedure in SalomeMacros.cmake !!
+#
 
-set(PARAVIEW_ROOT_DIR $ENV{PARAVIEW_ROOT_DIR} CACHE PATH "Path to ParaView directory")
-set(PARAVIEW_VERSION $ENV{PARAVIEW_VERSION} CACHE STRING "Version of Paraview")
-if(EXISTS ${PARAVIEW_ROOT_DIR})
-  set(VTK_DIR ${PARAVIEW_ROOT_DIR}/lib/paraview-${PARAVIEW_VERSION} CACHE PATH "Path to directory including VTKConfig.cmake")
-endif(EXISTS ${PARAVIEW_ROOT_DIR})
-find_package(VTK REQUIRED)
-if (VTK_FOUND)
-  include(${VTK_USE_FILE})
-  message(STATUS "VTK version is ${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}")
-  message(STATUS "Kit VTK availables : ${VTK_KITS}")
-  message(STATUS "VTK Library dir is : ${VTK_LIBRARY_DIRS}")
-  set(CMAKE_LIBRARY_PATH ${VTK_LIBRARY_DIRS})
-  set(VTK_LIBSWENEED vtkCommon vtkGraphics vtkImaging vtkFiltering vtkIO vtkRendering vtkHybrid vtkParallel vtkWidgets vtkInfovis vtkVolumeRendering)
-  unset(VTK_LIBRARIES)
-  foreach(VTK_LIB_NEEDED ${VTK_LIBSWENEED})
-    unset(VTK_LIB CACHE)
-    find_library(VTK_LIB ${VTK_LIB_NEEDED})
-    set(VTK_LIBRARIES ${VTK_LIBRARIES} ${VTK_LIB})
-  endforeach(VTK_LIB_NEEDED)
-  find_library(VTK_PYLIBS vtkWrappingPython${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}-pv${PARAVIEW_VERSION})
-  #find_library(vtkCommonPythonD vtkCommonPythonD)
-  #find_library(vtkGraphicsPythonD vtkGraphicsPythonD)
-  #find_library(vtkImagingPythonD vtkImagingPythonD)
-  #find_library(vtkPythonCore vtkPythonCore)
-endif(VTK_FOUND)
+# List the required components:
+#   Seting the following variable is equivalent to having passed the components
+#   when calling the FIND_PACKAGE() command.
+SET(SalomeVTK_FIND_COMPONENTS 
+  vtkRenderingFreeTypeOpenGL
+  vtkRenderingLOD 
+  vtkRenderingAnnotation 
+  vtkFiltersParallel
+  vtkIOExport
+  #vtkWrappingPythonCore  ## ParaView 4.0.1
+  vtkWrappingPython
+  vtkIOXML
+)
+
+# If no VTK root dir is specified, try the ParaView root dir:
+SET(PARAVIEW_ROOT_DIR "$ENV{PARAVIEW_ROOT_DIR}" CACHE PATH "Path to the ParaView installation")
+IF(EXISTS "${PARAVIEW_ROOT_DIR}" AND (NOT VTK_ROOT_DIR))
+  MESSAGE(STATUS "Looking for VTK in the ParaView installation (PARAVIEW_ROOT_DIR exists and VTK_ROOT_DIR is not defined) ...")
+  
+  # Extract sub-directory "paraview-x.xx":
+  FILE(GLOB VTK_DIR "${PARAVIEW_ROOT_DIR}/lib/cmake/paraview-*")
+  MESSAGE(STATUS "Setting VTK_DIR to: ${VTK_DIR}") 
+ENDIF()
+
+SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(VTK VTK_INCLUDE_DIRS 2)
+MARK_AS_ADVANCED(VTK_DIR)
+
+SALOME_ACCUMULATE_HEADERS(VTK_INCLUDE_DIRS)
+
+IF(VTK_FOUND)
+  MESSAGE(STATUS "VTK version is ${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION}")
+  #MESSAGE(STATUS "VTK libraries are: ${VTK_LIBRARIES}")
+ENDIF()