From 996a5125103000e76a0ca2fa56fe6d00cbab8226 Mon Sep 17 00:00:00 2001
From: Vivien Delmon <vivien.delmon@creatis.insa-lyon.fr>
Date: Wed, 14 Dec 2011 10:07:24 +0100
Subject: [PATCH] Add VTK_LIBRARIES variable for vtk < 5.8.0

Add VTK_LIBRARIES variable for vtk < 5.8.0 and use it.
---
 cmake/dependencies.cmake | 12 ++++++++++++
 tools/CMakeLists.txt     | 12 ++++--------
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake
index 225ddcc..078c5a4 100644
--- a/cmake/dependencies.cmake
+++ b/cmake/dependencies.cmake
@@ -13,6 +13,18 @@ ENDIF(ITK_FOUND)
 FIND_PACKAGE(VTK REQUIRED)
 IF(VTK_FOUND)
   INCLUDE("${VTK_USE_FILE}")
+  IF(VTK_VERSION VERSION_LESS 5.8.0)
+    SET ( VTK_LIBRARIES
+      vtkCommon
+      vtkRendering
+      vtkIO
+      vtkFiltering
+      vtkGraphics
+      vtkWidgets
+      vtkImaging
+      vtkHybrid
+      )
+  ENDIF(VTK_VERSION VERSION_LESS 5.8.0)
 ELSE(VTK_FOUND)
   MESSAGE(FATAL_ERROR "Please set VTK_DIR.")
 ENDIF(VTK_FOUND)
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 21a8101..3c70f52 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -126,7 +126,7 @@ IF (CLITK_BUILD_TOOLS)
 
   WRAP_GGO(clitkGammaIndex_GGO_C clitkGammaIndex.ggo)
   ADD_EXECUTABLE(clitkGammaIndex clitkGammaIndex.cxx ${clitkGammaIndex_GGO_C})
-  TARGET_LINK_LIBRARIES(clitkGammaIndex clitkCommon ${VTK_LIBRARIES} ${ITK_LIBRARIES} vtkIO)
+  TARGET_LINK_LIBRARIES(clitkGammaIndex clitkCommon ${VTK_LIBRARIES} ${ITK_LIBRARIES})
   SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkGammaIndex)
 
   ADD_EXECUTABLE(clitkImageArithm clitkImageArithm.cxx)
@@ -368,21 +368,17 @@ IF (CLITK_BUILD_TOOLS)
 
     WRAP_GGO(clitkBinaryImageToMesh_GGO_C clitkBinaryImageToMesh.ggo)
     ADD_EXECUTABLE(clitkBinaryImageToMesh clitkBinaryImageToMesh.cxx ${clitkBinaryImageToMesh_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkBinaryImageToMesh ${ITK_LIBRARIES} vtkCommon vtkRendering)
+    TARGET_LINK_LIBRARIES(clitkBinaryImageToMesh ${ITK_LIBRARIES} ${VTK_LIBRARIES})
     SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkBinaryImageToMesh)
 
     WRAP_GGO(clitkMeshToBinaryImage_GGO_C clitkMeshToBinaryImage.ggo)
     ADD_EXECUTABLE(clitkMeshToBinaryImage clitkMeshToBinaryImage.cxx ${clitkMeshToBinaryImage_GGO_C})
-    IF(VTK_VERSION VERSION_LESS 5.8.0)
-      TARGET_LINK_LIBRARIES(clitkMeshToBinaryImage clitkCommon ${ITK_LIBRARIES} vtkHybrid vtkIO)
-    ELSE(VTK_VERSION VERSION_LESS 5.8.0)
-      TARGET_LINK_LIBRARIES(clitkMeshToBinaryImage clitkCommon ${ITK_LIBRARIES} ${VTK_LIBRARIES})
-    ENDIF(VTK_VERSION VERSION_LESS 5.8.0)
+    TARGET_LINK_LIBRARIES(clitkMeshToBinaryImage clitkCommon ${ITK_LIBRARIES} ${VTK_LIBRARIES})
     SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMeshToBinaryImage)
 
     WRAP_GGO(clitkMeshViewer_GGO_C clitkMeshViewer.ggo)
     ADD_EXECUTABLE(clitkMeshViewer clitkMeshViewer.cxx ${clitkMeshViewer_GGO_C})
-    TARGET_LINK_LIBRARIES(clitkMeshViewer vtkCommon vtkRendering)
+    TARGET_LINK_LIBRARIES(clitkMeshViewer ${VTK_LIBRARIES})
     SET(TOOLS_INSTALL ${TOOLS_INSTALL} clitkMeshViewer)
   ENDIF(CLITK_EXPERIMENTAL)
 
-- 
2.47.1