IF(VTK_USE_DISPLAY)
ADD_EXECUTABLE(SocketServer SocketServer.cxx)
ADD_EXECUTABLE(SocketClient SocketClient.cxx)

IF (VTK_HAS_THREADS OR VTK_USE_MPI)
  IF (VTK_USE_RENDERING)
    ADD_EXECUTABLE(ParallelIsoTest ParallelIso.cxx)
    TARGET_LINK_LIBRARIES(ParallelIsoTest vtkVolumeRendering vtkParallel vtkHybrid vtkWidgets)
  ENDIF (VTK_USE_RENDERING)

 ADD_EXECUTABLE(GenericCommunicator GenericCommunicator.cxx)
 TARGET_LINK_LIBRARIES(GenericCommunicator vtkParallel)

 ADD_EXECUTABLE(TestPStream TestPStream.cxx)
 TARGET_LINK_LIBRARIES(TestPStream vtkParallel)
ENDIF (VTK_HAS_THREADS OR VTK_USE_MPI)

IF (VTK_HAS_THREADS)
 ADD_EXECUTABLE(ThreadedCommunicator ThreadedCommunicator.cxx)
 TARGET_LINK_LIBRARIES(ThreadedCommunicator vtkParallel)
ENDIF (VTK_HAS_THREADS)

TARGET_LINK_LIBRARIES(SocketServer vtkParallel)
TARGET_LINK_LIBRARIES(SocketClient vtkParallel)

IF (VTK_USE_MPI)
  ADD_EXECUTABLE(MPIGroups MPIGroups.cxx)
  TARGET_LINK_LIBRARIES(MPIGroups vtkParallel)

  ADD_EXECUTABLE(DistributedData DistributedData.cxx)
  TARGET_LINK_LIBRARIES(DistributedData vtkParallel)
ENDIF (VTK_USE_MPI)

#
# Add tests, with the data
#

IF (VTK_DATA_ROOT)
  IF (VTK_USE_RENDERING)
    IF (VTK_HAS_THREADS)
      ADD_TEST(ThreadedCommunicator-image 
               ${CXX_TEST_PATH}/ThreadedCommunicator
               -D ${VTK_DATA_ROOT}
               -T ${VTK_BINARY_DIR}/Testing/Temporary
               -V Baseline/Parallel/ThreadedCommunicator.cxx.png)
    ENDIF (VTK_HAS_THREADS)

    IF (VTK_USE_MPI)
     IF (UNIX)
      IF (VTK_MPIRUN_EXE)
        IF(VTK_MPI_MAX_NUMPROCS GREATER 1)
          ADD_TEST(ParallelIsoMPI-image 
            ${VTK_MPIRUN_EXE} ${VTK_MPI_NUMPROC_FLAG} 2 ${VTK_MPI_PREFLAGS} 
                   ${CXX_TEST_PATH}/ParallelIsoTest
                   -D ${VTK_DATA_ROOT}
                   -T ${VTK_BINARY_DIR}/Testing/Temporary
                   -V Baseline/Parallel/ParallelIso.cxx.png
                   ${VTK_MPI_POSTFLAGS})
          ADD_TEST(TestCommunicatorMPI-image 
            ${VTK_MPIRUN_EXE} ${VTK_MPI_NUMPROC_FLAG} 2 ${VTK_MPI_PREFLAGS} 
                   ${CXX_TEST_PATH}/GenericCommunicator
                   -D ${VTK_DATA_ROOT}
                   -T ${VTK_BINARY_DIR}/Testing/Temporary
                   -V Baseline/Parallel/GenericCommunicator.cxx.png
                   ${VTK_MPI_POSTFLAGS})
          ADD_TEST(TestPStreamMPI-image 
            ${VTK_MPIRUN_EXE} ${VTK_MPI_NUMPROC_FLAG} 2 ${VTK_MPI_PREFLAGS} 
                   ${CXX_TEST_PATH}/TestPStream
                   -D ${VTK_DATA_ROOT}
                   -T ${VTK_BINARY_DIR}/Testing/Temporary
                   -V Baseline/Parallel/TestPStream.cxx.png
                   ${VTK_MPI_POSTFLAGS})
        ENDIF(VTK_MPI_MAX_NUMPROCS GREATER 1)
        IF (VTK_MPI_MAX_NUMPROCS)
          IF (VTK_MPI_MAX_NUMPROCS GREATER 3)
           ADD_TEST(MPIGroups-image 
          ${VTK_MPIRUN_EXE} ${VTK_MPI_NUMPROC_FLAG} ${VTK_MPI_MAX_NUMPROCS} ${VTK_MPI_PREFLAGS} 
                   ${CXX_TEST_PATH}/MPIGroups
                   -D ${VTK_DATA_ROOT}
                   -T ${VTK_BINARY_DIR}/Testing/Temporary
                   -V Baseline/Parallel/MPIGroups.cxx.png
                   ${VTK_MPI_POSTFLAGS})
          ENDIF (VTK_MPI_MAX_NUMPROCS GREATER 3)
        ENDIF (VTK_MPI_MAX_NUMPROCS)
      ENDIF(VTK_MPIRUN_EXE)
     ENDIF (UNIX)
    ELSE (VTK_USE_MPI)
      IF (VTK_HAS_THREADS)
        ADD_TEST(ParallelIso-image ${CXX_TEST_PATH}/ParallelIsoTest
                 -D ${VTK_DATA_ROOT}
                 -T ${VTK_BINARY_DIR}/Testing/Temporary
                 -V Baseline/Parallel/ParallelIso.cxx.png)
        ADD_TEST(TestCommunicator-image ${CXX_TEST_PATH}/GenericCommunicator
                 -D ${VTK_DATA_ROOT}
                 -T ${VTK_BINARY_DIR}/Testing/Temporary
                 -V Baseline/Parallel/GenericCommunicator.cxx.png)
      ENDIF (VTK_HAS_THREADS)
    ENDIF (VTK_USE_MPI)
  ENDIF (VTK_USE_RENDERING)

  IF (VTK_USE_MPI)
    IF (VTK_MPIRUN_EXE)
      IF(VTK_MPI_MAX_NUMPROCS GREATER 1)
        ADD_TEST(DistributedData-image
          ${VTK_MPIRUN_EXE} ${VTK_MPI_NUMPROC_FLAG} 2 ${VTK_MPI_PREFLAGS}
                 ${CXX_TEST_PATH}/DistributedData
                 -D ${VTK_DATA_ROOT}
                 -T ${VTK_BINARY_DIR}/Testing/Temporary
                 -V Baseline/Parallel/DistributedData.cxx.png
                 ${VTK_MPI_POSTFLAGS})
      ENDIF(VTK_MPI_MAX_NUMPROCS GREATER 1)
    ENDIF (VTK_MPIRUN_EXE)
  ENDIF (VTK_USE_MPI)

#
# If we do not have the data, still run the tests that we can
#
ELSE (VTK_DATA_ROOT)
  IF (VTK_USE_RENDERING)
    IF (VTK_HAS_THREADS)
      ADD_TEST(ThreadedCommunicator ${CXX_TEST_PATH}/ThreadedCommunicator)
    ENDIF (VTK_HAS_THREADS)
    IF (VTK_USE_MPI)
     IF(UNIX)
      IF (VTK_MPIRUN_EXE)
        ADD_TEST(TestCommunicatorMPI 
      ${VTK_MPIRUN_EXE} ${VTK_MPI_NUMPROC_FLAG} 2 ${VTK_MPI_PREFLAGS} 
      ${CXX_TEST_PATH}/GenericCommunicator ${VTK_MPI_POSTFLAGS})
      ENDIF(VTK_MPIRUN_EXE)
     ENDIF(UNIX)
    ELSE (VTK_USE_MPI)
      IF (VTK_HAS_THREADS)
        ADD_TEST(TestCommunicator ${CXX_TEST_PATH}/GenericCommunicator)
      ENDIF (VTK_HAS_THREADS)
    ENDIF (VTK_USE_MPI)
  ENDIF (VTK_USE_RENDERING)
ENDIF (VTK_DATA_ROOT)

# For now this test is only available on Unix because
# on Windows, python does not support forking/killing processes
IF (UNIX)
 IF (PYTHON_EXECUTABLE)
  IF (VTK_DATA_ROOT)
    ADD_TEST(Sockets-image ${PYTHON_EXECUTABLE}
      ${VTK_SOURCE_DIR}/Parallel/Testing/Cxx/TestSockets.py 
      ${VTK_EXECUTABLE_DIR}/SocketServer
      ${VTK_EXECUTABLE_DIR}/SocketClient
      ${VTK_DATA_ROOT}
      Baseline/Parallel/SocketClient.cxx.png
      ${VTK_BINARY_DIR}/Testing/Temporary)
  ENDIF (VTK_DATA_ROOT)
 ENDIF (PYTHON_EXECUTABLE)
ENDIF (UNIX)
ENDIF(VTK_USE_DISPLAY)
