1 # generate split test header file only if it does not yet exist
2 # in order to prevent a rebuild everytime cmake is configured
3 if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/split_test_helper.h)
4 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/split_test_helper.h "")
6 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/split_test_helper.h
7 "#ifdef EIGEN_TEST_PART_${i}\n"
8 "#define CALL_SUBTEST_${i}(FUNC) CALL_SUBTEST(FUNC)\n"
10 "#define CALL_SUBTEST_${i}(FUNC)\n"
16 # check if we have a Fortran compiler
17 include("../cmake/language_support.cmake")
19 workaround_9220(Fortran EIGEN_Fortran_COMPILER_WORKS)
21 if(EIGEN_Fortran_COMPILER_WORKS)
22 enable_language(Fortran OPTIONAL)
23 if(NOT CMAKE_Fortran_COMPILER)
24 set(EIGEN_Fortran_COMPILER_WORKS OFF)
28 if(NOT EIGEN_Fortran_COMPILER_WORKS)
29 # search for a default Lapack library to complete Eigen's one
33 # configure blas/lapack (use Eigen's ones)
34 set(EIGEN_BLAS_LIBRARIES eigen_blas)
35 set(EIGEN_LAPACK_LIBRARIES eigen_lapack)
37 set(EIGEN_TEST_MATRIX_DIR "" CACHE STRING "Enable testing of realword sparse matrices contained in the specified path")
38 if(EIGEN_TEST_MATRIX_DIR)
40 message(STATUS "Test realworld sparse matrices: ${EIGEN_TEST_MATRIX_DIR}")
41 add_definitions( -DTEST_REAL_CASES="${EIGEN_TEST_MATRIX_DIR}" )
43 message(STATUS "REAL CASES CAN NOT BE CURRENTLY TESTED ON WIN32")
45 endif(EIGEN_TEST_MATRIX_DIR)
51 add_definitions("-DEIGEN_CHOLMOD_SUPPORT")
52 include_directories(${CHOLMOD_INCLUDES})
53 set(SPARSE_LIBS ${SPARSE_LIBS} ${CHOLMOD_LIBRARIES} ${EIGEN_BLAS_LIBRARIES} ${EIGEN_LAPACK_LIBRARIES})
54 set(CHOLMOD_ALL_LIBS ${CHOLMOD_LIBRARIES} ${EIGEN_BLAS_LIBRARIES} ${EIGEN_LAPACK_LIBRARIES})
55 ei_add_property(EIGEN_TESTED_BACKENDS "Cholmod, ")
57 ei_add_property(EIGEN_MISSING_BACKENDS "Cholmod, ")
62 add_definitions("-DEIGEN_UMFPACK_SUPPORT")
63 include_directories(${UMFPACK_INCLUDES})
64 set(SPARSE_LIBS ${SPARSE_LIBS} ${UMFPACK_LIBRARIES} ${EIGEN_BLAS_LIBRARIES})
65 set(UMFPACK_ALL_LIBS ${UMFPACK_LIBRARIES} ${EIGEN_BLAS_LIBRARIES})
66 ei_add_property(EIGEN_TESTED_BACKENDS "UmfPack, ")
68 ei_add_property(EIGEN_MISSING_BACKENDS "UmfPack, ")
71 find_package(SuperLU 4.0)
73 add_definitions("-DEIGEN_SUPERLU_SUPPORT")
74 include_directories(${SUPERLU_INCLUDES})
75 set(SPARSE_LIBS ${SPARSE_LIBS} ${SUPERLU_LIBRARIES} ${EIGEN_BLAS_LIBRARIES})
76 set(SUPERLU_ALL_LIBS ${SUPERLU_LIBRARIES} ${EIGEN_BLAS_LIBRARIES})
77 ei_add_property(EIGEN_TESTED_BACKENDS "SuperLU, ")
79 ei_add_property(EIGEN_MISSING_BACKENDS "SuperLU, ")
85 find_package(Metis 5.0 REQUIRED)
87 add_definitions("-DEIGEN_PASTIX_SUPPORT")
88 include_directories(${PASTIX_INCLUDES})
90 include_directories(${SCOTCH_INCLUDES})
91 set(PASTIX_LIBRARIES ${PASTIX_LIBRARIES} ${SCOTCH_LIBRARIES})
93 include_directories(${METIS_INCLUDES})
94 set(PASTIX_LIBRARIES ${PASTIX_LIBRARIES} ${METIS_LIBRARIES})
96 ei_add_property(EIGEN_MISSING_BACKENDS "PaStiX, ")
98 set(SPARSE_LIBS ${SPARSE_LIBS} ${PASTIX_LIBRARIES} ${ORDERING_LIBRARIES} ${EIGEN_BLAS_LIBRARIES})
99 set(PASTIX_ALL_LIBS ${PASTIX_LIBRARIES} ${EIGEN_BLAS_LIBRARIES})
100 ei_add_property(EIGEN_TESTED_BACKENDS "PaStiX, ")
102 ei_add_property(EIGEN_MISSING_BACKENDS "PaStiX, ")
106 add_definitions("-DEIGEN_METIS_SUPPORT")
107 include_directories(${METIS_INCLUDES})
108 ei_add_property(EIGEN_TESTED_BACKENDS "METIS, ")
110 ei_add_property(EIGEN_MISSING_BACKENDS "METIS, ")
114 if(SPQR_FOUND AND CHOLMOD_FOUND AND (EIGEN_Fortran_COMPILER_WORKS OR LAPACK_FOUND) )
115 add_definitions("-DEIGEN_SPQR_SUPPORT")
116 include_directories(${SPQR_INCLUDES})
117 set(SPQR_ALL_LIBS ${SPQR_LIBRARIES} ${CHOLMOD_LIBRARIES} ${EIGEN_LAPACK_LIBRARIES} ${EIGEN_BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
118 set(SPARSE_LIBS ${SPARSE_LIBS} ${SPQR_ALL_LIBS})
119 ei_add_property(EIGEN_TESTED_BACKENDS "SPQR, ")
121 ei_add_property(EIGEN_MISSING_BACKENDS "SPQR, ")
124 option(EIGEN_TEST_NOQT "Disable Qt support in unit tests" OFF)
125 if(NOT EIGEN_TEST_NOQT)
128 include(${QT_USE_FILE})
129 ei_add_property(EIGEN_TESTED_BACKENDS "Qt4 support, ")
131 ei_add_property(EIGEN_MISSING_BACKENDS "Qt4 support, ")
133 endif(NOT EIGEN_TEST_NOQT)
136 add_definitions("-DEIGEN_EXTERN_INSTANTIATIONS=1")
139 set_property(GLOBAL PROPERTY EIGEN_CURRENT_SUBPROJECT "Official")
140 add_custom_target(BuildOfficial)
145 ei_add_test(dynalloc)
146 ei_add_test(nomalloc)
147 ei_add_test(first_aligned)
149 ei_add_test(mixingtypes)
150 ei_add_test(packetmath "-DEIGEN_FAST_MATH=1")
151 ei_add_test(unalignedassert)
152 ei_add_test(vectorization_logic)
153 ei_add_test(basicstuff)
154 ei_add_test(constructor)
155 ei_add_test(linearstructure)
156 ei_add_test(integer_types)
157 ei_add_test(unalignedcount)
158 if(NOT EIGEN_TEST_NO_EXCEPTIONS)
159 ei_add_test(exceptions)
167 ei_add_test(conservative_resize)
168 ei_add_test(product_small)
169 ei_add_test(product_large)
170 ei_add_test(product_extra)
171 ei_add_test(diagonalmatrices)
173 ei_add_test(diagonal)
174 ei_add_test(miscmatrices)
175 ei_add_test(commainitializer)
176 ei_add_test(smallvectors)
177 ei_add_test(mapped_matrix)
178 ei_add_test(mapstride)
179 ei_add_test(mapstaticmethods)
181 ei_add_test(array_for_matrix)
182 ei_add_test(array_replicate)
183 ei_add_test(array_reverse)
185 ei_add_test(is_same_dense)
186 ei_add_test(triangular)
187 ei_add_test(selfadjoint)
188 ei_add_test(product_selfadjoint)
189 ei_add_test(product_symm)
190 ei_add_test(product_syrk)
191 ei_add_test(product_trmv)
192 ei_add_test(product_trmm)
193 ei_add_test(product_trsolve)
194 ei_add_test(product_mmtr)
195 ei_add_test(product_notemporary)
196 ei_add_test(stable_norm)
197 ei_add_test(permutationmatrices)
198 ei_add_test(bandmatrix)
199 ei_add_test(cholesky)
201 ei_add_test(determinant)
204 ei_add_test(qr_colpivoting)
205 ei_add_test(qr_fullpivoting)
206 ei_add_test(upperbidiagonalization)
207 ei_add_test(hessenberg)
208 ei_add_test(schur_real)
209 ei_add_test(schur_complex)
210 ei_add_test(eigensolver_selfadjoint)
211 ei_add_test(eigensolver_generic)
212 ei_add_test(eigensolver_complex)
214 ei_add_test(eigensolver_generalized_real)
216 ei_add_test(jacobisvd)
218 ei_add_test(householder)
219 ei_add_test(geo_orthomethods)
220 ei_add_test(geo_quaternion)
221 ei_add_test(geo_eulerangles)
222 ei_add_test(geo_parametrizedline)
223 ei_add_test(geo_alignedbox)
224 ei_add_test(geo_hyperplane)
225 ei_add_test(geo_transformations)
226 ei_add_test(geo_homogeneous)
227 ei_add_test(stdvector)
228 ei_add_test(stdvector_overload)
230 ei_add_test(stdlist_overload)
231 ei_add_test(stddeque)
232 ei_add_test(stddeque_overload)
233 ei_add_test(sparse_basic)
234 ei_add_test(sparse_block)
235 ei_add_test(sparse_vector)
236 ei_add_test(sparse_product)
237 ei_add_test(sparse_ref)
238 ei_add_test(sparse_solvers)
239 ei_add_test(sparse_permutations)
240 ei_add_test(simplicial_cholesky)
241 ei_add_test(conjugate_gradient)
242 ei_add_test(incomplete_cholesky)
243 ei_add_test(bicgstab)
245 ei_add_test(sparselu)
246 ei_add_test(sparseqr)
248 ei_add_test(nesting_ops "${CMAKE_CXX_FLAGS_DEBUG}")
249 ei_add_test(zerosized)
250 ei_add_test(dontalign)
251 ei_add_test(evaluators)
252 if(NOT EIGEN_TEST_NO_EXCEPTIONS)
253 ei_add_test(sizeoverflow)
255 ei_add_test(prec_inverse_4x4)
256 ei_add_test(vectorwiseop)
257 ei_add_test(special_numbers)
258 ei_add_test(rvalue_types)
259 ei_add_test(dense_storage)
260 ei_add_test(ctorleak)
261 ei_add_test(mpl2only)
262 ei_add_test(inplace_decomposition)
263 ei_add_test(half_float)
264 ei_add_test(array_of_string)
266 add_executable(bug1213 bug1213.cpp bug1213_main.cpp)
268 check_cxx_compiler_flag("-ffast-math" COMPILER_SUPPORT_FASTMATH)
269 if(COMPILER_SUPPORT_FASTMATH)
270 set(EIGEN_FASTMATH_FLAGS "-ffast-math")
272 check_cxx_compiler_flag("/fp:fast" COMPILER_SUPPORT_FPFAST)
273 if(COMPILER_SUPPORT_FPFAST)
274 set(EIGEN_FASTMATH_FLAGS "/fp:fast")
278 ei_add_test(fastmath " ${EIGEN_FASTMATH_FLAGS} ")
280 # # ei_add_test(denseLM)
283 ei_add_test(qtvector "" "${QT_QTCORE_LIBRARY}")
287 ei_add_test(umfpack_support "" "${UMFPACK_ALL_LIBS}")
291 ei_add_test(superlu_support "" "${SUPERLU_ALL_LIBS}")
295 ei_add_test(cholmod_support "" "${CHOLMOD_ALL_LIBS}")
299 ei_add_test(pardiso_support "" "${PARDISO_ALL_LIBS}")
302 if(PASTIX_FOUND AND (SCOTCH_FOUND OR METIS_FOUND))
303 ei_add_test(pastix_support "" "${PASTIX_ALL_LIBS}")
306 if(SPQR_FOUND AND CHOLMOD_FOUND)
307 ei_add_test(spqr_support "" "${SPQR_ALL_LIBS}")
311 ei_add_test(metis_support "" "${METIS_LIBRARIES}")
314 string(TOLOWER "${CMAKE_CXX_COMPILER}" cmake_cxx_compiler_tolower)
315 if(cmake_cxx_compiler_tolower MATCHES "qcc")
319 ei_add_property(EIGEN_TESTING_SUMMARY "CXX: ${CMAKE_CXX_COMPILER}\n")
320 if(CMAKE_COMPILER_IS_GNUCXX AND NOT CXX_IS_QCC)
321 execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version COMMAND head -n 1 OUTPUT_VARIABLE EIGEN_CXX_VERSION_STRING OUTPUT_STRIP_TRAILING_WHITESPACE)
322 ei_add_property(EIGEN_TESTING_SUMMARY "CXX_VERSION: ${EIGEN_CXX_VERSION_STRING}\n")
324 ei_add_property(EIGEN_TESTING_SUMMARY "CXX_FLAGS: ${CMAKE_CXX_FLAGS}\n")
325 ei_add_property(EIGEN_TESTING_SUMMARY "Sparse lib flags: ${SPARSE_LIBS}\n")
327 option(EIGEN_TEST_EIGEN2 "Run whole Eigen2 test suite against EIGEN2_SUPPORT" OFF)
328 mark_as_advanced(EIGEN_TEST_EIGEN2)
329 if(EIGEN_TEST_EIGEN2)
330 message(WARNING "The Eigen2 test suite has been removed")
336 include_directories(${Boost_INCLUDE_DIRS})
337 ei_add_test(boostmultiprec "" "${Boost_LIBRARIES}")
338 ei_add_property(EIGEN_TESTED_BACKENDS "Boost.Multiprecision, ")
340 ei_add_property(EIGEN_MISSING_BACKENDS "Boost.Multiprecision, ")
345 option(EIGEN_TEST_CUDA "Enable CUDA support in unit tests" OFF)
346 option(EIGEN_TEST_CUDA_CLANG "Use clang instead of nvcc to compile the CUDA tests" OFF)
348 if(EIGEN_TEST_CUDA_CLANG AND NOT CMAKE_CXX_COMPILER MATCHES "clang")
349 message(WARNING "EIGEN_TEST_CUDA_CLANG is set, but CMAKE_CXX_COMPILER does not appear to be clang.")
354 find_package(CUDA 5.0)
357 set(CUDA_PROPAGATE_HOST_FLAGS OFF)
358 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
359 set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_C_COMPILER}" CACHE STRING "nvcc flags" FORCE)
361 if(EIGEN_TEST_CUDA_CLANG)
362 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 --cuda-gpu-arch=sm_30")
364 cuda_include_directories(${CMAKE_CURRENT_BINARY_DIR})
365 set(EIGEN_ADD_TEST_FILENAME_EXTENSION "cu")
367 ei_add_test(cuda_basic)
369 unset(EIGEN_ADD_TEST_FILENAME_EXTENSION)
373 endif(EIGEN_TEST_CUDA)
376 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/failtests)
377 add_test(NAME failtests WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/failtests COMMAND ${CMAKE_COMMAND} ${Eigen_SOURCE_DIR} -G "${CMAKE_GENERATOR}" -DEIGEN_FAILTEST=ON)
379 option(EIGEN_TEST_BUILD_DOCUMENTATION "Test building the doxygen documentation" OFF)
380 IF(EIGEN_TEST_BUILD_DOCUMENTATION)
381 add_dependencies(buildtests doc)