add_subdirectory(ExpressionTemplates)
add_subdirectory(RungeKutta)
add_subdirectory(stensor)
add_subdirectory(tensor)
add_subdirectory(st2tost2)
add_subdirectory(t2tost2)
add_subdirectory(st2tot2)
add_subdirectory(t2tot2)
if(enable-cadna)
  add_subdirectory(cadna)
endif(enable-cadna)

# a simple macro
macro(tests_math test_arg)
  add_executable(${test_arg} EXCLUDE_FROM_ALL ${test_arg}.cxx)
  target_include_directories(${test_arg}
    PRIVATE ${PROJECT_SOURCE_DIR}/tests/Math/include/)
  target_link_libraries(${test_arg}
    TFELMath TFELUtilities TFELException TFELTests)
  add_test(NAME ${test_arg} COMMAND ${test_arg})
  add_dependencies(check ${test_arg})
  if((CMAKE_HOST_WIN32) AND (NOT MSYS))
    set_property(TEST ${test_arg}
  	         PROPERTY ENVIRONMENT "PATH=$<TARGET_FILE_DIR:TFELMath>\;$<TARGET_FILE_DIR:TFELUtilities>\;$<TARGET_FILE_DIR:TFELException>\;$<TARGET_FILE_DIR:TFELTests>\;$<TARGET_FILE_DIR:TFELUnicodeSupport>\;$ENV{PATH}")
  endif((CMAKE_HOST_WIN32) AND (NOT MSYS))
endmacro(tests_math)

macro(tests_math2 test_arg)
  add_executable(${test_arg} EXCLUDE_FROM_ALL ${test_arg}.cxx)
  add_test(NAME ${test_arg} COMMAND ${test_arg})
  add_dependencies(check ${test_arg})
  if((CMAKE_HOST_WIN32) AND (NOT MSYS))
    set_property(TEST ${test_arg}
  	         PROPERTY ENVIRONMENT "PATH=$<TARGET_FILE_DIR:TFELMathKriging>\;$<TARGET_FILE_DIR:TFELMath>\;$<TARGET_FILE_DIR:TFELUtilities>\;$<TARGET_FILE_DIR:TFELException>\;$<TARGET_FILE_DIR:TFELTests>\;$<TARGET_FILE_DIR:TFELUnicodeSupport>\;$ENV{PATH}")
  endif((CMAKE_HOST_WIN32) AND (NOT MSYS))
  target_link_libraries(${test_arg} TFELMathKriging TFELMath TFELUtilities TFELException TFELTests)
endmacro(tests_math2)

macro(tests_math3 test_arg)
  add_executable(${test_arg} EXCLUDE_FROM_ALL ${test_arg}.cxx)
  add_test(NAME ${test_arg} COMMAND ${test_arg})
  add_dependencies(check ${test_arg})
  if((CMAKE_HOST_WIN32) AND (NOT MSYS))
    set_property(TEST ${test_arg}
  	         PROPERTY ENVIRONMENT "PATH=$<TARGET_FILE_DIR:TFELMathKriging>\;$<TARGET_FILE_DIR:TFELMathParser>\;$<TARGET_FILE_DIR:TFELMath>\;$<TARGET_FILE_DIR:TFELUtilities>\;$<TARGET_FILE_DIR:TFELException>\;$<TARGET_FILE_DIR:TFELTests>\;$<TARGET_FILE_DIR:TFELUnicodeSupport>\;$ENV{PATH}")
  endif((CMAKE_HOST_WIN32) AND (NOT MSYS))
  target_link_libraries(${test_arg} TFELMathParser TFELMathKriging TFELMath TFELUtilities TFELException TFELTests)
endmacro(tests_math3)

macro(tests_math4 test_arg)
  add_executable(${test_arg} EXCLUDE_FROM_ALL ${test_arg}.cxx)
  add_test(NAME ${test_arg} COMMAND ${test_arg})
  add_dependencies(check ${test_arg})
  if((CMAKE_HOST_WIN32) AND (NOT MSYS))
    set_property(TEST ${test_arg}
  	         PROPERTY ENVIRONMENT "PATH=$<TARGET_FILE_DIR:TFELMathCubicSpline>\;$<TARGET_FILE_DIR:TFELMath>\;$<TARGET_FILE_DIR:TFELUtilities>\;$<TARGET_FILE_DIR:TFELException>\;$<TARGET_FILE_DIR:TFELTests>\;$<TARGET_FILE_DIR:TFELUnicodeSupport>\;$ENV{PATH}")
  endif((CMAKE_HOST_WIN32) AND (NOT MSYS))
  target_link_libraries(${test_arg} TFELMathCubicSpline TFELMath TFELUtilities TFELException TFELTests)
endmacro(tests_math4)

tests_math(IndexingPoliciesTest)
tests_math(view)
tests_math(power)
tests_math(CubicRoots)
tests_math(promote)
tests_math(derivative_type)
tests_math(derivative_view)
tests_math(hill)
tests_math(qt)
tests_math(qt2)
tests_math(qt3)
tests_math(qt4)
tests_math(conj)
tests_math(lu)
tests_math(lu2)
tests_math(lu3)
tests_math(invert)
tests_math(invert2)
tests_math(tinymatrixsolve)
tests_math(tinymatrixsolve2)
tests_math(qr)
tests_math(newton_raphson)
tests_math(powell_dog_leg_newton_raphson)
tests_math(solve)
tests_math(fsarray)
tests_math(runtime_array)
tests_math(tmatrix)
tests_math(tmatrix1)
tests_math(tmatrix2)
tests_math(tmatrix4)
tests_math(tmatrix5)
tests_math(tmatrix6)
tests_math(tmatrix7)
tests_math(tvector)
tests_math(tvector2)
tests_math(tvector3)
tests_math(tvector4)
tests_math(tvector5)
tests_math(tvector6)
tests_math(tvector7)
tests_math(VectorResultType)
tests_math(broyden)
tests_math(broyden2)
tests_math(TinyVectorOfStensorFromTinyVectorView)
tests_math(TinyVectorOfTinyVectorFromTinyVectorView)
tests_math(discretization1D)
tests_math(levenberg-marquardt)
tests_math(levenberg-marquardt2)
tests_math(levenberg-marquardt3)
tests_math(levenberg-marquardt5)
tests_math(CorotationnalCauchyStressToSecondPioloKirchhoffStressTest)
tests_math(StridedRandomAccessIteratorTest)
tests_math(DifferenceRandomAccessIteratorTest)
tests_math(IEEE754Test)
tests_math(ScalarNewtonRaphsonTest)
tests_math(BissectionAlgorithmTest)
tests_math(FixedSizeArrayDerivativeTest)
tests_math(ComputeNumericalDerivativeTest)
tests_math(LinearInterpolationTest)
tests_math(CubicSplineInterpolationTest)
tests_math(matrix)
tests_math(types)

tests_math3(levenberg-marquardt4)

tests_math2(krigeage)
tests_math2(krigeage1D)
tests_math2(krigeage2D)

tests_math3(parser)
tests_math3(parser2)
tests_math3(parser3)
tests_math3(parser4)
tests_math3(parser5)
tests_math3(parser6)
tests_math3(parser7)
tests_math3(parser8)
tests_math3(parser9)
tests_math3(parser10)
tests_math3(parser11)
tests_math3(parser12)
tests_math3(integerparser)

tests_math4(CubicSplineTest)

tests_math4(TensorProductCheck)
