aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/eigen2/CMakeLists.txt
blob: c92257224cde8781fa522b32510739abe8b75be5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
add_custom_target(buildtests_eigen2)
add_custom_target(check_eigen2 COMMAND "ctest")
add_dependencies(check_eigen2 buildtests_eigen2)

add_definitions("-DEIGEN_NO_EIGEN2_DEPRECATED_WARNINGS")
add_definitions("-DEIGEN2_SUPPORT")

# Macro to add a test
#
# the unique parameter testname must correspond to a file
# <testname>.cpp which follows this pattern:
#
# #include "main.h"
# void test_<testname>() { ... }
#
# this macro add an executable test_<testname> as well as a ctest test
# named <testname>
#
# On platforms with bash simply run:
#   "ctest -V" or "ctest -V -R <testname>"
# On other platform use ctest as usual
#
macro(ei_add_test_eigen2 testname)

  set(targetname test_eigen2_${testname})

  set(filename ${testname}.cpp)
  add_executable(${targetname} ${filename})
  add_dependencies(buildtests_eigen2 ${targetname})

  if(NOT EIGEN_NO_ASSERTION_CHECKING)

    if(MSVC)
      set_target_properties(${targetname} PROPERTIES COMPILE_FLAGS "/EHsc")
    else(MSVC)
      set_target_properties(${targetname} PROPERTIES COMPILE_FLAGS "-fexceptions")
    endif(MSVC)

    option(EIGEN_DEBUG_ASSERTS "Enable debuging of assertions" OFF)
    if(EIGEN_DEBUG_ASSERTS)
      set_target_properties(${targetname} PROPERTIES COMPILE_DEFINITIONS "EIGEN_DEBUG_ASSERTS=1")
    endif(EIGEN_DEBUG_ASSERTS)

  endif(NOT EIGEN_NO_ASSERTION_CHECKING)

  if(${ARGC} GREATER 1)
    ei_add_target_property(${targetname} COMPILE_FLAGS "${ARGV1}")
  endif(${ARGC} GREATER 1)

  ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_FUNC=${testname}")

  if(TEST_LIB)
    target_link_libraries(${targetname} Eigen2)
  endif(TEST_LIB)

  if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
    target_link_libraries(${targetname} ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
  endif()

  target_link_libraries(${targetname} ${EXTERNAL_LIBS})
  if(${ARGC} GREATER 2)
    string(STRIP "${ARGV2}" ARGV2_stripped)
    string(LENGTH "${ARGV2_stripped}" ARGV2_stripped_length)
    if(${ARGV2_stripped_length} GREATER 0)
      target_link_libraries(${targetname} ${ARGV2})
    endif(${ARGV2_stripped_length} GREATER 0)
  endif(${ARGC} GREATER 2)

  if(WIN32)
    add_test(${testname} "${targetname}")
  else(WIN32)
    add_test(${testname} "${CMAKE_CURRENT_SOURCE_DIR}/runtest.sh" "${testname}")
  endif(WIN32)

endmacro(ei_add_test_eigen2)

enable_testing()

if(TEST_LIB)
  add_definitions("-DEIGEN_EXTERN_INSTANTIATIONS=1")
endif(TEST_LIB)

ei_add_test_eigen2(meta)
ei_add_test_eigen2(sizeof)
ei_add_test_eigen2(dynalloc)
ei_add_test_eigen2(nomalloc)
ei_add_test_eigen2(first_aligned)
ei_add_test_eigen2(mixingtypes)
ei_add_test_eigen2(packetmath)
ei_add_test_eigen2(unalignedassert)
ei_add_test_eigen2(vectorization_logic)
ei_add_test_eigen2(basicstuff)
ei_add_test_eigen2(linearstructure)
ei_add_test_eigen2(cwiseop)
ei_add_test_eigen2(sum)
ei_add_test_eigen2(product_small)
ei_add_test_eigen2(product_large ${EI_OFLAG})
ei_add_test_eigen2(adjoint)
ei_add_test_eigen2(submatrices)
ei_add_test_eigen2(miscmatrices)
ei_add_test_eigen2(commainitializer)
ei_add_test_eigen2(smallvectors)
ei_add_test_eigen2(map)
ei_add_test_eigen2(array)
ei_add_test_eigen2(triangular)
ei_add_test_eigen2(cholesky " " "${GSL_LIBRARIES}")
ei_add_test_eigen2(lu ${EI_OFLAG})
ei_add_test_eigen2(determinant ${EI_OFLAG})
ei_add_test_eigen2(inverse)
ei_add_test_eigen2(qr)
ei_add_test_eigen2(eigensolver " " "${GSL_LIBRARIES}")
ei_add_test_eigen2(svd)
ei_add_test_eigen2(geometry)
ei_add_test_eigen2(hyperplane)
ei_add_test_eigen2(parametrizedline)
ei_add_test_eigen2(alignedbox)
ei_add_test_eigen2(regression)
ei_add_test_eigen2(stdvector)
ei_add_test_eigen2(newstdvector)
if(QT4_FOUND)
  ei_add_test_eigen2(qtvector " " "${QT_QTCORE_LIBRARY}")
endif(QT4_FOUND)
if(NOT EIGEN_DEFAULT_TO_ROW_MAJOR)
  ei_add_test_eigen2(sparse_vector)
  ei_add_test_eigen2(sparse_basic)
  ei_add_test_eigen2(sparse_solvers " " "${SPARSE_LIBS}")
  ei_add_test_eigen2(sparse_product)
endif()
ei_add_test_eigen2(swap)
ei_add_test_eigen2(visitor)
ei_add_test_eigen2(bug_132)

ei_add_test_eigen2(prec_inverse_4x4 ${EI_OFLAG})