SET(KIT Common)
SET(UKIT COMMON)
SET(KIT_TCL_LIBS ${VTK_TCL_LIBRARIES})
SET(KIT_PYTHON_LIBS)
SET(KIT_JAVA_LIBS)
SET(KIT_LIBS)

IF(WIN32)
  IF (NOT VTK_USE_X)
    SET(VTK_OWP_ENCODED_C vtkWin32OutputWindowProcessEncoded.c)
    SET_SOURCE_FILES_PROPERTIES(${VTK_OWP_ENCODED_C} PROPERTIES WRAP_EXCLUDE 1)
  ENDIF (NOT VTK_USE_X)
ENDIF(WIN32)

IF (APPLE)
  SET(KIT_LIBS ${KIT_LIBS} "-framework AppKit")
ENDIF (APPLE)
IF (UNIX)
  SET(KIT_LIBS ${KIT_LIBS} ${CMAKE_THREAD_LIBS} ${CMAKE_DL_LIBS} -lm)
ENDIF (UNIX)

SET( Kit_SRCS
vtkAbstractArray.cxx
vtkAbstractTransform.cxx
vtkAmoebaMinimizer.cxx
vtkAnimationCue.cxx
vtkAnimationScene.cxx
vtkAssemblyNode.cxx
vtkAssemblyPath.cxx
vtkAssemblyPaths.cxx
vtkBitArray.cxx
vtkBox.cxx
vtkByteSwap.cxx
vtkCallbackCommand.cxx
vtkCharArray.cxx
vtkCollection.cxx
vtkCollectionIterator.cxx
vtkCommand.cxx
vtkContourValues.cxx
vtkCriticalSection.cxx
vtkCylindricalTransform.cxx
vtkDataArray.cxx
vtkDataArrayCollection.cxx
vtkDataArrayCollectionIterator.cxx
vtkDataArraySelection.cxx
vtkDebugLeaks.cxx
vtkDebugLeaksManager.cxx
vtkDirectory.cxx
vtkDoubleArray.cxx
vtkDynamicLoader.cxx
vtkEdgeTable.cxx
vtkErrorCode.cxx
vtkEventForwarderCommand.cxx
vtkExtentSplitter.cxx
vtkExtentTranslator.cxx
vtkFastNumericConversion.cxx
vtkFileOutputWindow.cxx
vtkFloatArray.cxx
vtkFunctionParser.cxx
vtkFunctionSet.cxx
vtkGarbageCollector.cxx
vtkGarbageCollectorManager.cxx
vtkGeneralTransform.cxx
vtkHeap.cxx
vtkHomogeneousTransform.cxx
vtkIOStream.cxx
vtkIdList.cxx
vtkIdListCollection.cxx
vtkIdTypeArray.cxx
vtkIdentityTransform.cxx
vtkImplicitFunction.cxx
vtkImplicitFunctionCollection.cxx
vtkIndent.cxx
vtkInitialValueProblemSolver.cxx
vtkInstantiator.cxx
vtkIntArray.cxx
vtkLargeInteger.cxx
vtkLinearTransform.cxx
vtkLogLookupTable.cxx
vtkLongArray.cxx
vtkLookupTable.cxx
vtkMath.cxx
vtkMatrix4x4.cxx
vtkMatrixToHomogeneousTransform.cxx
vtkMatrixToLinearTransform.cxx
vtkMultiPartExtentTranslator.cxx
vtkMultiThreader.cxx
vtkMutexLock.cxx
vtkOStrStreamWrapper.cxx
vtkOStreamWrapper.cxx
vtkObject.cxx
vtkObjectBase.cxx
vtkObjectFactory.cxx
vtkObjectFactoryCollection.cxx
vtkOldStyleCallbackCommand.cxx
vtkOutputWindow.cxx
vtkOverrideInformation.cxx
vtkOverrideInformationCollection.cxx
vtkParametricBoy.cxx
vtkParametricConicSpiral.cxx
vtkParametricCrossCap.cxx
vtkParametricDini.cxx
vtkParametricEllipsoid.cxx
vtkParametricEnneper.cxx
vtkParametricFigure8Klein.cxx
vtkParametricFunction.cxx
vtkParametricKlein.cxx
vtkParametricMobius.cxx
vtkParametricRandomHills.cxx
vtkParametricRoman.cxx
vtkParametricSuperEllipsoid.cxx
vtkParametricSuperToroid.cxx
vtkParametricTorus.cxx
vtkPerspectiveTransform.cxx
vtkPlane.cxx
vtkPlaneCollection.cxx
vtkPlanes.cxx
vtkPoints.cxx
vtkPriorityQueue.cxx
vtkProp.cxx
vtkPropCollection.cxx
vtkProperty2D.cxx
vtkQuadric.cxx
vtkReferenceCount.cxx
vtkRungeKutta2.cxx
vtkRungeKutta4.cxx
vtkRungeKutta45.cxx
vtkScalarsToColors.cxx
vtkShortArray.cxx
vtkSignedCharArray.cxx
vtkSmartPointerBase.cxx
vtkSphericalTransform.cxx
vtkStdString.cxx
vtkStringArray.cxx
vtkStructuredData.cxx
vtkStructuredVisibilityConstraint.cxx
vtkTableExtentTranslator.cxx
vtkTensor.cxx
vtkThreadMessager.cxx
vtkTimeStamp.cxx
vtkTimerLog.cxx
vtkTransform.cxx
vtkTransformCollection.cxx
vtkUnsignedCharArray.cxx
vtkUnsignedIntArray.cxx
vtkUnsignedLongArray.cxx
vtkUnsignedShortArray.cxx
vtkVersion.cxx
vtkVoidArray.cxx
vtkWarpTransform.cxx
vtkWindow.cxx
vtkWindowLevelLookupTable.cxx
vtkXMLFileOutputWindow.cxx
)

IF(VTK_TYPE_USE_LONG_LONG)
  SET(Kit_SRCS ${Kit_SRCS}
    vtkLongLongArray.cxx
    vtkUnsignedLongLongArray.cxx
    )
  SET_SOURCE_FILES_PROPERTIES(
    vtkLongLongArray.cxx
    vtkUnsignedLongLongArray.cxx
    WRAP_EXCLUDE
    )
ENDIF(VTK_TYPE_USE_LONG_LONG)
IF(VTK_TYPE_USE___INT64)
  SET(Kit_SRCS ${Kit_SRCS} vtk__Int64Array.cxx)
  SET_SOURCE_FILES_PROPERTIES(vtk__Int64Array.cxx WRAP_EXCLUDE)
  IF(VTK_TYPE_CONVERT_UI64_TO_DOUBLE)
    SET(Kit_SRCS ${Kit_SRCS} vtkUnsigned__Int64Array.cxx)
    SET_SOURCE_FILES_PROPERTIES(vtkUnsigned__Int64Array.cxx WRAP_EXCLUDE)
  ENDIF(VTK_TYPE_CONVERT_UI64_TO_DOUBLE)
ENDIF(VTK_TYPE_USE___INT64)

SET_SOURCE_FILES_PROPERTIES(
# vtkObjectBase is marked ABSTRACT so that instantiators are happy.
vtkAbstractArray
vtkAbstractTransform
vtkCallbackCommand
vtkCommand
vtkDataArray
vtkEventForwarderCommand
vtkFunctionSet
vtkHomogeneousTransform
vtkImplicitFunction
vtkInitialValueProblemSolver
vtkLinearTransform
vtkObjectBase
vtkObjectFactory
vtkOldStyleCallbackCommand
vtkOverrideInformation
vtkOverrideInformationCollection
vtkParametricFunction
vtkProp
vtkScalarsToColors
vtkStructuredData
vtkWarpTransform
vtkWindow
ABSTRACT
)

SET_SOURCE_FILES_PROPERTIES(
  vtkCallbackCommand.cxx
  vtkCommand.cxx
  vtkDebugLeaksManager.cxx
  vtkErrorCode.cxx
  vtkEventForwarderCommand.cxx
  vtkGarbageCollectorManager.cxx
  vtkIOStream.cxx
  vtkIndent.cxx
  vtkLargeInteger.cxx
  vtkOStrStreamWrapper.cxx
  vtkOStreamWrapper.cxx
  vtkOldStyleCallbackCommand.cxx
  vtkSignedCharArray.cxx
  vtkSmartPointerBase.cxx
  vtkStdString.cxx
  vtkTimeStamp.cxx

  WRAP_EXCLUDE
)

SET(Kit_EXTRA_SRCS)
SET(Kit_EXTRA_CMDS)
SET(Kit_TCL_EXTRA_SRCS vtkTclUtil.cxx)
SET(Kit_PYTHON_EXTRA_SRCS vtkPythonUtil.cxx)
SET(Kit_JAVA_EXTRA_SRCS vtkJavaUtil.cxx)

IF (WIN32)
  IF (NOT VTK_USE_X)
    SET(Kit_SRCS ${Kit_SRCS} vtkWin32OutputWindow.cxx
      vtkWin32ProcessOutputWindow.cxx)
    SET(Kit_EXTRA_SRCS ${Kit_EXTRA_SRCS} vtkWin32OutputWindowProcessEncoded.c)
    SET_SOURCE_FILES_PROPERTIES(vtkWin32OutputWindowProcessEncoded.c
      PROPERTIES WRAP_EXCLUDE 1)
  ENDIF (NOT VTK_USE_X)
ENDIF (WIN32)

# -----------------------------------------------------------------
# Start of common section

# Setup vtkInstantiator registration for this library's classes.
VTK_MAKE_INSTANTIATOR3(vtk${KIT}Instantiator KitInstantiator_SRCS
                       "${Kit_SRCS}"
                       VTK_${UKIT}_EXPORT
                       ${VTK_BINARY_DIR} "")
ADD_LIBRARY(vtk${KIT} ${Kit_SRCS} ${Kit_EXTRA_SRCS} ${KitInstantiator_SRCS})

# Allow the user to customize their build with some local options
#
SET(LOCALUSERMACRODEFINED 0)
INCLUDE (${VTK_BINARY_DIR}/${KIT}/LocalUserOptions.cmake OPTIONAL)
INCLUDE (${VTK_SOURCE_DIR}/${KIT}/LocalUserOptions.cmake OPTIONAL)

# if we are wrapping into Tcl then add the library and extra
# source files
#
IF (VTK_WRAP_TCL)
  VTK_WRAP_TCL3(vtk${KIT}TCL KitTCL_SRCS 
                "${Kit_SRCS}"
                "${Kit_TCL_EXTRA_CMDS}")
  ADD_LIBRARY(vtk${KIT}TCL ${KitTCL_SRCS} ${Kit_TCL_EXTRA_SRCS})
  TARGET_LINK_LIBRARIES (vtk${KIT}TCL vtk${KIT} ${KIT_TCL_LIBS})
  IF(NOT VTK_INSTALL_NO_LIBRARIES)
    INSTALL_TARGETS(${VTK_INSTALL_LIB_DIR} vtk${KIT}TCL)
  ENDIF(NOT VTK_INSTALL_NO_LIBRARIES)
ENDIF (VTK_WRAP_TCL)

# if we are wrapping into Python then add the library and extra
# source files
#
IF (VTK_WRAP_PYTHON)
  VTK_WRAP_PYTHON3(vtk${KIT}Python KitPython_SRCS "${Kit_SRCS}")
  IF (APPLE)
    ADD_LIBRARY(vtk${KIT}PythonD ${KitPython_SRCS} ${Kit_PYTHON_EXTRA_SRCS})
    ADD_LIBRARY(vtk${KIT}Python MODULE vtk${KIT}PythonInit.cxx)
    TARGET_LINK_LIBRARIES(vtk${KIT}PythonD vtk${KIT} ${KIT_PYTHON_LIBS}
                          ${VTK_PYTHON_LIBRARIES})
    TARGET_LINK_LIBRARIES(vtk${KIT}Python vtk${KIT}PythonD)
    IF(NOT VTK_INSTALL_NO_LIBRARIES)
      INSTALL_TARGETS(${VTK_INSTALL_LIB_DIR} vtk${KIT}PythonD)
    ENDIF(NOT VTK_INSTALL_NO_LIBRARIES)
  ELSE (APPLE)
    ADD_LIBRARY(vtk${KIT}Python MODULE ${KitPython_SRCS} ${Kit_PYTHON_EXTRA_SRCS})
    TARGET_LINK_LIBRARIES (vtk${KIT}Python vtk${KIT} ${KIT_PYTHON_LIBS})
  ENDIF(APPLE)
  IF(WIN32)
    TARGET_LINK_LIBRARIES (vtk${KIT}Python ${VTK_PYTHON_LIBRARIES})
  ENDIF(WIN32)
  IF(NOT VTK_INSTALL_NO_LIBRARIES)
    INSTALL_TARGETS(${VTK_INSTALL_LIB_DIR} vtk${KIT}Python)
  ENDIF(NOT VTK_INSTALL_NO_LIBRARIES)
ENDIF (VTK_WRAP_PYTHON)

# if we are wrapping into Java then add the library and extra
# source files
#
IF (VTK_WRAP_JAVA)
  VTK_WRAP_JAVA3(vtk${KIT}Java KitJava_SRCS "${Kit_SRCS}")
  ADD_LIBRARY(vtk${KIT}Java SHARED ${KitJava_SRCS} ${Kit_JAVA_EXTRA_SRCS})
  TARGET_LINK_LIBRARIES(vtk${KIT}Java vtk${KIT} ${KIT_JAVA_LIBS})
  IF(NOT VTK_INSTALL_NO_LIBRARIES)
    INSTALL_TARGETS(${VTK_INSTALL_LIB_DIR} vtk${KIT}Java)
  ENDIF(NOT VTK_INSTALL_NO_LIBRARIES)
ENDIF (VTK_WRAP_JAVA)

TARGET_LINK_LIBRARIES(vtk${KIT} ${KIT_LIBS})

IF(NOT VTK_INSTALL_NO_LIBRARIES)
  INSTALL_TARGETS(${VTK_INSTALL_LIB_DIR} vtk${KIT})
ENDIF(NOT VTK_INSTALL_NO_LIBRARIES)
IF(NOT VTK_INSTALL_NO_DEVELOPMENT)
  INSTALL_FILES(${VTK_INSTALL_INCLUDE_DIR} .h ${Kit_SRCS})
ENDIF(NOT VTK_INSTALL_NO_DEVELOPMENT)

VTK_EXPORT_KIT("${KIT}" "${UKIT}" "${Kit_SRCS}")

# If the user defined a custom macro, execute it now and pass in all the srcs
#
IF(LOCALUSERMACRODEFINED)
  LocalUserOptionsMacro( "${Kit_SRCS}"       "${Kit_EXTRA_SRCS}"
                         "${KitTCL_SRCS}"    "${Kit_TCL_EXTRA_SRCS}"
                         "${KitJava_SRCS}"   "${Kit_JAVA_EXTRA_SRCS}"
                         "${KitPython_SRCS}" "${Kit_PYTHON_EXTRA_SRCS}")
ENDIF(LOCALUSERMACRODEFINED)

# End of common section
# -----------------------------------------------------------------

IF(NOT VTK_INSTALL_NO_DEVELOPMENT)
  INSTALL_FILES(${VTK_INSTALL_INCLUDE_DIR} .h
    vtkDataArrayTemplate
    vtkIOStream
    vtkIOStreamFwd
    vtkSetGet
    vtkSmartPointer
    vtkSystemIncludes
    vtkType
    vtkTypeTraits
    vtkWin32Header
    vtkWindows
    )

  IF(VTK_WRAP_TCL)
    INSTALL_FILES(${VTK_INSTALL_INCLUDE_DIR} .h
      vtkTcl
      vtkTclUtil
      vtkTk
      )
  ENDIF(VTK_WRAP_TCL)
  IF(VTK_WRAP_PYTHON)
    INSTALL_FILES(${VTK_INSTALL_INCLUDE_DIR} .h
      vtkPythonUtil
      )
    INSTALL_FILES(${VTK_INSTALL_INCLUDE_DIR} FILES
      vtkPython.h
      )
    IF (TK_LIBRARY)
      IF(NOT VTK_USE_COCOA)
        INSTALL_FILES(${VTK_INSTALL_INCLUDE_DIR} .h
          vtkTcl
          vtkTk
          )
      ENDIF(NOT VTK_USE_COCOA)
    ENDIF (TK_LIBRARY)
  ENDIF(VTK_WRAP_PYTHON)
  IF(VTK_WRAP_JAVA)
    INSTALL_FILES(${VTK_INSTALL_INCLUDE_DIR} .h
      vtkJavaUtil
      )
  ENDIF(VTK_WRAP_JAVA)

  INSTALL_FILES(${VTK_INSTALL_INCLUDE_DIR} .txx
    vtkDataArrayTemplate
    vtkDataArrayTemplateImplicit
    )

  INSTALL_FILES(${VTK_INSTALL_LIB_DIR}/testing FILES
    ${VTK_SOURCE_DIR}/${KIT}/Testing/HeaderTesting.py
    ${VTK_SOURCE_DIR}/${KIT}/Testing/Tcl/FindString.tcl
    ${VTK_SOURCE_DIR}/${KIT}/Testing/Tcl/PrintSelfCheck.tcl
    ${VTK_SOURCE_DIR}/${KIT}/Testing/Tcl/rtImageTest.tcl
    ${VTK_SOURCE_DIR}/${KIT}/Testing/Tcl/TestSetGet.tcl
    )
  INSTALL_FILES(${VTK_INSTALL_INCLUDE_DIR} FILES
    ${VTK_SOURCE_DIR}/${KIT}/Testing/Cxx/vtkTestUtilities.h)
  IF(VTK_USE_PARALLEL)
    INSTALL_FILES(${VTK_INSTALL_LIB_DIR}/testing FILES
      ${VTK_SOURCE_DIR}/${KIT}/Testing/Tcl/prtImageTest.tcl)
  ENDIF(VTK_USE_PARALLEL)
ENDIF(NOT VTK_INSTALL_NO_DEVELOPMENT)
