You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

355 lines
11 KiB

  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 "")
  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()
  14. endif()
  15. # check if we have a Fortran compiler
  16. include("../cmake/language_support.cmake")
  17. workaround_9220(Fortran EIGEN_Fortran_COMPILER_WORKS)
  18. if(EIGEN_Fortran_COMPILER_WORKS)
  19. enable_language(Fortran OPTIONAL)
  20. if(NOT CMAKE_Fortran_COMPILER)
  21. set(EIGEN_Fortran_COMPILER_WORKS OFF)
  22. endif()
  23. endif()
  24. if(NOT EIGEN_Fortran_COMPILER_WORKS)
  25. # search for a default Lapack library to complete Eigen's one
  26. find_package(LAPACK)
  27. endif()
  28. # configure blas/lapack (use Eigen's ones)
  29. set(EIGEN_BLAS_LIBRARIES eigen_blas)
  30. set(EIGEN_LAPACK_LIBRARIES eigen_lapack)
  31. set(EIGEN_TEST_MATRIX_DIR "" CACHE STRING "Enable testing of realword sparse matrices contained in the specified path")
  32. if(EIGEN_TEST_MATRIX_DIR)
  33. if(NOT WIN32)
  34. message(STATUS "Test realworld sparse matrices: ${EIGEN_TEST_MATRIX_DIR}")
  35. add_definitions( -DTEST_REAL_CASES="${EIGEN_TEST_MATRIX_DIR}" )
  36. else(NOT WIN32)
  37. message(STATUS "REAL CASES CAN NOT BE CURRENTLY TESTED ON WIN32")
  38. endif(NOT WIN32)
  39. endif(EIGEN_TEST_MATRIX_DIR)
  40. set(SPARSE_LIBS " ")
  41. find_package(Cholmod)
  42. if(CHOLMOD_FOUND)
  43. add_definitions("-DEIGEN_CHOLMOD_SUPPORT")
  44. include_directories(${CHOLMOD_INCLUDES})
  45. set(SPARSE_LIBS ${SPARSE_LIBS} ${CHOLMOD_LIBRARIES} ${EIGEN_BLAS_LIBRARIES} ${EIGEN_LAPACK_LIBRARIES})
  46. set(CHOLMOD_ALL_LIBS ${CHOLMOD_LIBRARIES} ${EIGEN_BLAS_LIBRARIES} ${EIGEN_LAPACK_LIBRARIES})
  47. ei_add_property(EIGEN_TESTED_BACKENDS "Cholmod, ")
  48. else()
  49. ei_add_property(EIGEN_MISSING_BACKENDS "Cholmod, ")
  50. endif()
  51. find_package(Umfpack)
  52. if(UMFPACK_FOUND)
  53. add_definitions("-DEIGEN_UMFPACK_SUPPORT")
  54. include_directories(${UMFPACK_INCLUDES})
  55. set(SPARSE_LIBS ${SPARSE_LIBS} ${UMFPACK_LIBRARIES} ${EIGEN_BLAS_LIBRARIES})
  56. set(UMFPACK_ALL_LIBS ${UMFPACK_LIBRARIES} ${EIGEN_BLAS_LIBRARIES})
  57. ei_add_property(EIGEN_TESTED_BACKENDS "UmfPack, ")
  58. else()
  59. ei_add_property(EIGEN_MISSING_BACKENDS "UmfPack, ")
  60. endif()
  61. find_package(SuperLU 4.0)
  62. if(SUPERLU_FOUND)
  63. add_definitions("-DEIGEN_SUPERLU_SUPPORT")
  64. include_directories(${SUPERLU_INCLUDES})
  65. set(SPARSE_LIBS ${SPARSE_LIBS} ${SUPERLU_LIBRARIES} ${EIGEN_BLAS_LIBRARIES})
  66. set(SUPERLU_ALL_LIBS ${SUPERLU_LIBRARIES} ${EIGEN_BLAS_LIBRARIES})
  67. ei_add_property(EIGEN_TESTED_BACKENDS "SuperLU, ")
  68. else()
  69. ei_add_property(EIGEN_MISSING_BACKENDS "SuperLU, ")
  70. endif()
  71. find_package(Pastix)
  72. find_package(Scotch)
  73. find_package(Metis 5.0 REQUIRED)
  74. if(PASTIX_FOUND)
  75. add_definitions("-DEIGEN_PASTIX_SUPPORT")
  76. include_directories(${PASTIX_INCLUDES})
  77. if(SCOTCH_FOUND)
  78. include_directories(${SCOTCH_INCLUDES})
  79. set(PASTIX_LIBRARIES ${PASTIX_LIBRARIES} ${SCOTCH_LIBRARIES})
  80. elseif(METIS_FOUND)
  81. include_directories(${METIS_INCLUDES})
  82. set(PASTIX_LIBRARIES ${PASTIX_LIBRARIES} ${METIS_LIBRARIES})
  83. else(SCOTCH_FOUND)
  84. ei_add_property(EIGEN_MISSING_BACKENDS "PaStiX, ")
  85. endif(SCOTCH_FOUND)
  86. set(SPARSE_LIBS ${SPARSE_LIBS} ${PASTIX_LIBRARIES} ${ORDERING_LIBRARIES} ${EIGEN_BLAS_LIBRARIES})
  87. set(PASTIX_ALL_LIBS ${PASTIX_LIBRARIES} ${EIGEN_BLAS_LIBRARIES})
  88. ei_add_property(EIGEN_TESTED_BACKENDS "PaStiX, ")
  89. else()
  90. ei_add_property(EIGEN_MISSING_BACKENDS "PaStiX, ")
  91. endif()
  92. if(METIS_FOUND)
  93. add_definitions("-DEIGEN_METIS_SUPPORT")
  94. include_directories(${METIS_INCLUDES})
  95. ei_add_property(EIGEN_TESTED_BACKENDS "METIS, ")
  96. else()
  97. ei_add_property(EIGEN_MISSING_BACKENDS "METIS, ")
  98. endif()
  99. find_package(SPQR)
  100. if(SPQR_FOUND AND CHOLMOD_FOUND AND (EIGEN_Fortran_COMPILER_WORKS OR LAPACK_FOUND) )
  101. add_definitions("-DEIGEN_SPQR_SUPPORT")
  102. include_directories(${SPQR_INCLUDES})
  103. set(SPQR_ALL_LIBS ${SPQR_LIBRARIES} ${CHOLMOD_LIBRARIES} ${EIGEN_LAPACK_LIBRARIES} ${EIGEN_BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
  104. set(SPARSE_LIBS ${SPARSE_LIBS} ${SPQR_ALL_LIBS})
  105. ei_add_property(EIGEN_TESTED_BACKENDS "SPQR, ")
  106. else()
  107. ei_add_property(EIGEN_MISSING_BACKENDS "SPQR, ")
  108. endif()
  109. option(EIGEN_TEST_NOQT "Disable Qt support in unit tests" OFF)
  110. if(NOT EIGEN_TEST_NOQT)
  111. find_package(Qt4)
  112. if(QT4_FOUND)
  113. include(${QT_USE_FILE})
  114. ei_add_property(EIGEN_TESTED_BACKENDS "Qt4 support, ")
  115. else()
  116. ei_add_property(EIGEN_MISSING_BACKENDS "Qt4 support, ")
  117. endif()
  118. endif(NOT EIGEN_TEST_NOQT)
  119. if(TEST_LIB)
  120. add_definitions("-DEIGEN_EXTERN_INSTANTIATIONS=1")
  121. endif(TEST_LIB)
  122. set_property(GLOBAL PROPERTY EIGEN_CURRENT_SUBPROJECT "Official")
  123. add_custom_target(BuildOfficial)
  124. ei_add_test(rand)
  125. ei_add_test(meta)
  126. ei_add_test(sizeof)
  127. ei_add_test(dynalloc)
  128. ei_add_test(nomalloc)
  129. ei_add_test(first_aligned)
  130. ei_add_test(nullary)
  131. ei_add_test(mixingtypes)
  132. ei_add_test(packetmath)
  133. ei_add_test(unalignedassert)
  134. ei_add_test(vectorization_logic)
  135. ei_add_test(basicstuff)
  136. ei_add_test(linearstructure)
  137. ei_add_test(integer_types)
  138. ei_add_test(unalignedcount)
  139. if(NOT EIGEN_TEST_NO_EXCEPTIONS)
  140. ei_add_test(exceptions)
  141. endif()
  142. ei_add_test(redux)
  143. ei_add_test(visitor)
  144. ei_add_test(block)
  145. ei_add_test(corners)
  146. ei_add_test(swap)
  147. ei_add_test(resize)
  148. ei_add_test(conservative_resize)
  149. ei_add_test(product_small)
  150. ei_add_test(product_large)
  151. ei_add_test(product_extra)
  152. ei_add_test(diagonalmatrices)
  153. ei_add_test(adjoint)
  154. ei_add_test(diagonal)
  155. ei_add_test(miscmatrices)
  156. ei_add_test(commainitializer)
  157. ei_add_test(smallvectors)
  158. ei_add_test(mapped_matrix)
  159. ei_add_test(mapstride)
  160. ei_add_test(mapstaticmethods)
  161. ei_add_test(array)
  162. ei_add_test(array_for_matrix)
  163. ei_add_test(array_replicate)
  164. ei_add_test(array_reverse)
  165. ei_add_test(ref)
  166. ei_add_test(is_same_dense)
  167. ei_add_test(triangular)
  168. ei_add_test(selfadjoint)
  169. ei_add_test(product_selfadjoint)
  170. ei_add_test(product_symm)
  171. ei_add_test(product_syrk)
  172. ei_add_test(product_trmv)
  173. ei_add_test(product_trmm)
  174. ei_add_test(product_trsolve)
  175. ei_add_test(product_mmtr)
  176. ei_add_test(product_notemporary)
  177. ei_add_test(stable_norm)
  178. ei_add_test(permutationmatrices)
  179. ei_add_test(bandmatrix)
  180. ei_add_test(cholesky)
  181. ei_add_test(lu)
  182. ei_add_test(determinant)
  183. ei_add_test(inverse)
  184. ei_add_test(qr)
  185. ei_add_test(qr_colpivoting)
  186. ei_add_test(qr_fullpivoting)
  187. ei_add_test(upperbidiagonalization)
  188. ei_add_test(hessenberg)
  189. ei_add_test(schur_real)
  190. ei_add_test(schur_complex)
  191. ei_add_test(eigensolver_selfadjoint)
  192. ei_add_test(eigensolver_generic)
  193. ei_add_test(eigensolver_complex)
  194. ei_add_test(real_qz)
  195. ei_add_test(eigensolver_generalized_real)
  196. ei_add_test(jacobi)
  197. ei_add_test(jacobisvd)
  198. ei_add_test(bdcsvd)
  199. ei_add_test(householder)
  200. ei_add_test(geo_orthomethods)
  201. ei_add_test(geo_quaternion)
  202. ei_add_test(geo_eulerangles)
  203. ei_add_test(geo_parametrizedline)
  204. ei_add_test(geo_alignedbox)
  205. ei_add_test(geo_hyperplane)
  206. ei_add_test(geo_transformations)
  207. ei_add_test(geo_homogeneous)
  208. ei_add_test(stdvector)
  209. ei_add_test(stdvector_overload)
  210. ei_add_test(stdlist)
  211. ei_add_test(stddeque)
  212. ei_add_test(sparse_basic)
  213. ei_add_test(sparse_block)
  214. ei_add_test(sparse_vector)
  215. ei_add_test(sparse_product)
  216. ei_add_test(sparse_ref)
  217. ei_add_test(sparse_solvers)
  218. ei_add_test(sparse_permutations)
  219. ei_add_test(simplicial_cholesky)
  220. ei_add_test(conjugate_gradient)
  221. ei_add_test(incomplete_cholesky)
  222. ei_add_test(bicgstab)
  223. ei_add_test(lscg)
  224. ei_add_test(sparselu)
  225. ei_add_test(sparseqr)
  226. ei_add_test(umeyama)
  227. ei_add_test(nesting_ops "${CMAKE_CXX_FLAGS_DEBUG}")
  228. ei_add_test(zerosized)
  229. ei_add_test(dontalign)
  230. ei_add_test(evaluators)
  231. if(NOT EIGEN_TEST_NO_EXCEPTIONS)
  232. ei_add_test(sizeoverflow)
  233. endif()
  234. ei_add_test(prec_inverse_4x4)
  235. ei_add_test(vectorwiseop)
  236. ei_add_test(special_numbers)
  237. ei_add_test(rvalue_types)
  238. ei_add_test(dense_storage)
  239. ei_add_test(ctorleak)
  240. ei_add_test(mpl2only)
  241. check_cxx_compiler_flag("-ffast-math" COMPILER_SUPPORT_FASTMATH)
  242. if(COMPILER_SUPPORT_FASTMATH)
  243. set(EIGEN_FASTMATH_FLAGS "-ffast-math")
  244. else()
  245. check_cxx_compiler_flag("/fp:fast" COMPILER_SUPPORT_FPFAST)
  246. if(COMPILER_SUPPORT_FPFAST)
  247. set(EIGEN_FASTMATH_FLAGS "/fp:fast")
  248. endif()
  249. endif()
  250. ei_add_test(fastmath " ${EIGEN_FASTMATH_FLAGS} ")
  251. # # ei_add_test(denseLM)
  252. if(QT4_FOUND)
  253. ei_add_test(qtvector "" "${QT_QTCORE_LIBRARY}")
  254. endif(QT4_FOUND)
  255. if(UMFPACK_FOUND)
  256. ei_add_test(umfpack_support "" "${UMFPACK_ALL_LIBS}")
  257. endif()
  258. if(SUPERLU_FOUND)
  259. ei_add_test(superlu_support "" "${SUPERLU_ALL_LIBS}")
  260. endif()
  261. if(CHOLMOD_FOUND)
  262. ei_add_test(cholmod_support "" "${CHOLMOD_ALL_LIBS}")
  263. endif()
  264. if(PARDISO_FOUND)
  265. ei_add_test(pardiso_support "" "${PARDISO_ALL_LIBS}")
  266. endif()
  267. if(PASTIX_FOUND AND (SCOTCH_FOUND OR METIS_FOUND))
  268. ei_add_test(pastix_support "" "${PASTIX_ALL_LIBS}")
  269. endif()
  270. if(SPQR_FOUND AND CHOLMOD_FOUND)
  271. ei_add_test(spqr_support "" "${SPQR_ALL_LIBS}")
  272. endif()
  273. if(METIS_FOUND)
  274. ei_add_test(metis_support "" "${METIS_LIBRARIES}")
  275. endif()
  276. string(TOLOWER "${CMAKE_CXX_COMPILER}" cmake_cxx_compiler_tolower)
  277. if(cmake_cxx_compiler_tolower MATCHES "qcc")
  278. set(CXX_IS_QCC "ON")
  279. endif()
  280. ei_add_property(EIGEN_TESTING_SUMMARY "CXX: ${CMAKE_CXX_COMPILER}\n")
  281. if(CMAKE_COMPILER_IS_GNUCXX AND NOT CXX_IS_QCC)
  282. execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version COMMAND head -n 1 OUTPUT_VARIABLE EIGEN_CXX_VERSION_STRING OUTPUT_STRIP_TRAILING_WHITESPACE)
  283. ei_add_property(EIGEN_TESTING_SUMMARY "CXX_VERSION: ${EIGEN_CXX_VERSION_STRING}\n")
  284. endif()
  285. ei_add_property(EIGEN_TESTING_SUMMARY "CXX_FLAGS: ${CMAKE_CXX_FLAGS}\n")
  286. ei_add_property(EIGEN_TESTING_SUMMARY "Sparse lib flags: ${SPARSE_LIBS}\n")
  287. option(EIGEN_TEST_EIGEN2 "Run whole Eigen2 test suite against EIGEN2_SUPPORT" OFF)
  288. mark_as_advanced(EIGEN_TEST_EIGEN2)
  289. if(EIGEN_TEST_EIGEN2)
  290. message(WARNING "The Eigen2 test suite has been removed")
  291. endif()
  292. # NVCC unit tests
  293. option(EIGEN_TEST_NVCC "Enable NVCC support in unit tests" OFF)
  294. if(EIGEN_TEST_NVCC)
  295. find_package(CUDA 5.0)
  296. if(CUDA_FOUND)
  297. set(CUDA_PROPAGATE_HOST_FLAGS OFF)
  298. if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  299. set(CUDA_NVCC_FLAGS "-ccbin /usr/bin/clang" CACHE STRING "nvcc flags" FORCE)
  300. endif()
  301. cuda_include_directories(${CMAKE_CURRENT_BINARY_DIR})
  302. set(EIGEN_ADD_TEST_FILENAME_EXTENSION "cu")
  303. ei_add_test(cuda_basic)
  304. unset(EIGEN_ADD_TEST_FILENAME_EXTENSION)
  305. endif(CUDA_FOUND)
  306. endif(EIGEN_TEST_NVCC)
  307. file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/failtests)
  308. add_test(NAME failtests WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/failtests COMMAND ${CMAKE_COMMAND} ${Eigen_SOURCE_DIR} -G "${CMAKE_GENERATOR}" -DEIGEN_FAILTEST=ON)
  309. option(EIGEN_TEST_BUILD_DOCUMENTATION "Test building the doxygen documentation" OFF)
  310. IF(EIGEN_TEST_BUILD_DOCUMENTATION)
  311. add_dependencies(buildtests doc)
  312. ENDIF()