Merged in f5soh/librepilot/update_credits (pull request #529)
[librepilot.git] / ground / gcs / src / libs / eigen / test / CMakeLists.txt
blob2141d07c2b760401be6631795bc6b525752a9b21
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()
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)
25   endif()
26 endif()
28 if(NOT EIGEN_Fortran_COMPILER_WORKS)
29   # search for a default Lapack library to complete Eigen's one
30   find_package(LAPACK)
31 endif()
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)
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)
45 endif(EIGEN_TEST_MATRIX_DIR)
47 set(SPARSE_LIBS " ")
49 find_package(Cholmod)
50 if(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, ")
56 else()
57   ei_add_property(EIGEN_MISSING_BACKENDS "Cholmod, ")
58 endif()
60 find_package(Umfpack)
61 if(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, ")
67 else()
68   ei_add_property(EIGEN_MISSING_BACKENDS "UmfPack, ")
69 endif()
71 find_package(SuperLU 4.0)
72 if(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, ")
78 else()
79   ei_add_property(EIGEN_MISSING_BACKENDS  "SuperLU, ")
80 endif()
83 find_package(Pastix)
84 find_package(Scotch)
85 find_package(Metis 5.0 REQUIRED)
86 if(PASTIX_FOUND)
87   add_definitions("-DEIGEN_PASTIX_SUPPORT")
88   include_directories(${PASTIX_INCLUDES})
89   if(SCOTCH_FOUND)
90     include_directories(${SCOTCH_INCLUDES})
91     set(PASTIX_LIBRARIES ${PASTIX_LIBRARIES} ${SCOTCH_LIBRARIES})
92   elseif(METIS_FOUND)
93     include_directories(${METIS_INCLUDES})
94     set(PASTIX_LIBRARIES ${PASTIX_LIBRARIES} ${METIS_LIBRARIES})
95   else(SCOTCH_FOUND)
96     ei_add_property(EIGEN_MISSING_BACKENDS  "PaStiX, ")
97   endif(SCOTCH_FOUND)
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, ")
101 else()
102   ei_add_property(EIGEN_MISSING_BACKENDS  "PaStiX, ")
103 endif()
105 if(METIS_FOUND)
106   add_definitions("-DEIGEN_METIS_SUPPORT")
107   include_directories(${METIS_INCLUDES})
108   ei_add_property(EIGEN_TESTED_BACKENDS "METIS, ")
109 else()
110   ei_add_property(EIGEN_MISSING_BACKENDS "METIS, ")
111 endif()
113 find_package(SPQR)
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, ")
120 else()
121   ei_add_property(EIGEN_MISSING_BACKENDS "SPQR, ")
122 endif()
124 option(EIGEN_TEST_NOQT "Disable Qt support in unit tests" OFF)
125 if(NOT EIGEN_TEST_NOQT)
126   find_package(Qt4)
127   if(QT4_FOUND)
128     include(${QT_USE_FILE})
129     ei_add_property(EIGEN_TESTED_BACKENDS  "Qt4 support, ")
130   else()
131     ei_add_property(EIGEN_MISSING_BACKENDS  "Qt4 support, ")
132   endif()
133 endif(NOT EIGEN_TEST_NOQT)
135 if(TEST_LIB)
136   add_definitions("-DEIGEN_EXTERN_INSTANTIATIONS=1")
137 endif(TEST_LIB)
139 set_property(GLOBAL PROPERTY EIGEN_CURRENT_SUBPROJECT "Official")
140 add_custom_target(BuildOfficial)
142 ei_add_test(rand)
143 ei_add_test(meta)
144 ei_add_test(sizeof)
145 ei_add_test(dynalloc)
146 ei_add_test(nomalloc)
147 ei_add_test(first_aligned)
148 ei_add_test(nullary)
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)
160 endif()
161 ei_add_test(redux)
162 ei_add_test(visitor)
163 ei_add_test(block)
164 ei_add_test(corners)
165 ei_add_test(swap)
166 ei_add_test(resize)
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)
172 ei_add_test(adjoint)
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)
180 ei_add_test(array)
181 ei_add_test(array_for_matrix)
182 ei_add_test(array_replicate)
183 ei_add_test(array_reverse)
184 ei_add_test(ref)
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)
200 ei_add_test(lu)
201 ei_add_test(determinant)
202 ei_add_test(inverse)
203 ei_add_test(qr)
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)
213 ei_add_test(real_qz)
214 ei_add_test(eigensolver_generalized_real)
215 ei_add_test(jacobi)
216 ei_add_test(jacobisvd)
217 ei_add_test(bdcsvd)
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)
229 ei_add_test(stdlist)
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)
244 ei_add_test(lscg)
245 ei_add_test(sparselu)
246 ei_add_test(sparseqr)
247 ei_add_test(umeyama)
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)
254 endif()
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")
271 else()
272   check_cxx_compiler_flag("/fp:fast" COMPILER_SUPPORT_FPFAST)
273   if(COMPILER_SUPPORT_FPFAST)
274     set(EIGEN_FASTMATH_FLAGS "/fp:fast")
275   endif()
276 endif()
278 ei_add_test(fastmath " ${EIGEN_FASTMATH_FLAGS} ")
280 # # ei_add_test(denseLM)
282 if(QT4_FOUND)
283   ei_add_test(qtvector "" "${QT_QTCORE_LIBRARY}")
284 endif(QT4_FOUND)
286 if(UMFPACK_FOUND)
287   ei_add_test(umfpack_support "" "${UMFPACK_ALL_LIBS}")
288 endif()
290 if(SUPERLU_FOUND)
291   ei_add_test(superlu_support "" "${SUPERLU_ALL_LIBS}")
292 endif()
294 if(CHOLMOD_FOUND)
295   ei_add_test(cholmod_support "" "${CHOLMOD_ALL_LIBS}")
296 endif()
298 if(PARDISO_FOUND)
299   ei_add_test(pardiso_support "" "${PARDISO_ALL_LIBS}")
300 endif()
302 if(PASTIX_FOUND AND (SCOTCH_FOUND OR METIS_FOUND))
303   ei_add_test(pastix_support "" "${PASTIX_ALL_LIBS}")
304 endif()
306 if(SPQR_FOUND AND CHOLMOD_FOUND)
307   ei_add_test(spqr_support "" "${SPQR_ALL_LIBS}")
308 endif()
310 if(METIS_FOUND)
311 ei_add_test(metis_support "" "${METIS_LIBRARIES}")
312 endif()
314 string(TOLOWER "${CMAKE_CXX_COMPILER}" cmake_cxx_compiler_tolower)
315 if(cmake_cxx_compiler_tolower MATCHES "qcc")
316   set(CXX_IS_QCC "ON")
317 endif()
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")
323 endif()
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")
331 endif()
333 # boost MP unit test
334 find_package(Boost)
335 if(Boost_FOUND)
336   include_directories(${Boost_INCLUDE_DIRS})
337   ei_add_test(boostmultiprec "" "${Boost_LIBRARIES}")
338   ei_add_property(EIGEN_TESTED_BACKENDS "Boost.Multiprecision, ")
339 else()
340   ei_add_property(EIGEN_MISSING_BACKENDS "Boost.Multiprecision, ")
341 endif()
344 # CUDA unit tests
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.")
350 endif()
352 if(EIGEN_TEST_CUDA)
354 find_package(CUDA 5.0)
355 if(CUDA_FOUND)
356   
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)
360   endif()
361   if(EIGEN_TEST_CUDA_CLANG)
362    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 --cuda-gpu-arch=sm_30")
363   endif()
364   cuda_include_directories(${CMAKE_CURRENT_BINARY_DIR})
365   set(EIGEN_ADD_TEST_FILENAME_EXTENSION  "cu")
366   
367   ei_add_test(cuda_basic)
368   
369   unset(EIGEN_ADD_TEST_FILENAME_EXTENSION)
371 endif(CUDA_FOUND)
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)
382 ENDIF()