#set(GRIDTYPE ALBERTAGRID CACHE STRING "Gridtype to use")
set(GRIDTYPE ALUGRID_CONFORM CACHE STRING "Gridtype to use")
set(GRIDDIM  2 CACHE STRING "Grid-dimension to use")
set(NSM_P_POLORDER  1 CACHE STRING "Polynomial order of p to use")
set(NSM_U_POLORDER  1 CACHE STRING "Polynomial order of u to use")
set(NSM_U_DISCONT  false CACHE BOOL "true if u discontinuous")
set(NSM_P_DISCONT  false CACHE BOOL "true if p discontinuous")
set(NSM_USE_IMAGE  false CACHE BOOL "true if use image from file")
set(NSM_USE_NOISE  false CACHE BOOL "true if use and noise image from file")
set(NSM_SET_STEPSIZE  false CACHE BOOL "true if set tau and sigma manually")

set(WANT_ISTL 1 CACHE STRING "Set to 1 to use ISTL")
set(WANT_PETSC 0 CACHE STRING "Set to 1 to use PETSC")

add_definitions(
 -D${GRIDTYPE}
 -DNSM_P_POLORDER=${NSM_P_POLORDER}
 -DNSM_U_POLORDER=${NSM_U_POLORDER}
 -DNSM_U_DISCONT=${NSM_U_DISCONT}
 -DNSM_P_DISCONT=${NSM_P_DISCONT}
 -DNSM_USE_IMAGE=${NSM_USE_IMAGE}
 -DNSM_USE_NOISE=${NSM_USE_NOISE}
 -DNSM_SET_STEPSIZE=${NSM_SET_STEPSIZE}
 -DGRIDDIM=${GRIDDIM}
 -DWANT_ISTL=${WANT_ISTL}
 -DWANT_PETSC=${WANT_PETSC}
)


add_executable(nsm nsm.cc)

add_dune_alugrid_flags(nsm)

if(${GRIDTYPE} STREQUAL ALBERTAGRID)
  add_dune_alberta_flags(nsm WORLDDIM ${GRIDDIM})
elseif(${GRIDTYPE} MATCHES ALUGRID)
  target_link_libraries(nsm ${DUNE_LIBS})
  add_dune_alugrid_flags(nsm)
endif()

add_custom_command(TARGET nsm PRE_BUILD
  COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:nsm>/../output)

add_custom_command(TARGET nsm PRE_BUILD
  COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/data/ $<TARGET_FILE_DIR:nsm>/../data/)

