###  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 (
  ${FEEL_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 2 3 4 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} ${FEEL_LIBRARIES} )


    # test each backend
    foreach( BACKEND petsc trilinos )
      add_test( feel_bench_${BENCH}-${BACKEND}-strong
        ${FEEL_SOURCE_DIR}/benchmarks/python/batch_validation.py
        --program=${targetname}
        --path=${FEEL_BUILD_DIR}/benchmarks/laplacian/cG/
        --cmdargs="--backend=${BACKEND} --export=0 ${${BACKEND}_SOLVER_OPTIONS}" )
      add_test( feel_bench_${BENCH}-${BACKEND}-weak
        ${FEEL_SOURCE_DIR}/benchmarks/python/batch_validation.py
        --program=${targetname}
        --mode=0
        --path=${FEEL_BUILD_DIR}/benchmarks/laplacian/cG/
        --cmdargs="--backend=${BACKEND} --weak --export=0 ${${BACKEND}_SOLVER_OPTIONS}")

    endforeach() # backend

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


# foreach( BENCH     laplacian3dP1 laplacian3dP2 laplacian3dP3 laplacian3dP5)

#     feel_add_bench( ${BENCH} )

#     # test each backend
#     foreach( BACKEND petsc trilinos )
#       add_test( feel_bench_${BENCH}-${BACKEND}-strong
#         ${FEEL_SOURCE_DIR}/benchmarks/python/batch_validation.py
#         --program=${targetname}
#         --path=${FEEL_BUILD_DIR}/benchmarks/laplacian/cG/
#         --cmdargs="--backend=${BACKEND} --export=0 ${${BACKEND}_SOLVER_OPTIONS}" )
#       add_test( feel_bench_${BENCH}-${BACKEND}-weak
#         ${FEEL_SOURCE_DIR}/benchmarks/python/batch_validation.py
#         --program=${targetname}
#         --mode=0
#         --path=${FEEL_BUILD_DIR}/benchmarks/laplacian/cG/
#         --cmdargs="--backend=${BACKEND} --weak --export=0 ${${BACKEND}_SOLVER_OPTIONS}")

#     endforeach()

# endforeach()


