if( NOT GRIDTYPE )
  set(GRIDTYPE  YASPGRID)
endif()
if( NOT GRIDDIM )
  set(GRIDDIM  2)
endif()

# copy data to build source to make tests work
configure_file(1dgrid.dgf ${CMAKE_CURRENT_BINARY_DIR}/1dgrid.dgf COPYONLY)
configure_file(2dgrid.dgf ${CMAKE_CURRENT_BINARY_DIR}/2dgrid.dgf COPYONLY)
configure_file(3dgrid.dgf ${CMAKE_CURRENT_BINARY_DIR}/3dgrid.dgf COPYONLY)

set( BASISFUNCTIONSETS vectorialbasisfunctionset defaultbasisfunctionset  simplebasisfunctionset tuplebasisfunctionset cachingbasisfunctionset generate )
foreach( bset ${BASISFUNCTIONSETS} )
  dune_add_test( NAME test_${bset} SOURCES test-${bset}.cc
  COMPILE_DEFINITIONS "${GRIDTYPE};GRIDDIM=${GRIDDIM};DIMRANGE=5;POLORDER=3"
  LINK_LIBRARIES dunefem )
endforeach()

target_include_directories(test_generate PRIVATE "./" "${CMAKE_CURRENT_BINARY_DIR}")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/autogeneratedcode.hh "// to be gernated automatically")

exclude_from_headercheck( ${CMAKE_CURRENT_BINARY_DIR}/autogeneratedcode.hh )
exclude_from_headercheck( ${CMAKE_CURRENT_BINARY_DIR}/autogeneratedcode/* )

add_custom_target(generate test_generate)
dune_add_test( NAME test_optimizedcode SOURCES test-cachingbasisfunctionset.cc
  COMPILE_DEFINITIONS "${GRIDTYPE};USE_BASEFUNCTIONSET_CODEGEN;GRIDDIM=${GRIDDIM};DIMRANGE=5;POLORDER=3"
  LINK_LIBRARIES dunefem )
target_include_directories(test_optimizedcode PRIVATE "./" "${CMAKE_CURRENT_BINARY_DIR}")
add_dependencies(test_optimizedcode test_generate generate)

set_property(TARGET test_vectorialbasisfunctionset APPEND PROPERTY COMPILE_DEFINITIONS "USE_VERTICAL_DOF_ALIGNMENT=1" )

dune_install(checkbasisfunctionset.hh)
