###  CMakeLists.txt ---

#  Author(s): Christophe Prud'homme <christophe.prudhomme@ujf-grenoble.fr>
#       Date: 2010-06-26
#
#  Copyright (C) 2010 Université Joseph Fourier (Grenoble I)
#
# Distributed under the GPL(GNU Public License):
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
INCLUDE_DIRECTORIES (
  ${FEELPP_SOURCE_DIR}/benchmarks/laplacian/cG
  )
ENABLE_TESTING()

foreach( continuity Discontinuous )
#  foreach( dim 1 2 3)
# 3D discontinuous does not work (problem with face integral in 3D)
  foreach( dim 1 2 )
    foreach( order 1  5)
      foreach( convex Simplex Hypercube )
        set(modulename "laplacian")
        set(BENCH "${modulename}_${continuity}_${dim}_${order}_${convex}" )
        set(targetname feel_bench_${BENCH})
        FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${modulename}_${continuity}_${dim}_${order}_${convex}.cpp
          "// this file is auto-generated by Feel \n\n
#include<${modulename}.hpp>\n\n
int main( int argc, char** argv )
{
    Feel::Assert::setLog( \"${modulename}_${dim}_${order}_${convex}.assert\");
    Laplacian<${dim}, ${order}, ${dim}, ${continuity}, Feel::${convex}> laplacian( argc, argv, makeAbout(), makeOptions() );
    laplacian.run();
}
\n" )

add_executable(${targetname} ${modulename}_${continuity}_${dim}_${order}_${convex}.cpp)
target_link_libraries(${targetname} ${FEELPP_LIBRARIES} )
set_property(TARGET ${targetname} PROPERTY LABELS benchmarks)
add_dependencies( benchmarks ${targetname} )
# test each backend
    foreach( BACKEND ${FEELPP_BACKENDS} )
      add_test( feel_bench_${BENCH}-${BACKEND}-strong
        ${PYTHON_EXECUTABLE}
        ${FEELPP_SOURCE_DIR}/benchmarks/python/batch_validation.py
        --program=${targetname}
        --path=${FEELPP_BUILD_DIR}/benchmarks/laplacian/cG/
        --cmdargs="--backend=${BACKEND} --weak=0 --export=0 ${${BACKEND}_SOLVER_OPTIONS}" )
      set_property(TEST feel_bench_${BENCH}-${BACKEND}-strong PROPERTY LABELS benchmarks)
      add_test( feel_bench_${BENCH}-${BACKEND}-weak
        ${PYTHON_EXECUTABLE}
        ${FEELPP_SOURCE_DIR}/benchmarks/python/batch_validation.py
        --program=${targetname}
        --mode=0
        --path=${FEELPP_BUILD_DIR}/benchmarks/laplacian/cG/
        --cmdargs="--backend=${BACKEND} --weak=1 --export=0 ${${BACKEND}_SOLVER_OPTIONS}")
      set_property(TEST feel_bench_${BENCH}-${BACKEND}-weak PROPERTY LABELS benchmarks)
    endforeach() # backend

  endforeach() # convex
endforeach() # order
endforeach() # dim
endforeach() # continuity
