• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# generate split test header file only if it does not yet exist
2# in order to prevent a rebuild everytime cmake is configured
3if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/split_test_helper.h)
4  file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/split_test_helper.h "")
5  foreach(i RANGE 1 999)
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"
9      "#else\n"
10      "#define CALL_SUBTEST_${i}(FUNC)\n"
11      "#endif\n\n"
12    )
13  endforeach()
14endif()
15
16# check if we have a Fortran compiler
17include("../cmake/language_support.cmake")
18
19workaround_9220(Fortran EIGEN_Fortran_COMPILER_WORKS)
20
21if(EIGEN_Fortran_COMPILER_WORKS)
22  enable_language(Fortran OPTIONAL)
23  if(NOT CMAKE_Fortran_COMPILER)
24    set(EIGEN_Fortran_COMPILER_WORKS OFF)
25  endif()
26endif()
27
28if(NOT EIGEN_Fortran_COMPILER_WORKS)
29  # search for a default Lapack library to complete Eigen's one
30  find_package(LAPACK QUIET)
31endif()
32
33# configure blas/lapack (use Eigen's ones)
34set(EIGEN_BLAS_LIBRARIES eigen_blas)
35set(EIGEN_LAPACK_LIBRARIES eigen_lapack)
36
37set(EIGEN_TEST_MATRIX_DIR "" CACHE STRING "Enable testing of realword sparse matrices contained in the specified path")
38if(EIGEN_TEST_MATRIX_DIR)
39  if(NOT WIN32)
40    message(STATUS "Test realworld sparse matrices: ${EIGEN_TEST_MATRIX_DIR}")
41    add_definitions( -DTEST_REAL_CASES="${EIGEN_TEST_MATRIX_DIR}" )
42  else(NOT WIN32)
43    message(STATUS "REAL CASES CAN NOT BE CURRENTLY TESTED ON WIN32")
44  endif(NOT WIN32)
45endif(EIGEN_TEST_MATRIX_DIR)
46
47set(SPARSE_LIBS " ")
48
49find_package(Cholmod)
50if(CHOLMOD_FOUND)
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, ")
56else()
57  ei_add_property(EIGEN_MISSING_BACKENDS "Cholmod, ")
58endif()
59
60find_package(Umfpack)
61if(UMFPACK_FOUND)
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, ")
67else()
68  ei_add_property(EIGEN_MISSING_BACKENDS "UmfPack, ")
69endif()
70
71find_package(SuperLU 4.0)
72if(SUPERLU_FOUND)
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, ")
78else()
79  ei_add_property(EIGEN_MISSING_BACKENDS  "SuperLU, ")
80endif()
81
82
83find_package(PASTIX QUIET COMPONENTS METIS SCOTCH)
84# check that the PASTIX found is a version without MPI
85find_path(PASTIX_pastix_nompi.h_INCLUDE_DIRS
86  NAMES pastix_nompi.h
87  HINTS ${PASTIX_INCLUDE_DIRS}
88)
89if (NOT PASTIX_pastix_nompi.h_INCLUDE_DIRS)
90  message(STATUS "A version of Pastix has been found but pastix_nompi.h does not exist in the include directory."
91                 " Because Eigen tests require a version without MPI, we disable the Pastix backend.")
92endif()
93if(PASTIX_FOUND AND PASTIX_pastix_nompi.h_INCLUDE_DIRS)
94  add_definitions("-DEIGEN_PASTIX_SUPPORT")
95  include_directories(${PASTIX_INCLUDE_DIRS_DEP})
96  if(SCOTCH_FOUND)
97    include_directories(${SCOTCH_INCLUDE_DIRS})
98    set(PASTIX_LIBRARIES ${PASTIX_LIBRARIES} ${SCOTCH_LIBRARIES})
99  elseif(METIS_FOUND)
100    include_directories(${METIS_INCLUDE_DIRS})
101    set(PASTIX_LIBRARIES ${PASTIX_LIBRARIES} ${METIS_LIBRARIES})
102  else(SCOTCH_FOUND)
103    ei_add_property(EIGEN_MISSING_BACKENDS  "PaStiX, ")
104  endif(SCOTCH_FOUND)
105  set(SPARSE_LIBS ${SPARSE_LIBS} ${PASTIX_LIBRARIES_DEP} ${ORDERING_LIBRARIES})
106  set(PASTIX_ALL_LIBS ${PASTIX_LIBRARIES_DEP})
107  ei_add_property(EIGEN_TESTED_BACKENDS  "PaStiX, ")
108else()
109  ei_add_property(EIGEN_MISSING_BACKENDS  "PaStiX, ")
110endif()
111
112if(METIS_FOUND)
113  add_definitions("-DEIGEN_METIS_SUPPORT")
114  include_directories(${METIS_INCLUDE_DIRS})
115  ei_add_property(EIGEN_TESTED_BACKENDS "METIS, ")
116else()
117  ei_add_property(EIGEN_MISSING_BACKENDS "METIS, ")
118endif()
119
120find_package(SPQR)
121if(SPQR_FOUND AND CHOLMOD_FOUND AND (EIGEN_Fortran_COMPILER_WORKS OR LAPACK_FOUND) )
122  add_definitions("-DEIGEN_SPQR_SUPPORT")
123  include_directories(${SPQR_INCLUDES})
124  set(SPQR_ALL_LIBS ${SPQR_LIBRARIES} ${CHOLMOD_LIBRARIES} ${EIGEN_LAPACK_LIBRARIES} ${EIGEN_BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
125  set(SPARSE_LIBS ${SPARSE_LIBS} ${SPQR_ALL_LIBS})
126  ei_add_property(EIGEN_TESTED_BACKENDS "SPQR, ")
127else()
128  ei_add_property(EIGEN_MISSING_BACKENDS "SPQR, ")
129endif()
130
131option(EIGEN_TEST_NOQT "Disable Qt support in unit tests" OFF)
132if(NOT EIGEN_TEST_NOQT)
133  find_package(Qt4)
134  if(QT4_FOUND)
135    include(${QT_USE_FILE})
136    ei_add_property(EIGEN_TESTED_BACKENDS  "Qt4 support, ")
137  else()
138    ei_add_property(EIGEN_MISSING_BACKENDS  "Qt4 support, ")
139  endif()
140endif(NOT EIGEN_TEST_NOQT)
141
142if(TEST_LIB)
143  add_definitions("-DEIGEN_EXTERN_INSTANTIATIONS=1")
144endif(TEST_LIB)
145
146set_property(GLOBAL PROPERTY EIGEN_CURRENT_SUBPROJECT "Official")
147add_custom_target(BuildOfficial)
148
149ei_add_test(rand)
150ei_add_test(meta)
151ei_add_test(numext)
152ei_add_test(sizeof)
153ei_add_test(dynalloc)
154ei_add_test(nomalloc)
155ei_add_test(first_aligned)
156ei_add_test(nullary)
157ei_add_test(mixingtypes)
158ei_add_test(packetmath "-DEIGEN_FAST_MATH=1")
159ei_add_test(unalignedassert)
160ei_add_test(vectorization_logic)
161ei_add_test(basicstuff)
162ei_add_test(constructor)
163ei_add_test(linearstructure)
164ei_add_test(integer_types)
165ei_add_test(unalignedcount)
166if(NOT EIGEN_TEST_NO_EXCEPTIONS)
167  ei_add_test(exceptions)
168endif()
169ei_add_test(redux)
170ei_add_test(visitor)
171ei_add_test(block)
172ei_add_test(corners)
173ei_add_test(swap)
174ei_add_test(resize)
175ei_add_test(conservative_resize)
176ei_add_test(product_small)
177ei_add_test(product_large)
178ei_add_test(product_extra)
179ei_add_test(diagonalmatrices)
180ei_add_test(adjoint)
181ei_add_test(diagonal)
182ei_add_test(miscmatrices)
183ei_add_test(commainitializer)
184ei_add_test(smallvectors)
185ei_add_test(mapped_matrix)
186ei_add_test(mapstride)
187ei_add_test(mapstaticmethods)
188ei_add_test(array)
189ei_add_test(array_for_matrix)
190ei_add_test(array_replicate)
191ei_add_test(array_reverse)
192ei_add_test(ref)
193ei_add_test(is_same_dense)
194ei_add_test(triangular)
195ei_add_test(selfadjoint)
196ei_add_test(product_selfadjoint)
197ei_add_test(product_symm)
198ei_add_test(product_syrk)
199ei_add_test(product_trmv)
200ei_add_test(product_trmm)
201ei_add_test(product_trsolve)
202ei_add_test(product_mmtr)
203ei_add_test(product_notemporary)
204ei_add_test(stable_norm)
205ei_add_test(permutationmatrices)
206ei_add_test(bandmatrix)
207ei_add_test(cholesky)
208ei_add_test(lu)
209ei_add_test(determinant)
210ei_add_test(inverse)
211ei_add_test(qr)
212ei_add_test(qr_colpivoting)
213ei_add_test(qr_fullpivoting)
214ei_add_test(upperbidiagonalization)
215ei_add_test(hessenberg)
216ei_add_test(schur_real)
217ei_add_test(schur_complex)
218ei_add_test(eigensolver_selfadjoint)
219ei_add_test(eigensolver_generic)
220ei_add_test(eigensolver_complex)
221ei_add_test(real_qz)
222ei_add_test(eigensolver_generalized_real)
223ei_add_test(jacobi)
224ei_add_test(jacobisvd)
225ei_add_test(bdcsvd)
226ei_add_test(householder)
227ei_add_test(geo_orthomethods)
228ei_add_test(geo_quaternion)
229ei_add_test(geo_eulerangles)
230ei_add_test(geo_parametrizedline)
231ei_add_test(geo_alignedbox)
232ei_add_test(geo_hyperplane)
233ei_add_test(geo_transformations)
234ei_add_test(geo_homogeneous)
235ei_add_test(stdvector)
236ei_add_test(stdvector_overload)
237ei_add_test(stdlist)
238ei_add_test(stdlist_overload)
239ei_add_test(stddeque)
240ei_add_test(stddeque_overload)
241ei_add_test(sparse_basic)
242ei_add_test(sparse_block)
243ei_add_test(sparse_vector)
244ei_add_test(sparse_product)
245ei_add_test(sparse_ref)
246ei_add_test(sparse_solvers)
247ei_add_test(sparse_permutations)
248ei_add_test(simplicial_cholesky)
249ei_add_test(conjugate_gradient)
250ei_add_test(incomplete_cholesky)
251ei_add_test(bicgstab)
252ei_add_test(lscg)
253ei_add_test(sparselu)
254ei_add_test(sparseqr)
255ei_add_test(umeyama)
256ei_add_test(nesting_ops "${CMAKE_CXX_FLAGS_DEBUG}")
257ei_add_test(zerosized)
258ei_add_test(dontalign)
259ei_add_test(evaluators)
260if(NOT EIGEN_TEST_NO_EXCEPTIONS)
261  ei_add_test(sizeoverflow)
262endif()
263ei_add_test(prec_inverse_4x4)
264ei_add_test(vectorwiseop)
265ei_add_test(special_numbers)
266ei_add_test(rvalue_types)
267ei_add_test(dense_storage)
268ei_add_test(ctorleak)
269ei_add_test(mpl2only)
270ei_add_test(inplace_decomposition)
271ei_add_test(half_float)
272ei_add_test(array_of_string)
273
274add_executable(bug1213 bug1213.cpp bug1213_main.cpp)
275
276check_cxx_compiler_flag("-ffast-math" COMPILER_SUPPORT_FASTMATH)
277if(COMPILER_SUPPORT_FASTMATH)
278  set(EIGEN_FASTMATH_FLAGS "-ffast-math")
279else()
280  check_cxx_compiler_flag("/fp:fast" COMPILER_SUPPORT_FPFAST)
281  if(COMPILER_SUPPORT_FPFAST)
282    set(EIGEN_FASTMATH_FLAGS "/fp:fast")
283  endif()
284endif()
285
286ei_add_test(fastmath " ${EIGEN_FASTMATH_FLAGS} ")
287
288# # ei_add_test(denseLM)
289
290if(QT4_FOUND)
291  ei_add_test(qtvector "" "${QT_QTCORE_LIBRARY}")
292endif(QT4_FOUND)
293
294if(UMFPACK_FOUND)
295  ei_add_test(umfpack_support "" "${UMFPACK_ALL_LIBS}")
296endif()
297
298if(SUPERLU_FOUND)
299  ei_add_test(superlu_support "" "${SUPERLU_ALL_LIBS}")
300endif()
301
302if(CHOLMOD_FOUND)
303  ei_add_test(cholmod_support "" "${CHOLMOD_ALL_LIBS}")
304endif()
305
306if(PARDISO_FOUND)
307  ei_add_test(pardiso_support "" "${PARDISO_ALL_LIBS}")
308endif()
309
310if(PASTIX_FOUND AND (SCOTCH_FOUND OR METIS_FOUND))
311  ei_add_test(pastix_support "" "${PASTIX_ALL_LIBS}")
312endif()
313
314if(SPQR_FOUND AND CHOLMOD_FOUND)
315  ei_add_test(spqr_support "" "${SPQR_ALL_LIBS}")
316endif()
317
318if(METIS_FOUND)
319ei_add_test(metis_support "" "${METIS_LIBRARIES}")
320endif()
321
322string(TOLOWER "${CMAKE_CXX_COMPILER}" cmake_cxx_compiler_tolower)
323if(cmake_cxx_compiler_tolower MATCHES "qcc")
324  set(CXX_IS_QCC "ON")
325endif()
326
327ei_add_property(EIGEN_TESTING_SUMMARY "CXX:               ${CMAKE_CXX_COMPILER}\n")
328if(CMAKE_COMPILER_IS_GNUCXX AND NOT CXX_IS_QCC)
329  execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version COMMAND head -n 1 OUTPUT_VARIABLE EIGEN_CXX_VERSION_STRING OUTPUT_STRIP_TRAILING_WHITESPACE)
330  ei_add_property(EIGEN_TESTING_SUMMARY "CXX_VERSION:       ${EIGEN_CXX_VERSION_STRING}\n")
331endif()
332ei_add_property(EIGEN_TESTING_SUMMARY "CXX_FLAGS:         ${CMAKE_CXX_FLAGS}\n")
333ei_add_property(EIGEN_TESTING_SUMMARY "Sparse lib flags:  ${SPARSE_LIBS}\n")
334
335option(EIGEN_TEST_EIGEN2 "Run whole Eigen2 test suite against EIGEN2_SUPPORT" OFF)
336mark_as_advanced(EIGEN_TEST_EIGEN2)
337if(EIGEN_TEST_EIGEN2)
338  message(WARNING "The Eigen2 test suite has been removed")
339endif()
340
341# boost MP unit test
342find_package(Boost)
343if(Boost_FOUND)
344  include_directories(${Boost_INCLUDE_DIRS})
345  ei_add_test(boostmultiprec "" "${Boost_LIBRARIES}")
346  ei_add_property(EIGEN_TESTED_BACKENDS "Boost.Multiprecision, ")
347else()
348  ei_add_property(EIGEN_MISSING_BACKENDS "Boost.Multiprecision, ")
349endif()
350
351
352# CUDA unit tests
353option(EIGEN_TEST_CUDA "Enable CUDA support in unit tests" OFF)
354option(EIGEN_TEST_CUDA_CLANG "Use clang instead of nvcc to compile the CUDA tests" OFF)
355
356if(EIGEN_TEST_CUDA_CLANG AND NOT CMAKE_CXX_COMPILER MATCHES "clang")
357  message(WARNING "EIGEN_TEST_CUDA_CLANG is set, but CMAKE_CXX_COMPILER does not appear to be clang.")
358endif()
359
360if(EIGEN_TEST_CUDA)
361
362find_package(CUDA 5.0)
363if(CUDA_FOUND)
364
365  set(CUDA_PROPAGATE_HOST_FLAGS OFF)
366  if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
367    set(CUDA_NVCC_FLAGS "-ccbin ${CMAKE_C_COMPILER}" CACHE STRING "nvcc flags" FORCE)
368  endif()
369  if(EIGEN_TEST_CUDA_CLANG)
370   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 --cuda-gpu-arch=sm_30")
371  endif()
372  cuda_include_directories(${CMAKE_CURRENT_BINARY_DIR})
373  set(EIGEN_ADD_TEST_FILENAME_EXTENSION  "cu")
374
375  ei_add_test(cuda_basic)
376
377  unset(EIGEN_ADD_TEST_FILENAME_EXTENSION)
378
379endif(CUDA_FOUND)
380
381endif(EIGEN_TEST_CUDA)
382
383
384file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/failtests)
385add_test(NAME failtests WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/failtests COMMAND ${CMAKE_COMMAND} ${Eigen_SOURCE_DIR} -G "${CMAKE_GENERATOR}" -DEIGEN_FAILTEST=ON)
386
387option(EIGEN_TEST_BUILD_DOCUMENTATION "Test building the doxygen documentation" OFF)
388IF(EIGEN_TEST_BUILD_DOCUMENTATION)
389  add_dependencies(buildtests doc)
390ENDIF()
391