project(${WIKI}MyCode)

set(KIT ${PROJECT_NAME})

find_package(VTK COMPONENTS 
  CommonColor
  CommonCore
  CommonDataModel
  FiltersCore
  ImagingHybrid
  IOImport
  InteractionStyle
  RenderingAnnotation
  RenderingContextOpenGL2
  RenderingCore
  RenderingFreeType
  RenderingGL2PSOpenGL2
  RenderingOpenGL2
  OPTIONAL_COMPONENTS
  cli11
  fmt
  TestingRendering
  QUIET

)

set(KIT_LIBS ${VTK_LIBRARIES})

#
# Build all .cxx files in the directory
file(GLOB ALL_FILES *.cxx)


foreach(SOURCE_FILE ${ALL_FILES})
  string(REPLACE ".cxx" "" TMP ${SOURCE_FILE})
  string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/ "" EXAMPLE ${TMP})
  add_executable(${WIKI}${EXAMPLE} ${EXECUTABLE_FLAG} ${EXAMPLE}.cxx)
  target_link_libraries(${WIKI}${EXAMPLE} ${KIT_LIBS})
  vtk_module_autoinit(
    TARGETS ${WIKI}${EXAMPLE}
    MODULES ${VTK_LIBRARIES}
    )
endforeach()

if (BUILD_TESTING)
  set(NEEDS_ARGS
    IndividualVRML
    )

  set(DATA ${TestFramework_SOURCE_DIR}/src/Testing/Data)
  set(TEMP ${TestFramework_BINARY_DIR}/Testing/Temporary)

  add_test(${KIT}-IndividualVRML ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${KIT}CxxTests
    TestIndividualVRML ${DATA}/utah_teapot.wrl teapot)

  include(${TestFramework_SOURCE_DIR}/CMake/EgTesting.cmake)
endif()

# Demonstrate using a different comparison method.
# You must rebuild the project after each change.
# Change edgeColour from SteelBlue to Turquoise
# Then run ctest with set_tests_properties command for ImplicitQuadric commented out.
# You should see a failed test.
# Now uncomment the set_tests_properties command for ImplicitQuadric and run ctest.
# The test will now pass.
# if (BUILD_TESTING)
#   set_tests_properties(${KIT}-ImplicitQuadric PROPERTIES ENVIRONMENT "VTK_TESTING=1;VTK_TESTING_IMAGE_COMPARE_METHOD=LOOSE_VALID")
# endif()
