2 project(EigenLapack CXX)
4 include("../cmake/language_support.cmake")
6 workaround_9220(Fortran EIGEN_Fortran_COMPILER_WORKS)
8 if(EIGEN_Fortran_COMPILER_WORKS)
9 enable_language(Fortran OPTIONAL)
10 if(NOT CMAKE_Fortran_COMPILER)
11 set(EIGEN_Fortran_COMPILER_WORKS OFF)
15 add_custom_target(lapack)
16 include_directories(../blas)
19 single.cpp double.cpp complex_single.cpp complex_double.cpp ../blas/xerbla.cpp
22 if(EIGEN_Fortran_COMPILER_WORKS)
24 set(EigenLapack_SRCS ${EigenLapack_SRCS}
25 slarft.f dlarft.f clarft.f zlarft.f
26 slarfb.f dlarfb.f clarfb.f zlarfb.f
27 slarfg.f dlarfg.f clarfg.f zlarfg.f
28 slarf.f dlarf.f clarf.f zlarf.f
29 sladiv.f dladiv.f cladiv.f zladiv.f
30 ilaslr.f iladlr.f ilaclr.f ilazlr.f
31 ilaslc.f iladlc.f ilaclc.f ilazlc.f
32 dlapy2.f dlapy3.f slapy2.f slapy3.f
35 second_NONE.f dsecnd_NONE.f
38 option(EIGEN_ENABLE_LAPACK_TESTS OFF "Enbale the Lapack unit tests")
40 if(EIGEN_ENABLE_LAPACK_TESTS)
42 get_filename_component(eigen_full_path_to_reference_lapack "./reference/" ABSOLUTE)
43 if(NOT EXISTS ${eigen_full_path_to_reference_lapack})
44 # Download lapack and install sources and testing at the right place
45 message(STATUS "Download lapack_addons_3.4.1.tgz...")
47 file(DOWNLOAD "http://downloads.tuxfamily.org/eigen/lapack_addons_3.4.1.tgz"
48 "${CMAKE_CURRENT_SOURCE_DIR}/lapack_addons_3.4.1.tgz"
51 STATUS download_status
52 EXPECTED_MD5 5758ce55afcf79da98de8b9de1615ad5
55 message(STATUS ${download_status})
56 list(GET download_status 0 download_status_num)
57 set(download_status_num 0)
58 if(download_status_num EQUAL 0)
59 message(STATUS "Setup lapack reference and lapack unit tests")
60 execute_process(COMMAND tar xzf "lapack_addons_3.4.1.tgz" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
62 message(STATUS "Download of lapack_addons_3.4.1.tgz failed, LAPACK unit tests wont be enabled")
63 set(EIGEN_ENABLE_LAPACK_TESTS false)
68 get_filename_component(eigen_full_path_to_reference_lapack "./reference/" ABSOLUTE)
69 if(EXISTS ${eigen_full_path_to_reference_lapack})
70 set(EigenLapack_funcfilenames
71 ssyev.f dsyev.f csyev.f zsyev.f
72 spotrf.f dpotrf.f cpotrf.f zpotrf.f
73 spotrs.f dpotrs.f cpotrs.f zpotrs.f
74 sgetrf.f dgetrf.f cgetrf.f zgetrf.f
75 sgetrs.f dgetrs.f cgetrs.f zgetrs.f)
77 FILE(GLOB ReferenceLapack_SRCS0 RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "reference/*.f")
78 foreach(filename1 IN LISTS ReferenceLapack_SRCS0)
79 string(REPLACE "reference/" "" filename ${filename1})
80 list(FIND EigenLapack_SRCS ${filename} id1)
81 list(FIND EigenLapack_funcfilenames ${filename} id2)
82 if((id1 EQUAL -1) AND (id2 EQUAL -1))
83 set(ReferenceLapack_SRCS ${ReferenceLapack_SRCS} reference/${filename})
89 endif(EIGEN_ENABLE_LAPACK_TESTS)
91 endif(EIGEN_Fortran_COMPILER_WORKS)
93 add_library(eigen_lapack_static ${EigenLapack_SRCS} ${ReferenceLapack_SRCS})
94 add_library(eigen_lapack SHARED ${EigenLapack_SRCS})
96 target_link_libraries(eigen_lapack eigen_blas)
98 if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
99 target_link_libraries(eigen_lapack_static ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
100 target_link_libraries(eigen_lapack ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
103 add_dependencies(lapack eigen_lapack eigen_lapack_static)
105 install(TARGETS eigen_lapack eigen_lapack_static
106 RUNTIME DESTINATION bin
107 LIBRARY DESTINATION lib
108 ARCHIVE DESTINATION lib)
112 get_filename_component(eigen_full_path_to_testing_lapack "./testing/" ABSOLUTE)
113 if(EXISTS ${eigen_full_path_to_testing_lapack})
115 # The following comes from lapack/TESTING/CMakeLists.txt
117 find_package(PythonInterp)
118 message(STATUS "Looking for Python found - ${PYTHONINTERP_FOUND}")
119 if (PYTHONINTERP_FOUND)
120 message(STATUS "Using Python version ${PYTHON_VERSION_STRING}")
123 set(LAPACK_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
124 set(LAPACK_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
125 set(BUILD_SINGLE true)
126 set(BUILD_DOUBLE true)
127 set(BUILD_COMPLEX true)
128 set(BUILD_COMPLEX16E true)
131 # string(REPLACE "/STACK:10000000" "/STACK:900000000000000000"
132 # CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
133 string(REGEX REPLACE "(.*)/STACK:(.*) (.*)" "\\1/STACK:900000000000000000 \\3"
134 CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
136 add_subdirectory(testing/MATGEN)
137 add_subdirectory(testing/LIN)
138 add_subdirectory(testing/EIG)
139 macro(add_lapack_test output input target)
140 set(TEST_INPUT "${LAPACK_SOURCE_DIR}/testing/${input}")
141 set(TEST_OUTPUT "${LAPACK_BINARY_DIR}/testing/${output}")
142 get_target_property(TEST_LOC ${target} LOCATION)
143 string(REPLACE "." "_" input_name ${input})
144 set(testName "${target}_${input_name}")
145 if(EXISTS "${TEST_INPUT}")
146 add_test(LAPACK-${testName} "${CMAKE_COMMAND}"
148 -DINPUT=${TEST_INPUT}
149 -DOUTPUT=${TEST_OUTPUT}
150 -DINTDIR=${CMAKE_CFG_INTDIR}
151 -P "${LAPACK_SOURCE_DIR}/testing/runtest.cmake")
153 endmacro(add_lapack_test)
156 add_lapack_test(stest.out stest.in xlintsts)
158 # ======== SINGLE RFP LIN TESTS ========================
159 add_lapack_test(stest_rfp.out stest_rfp.in xlintstrfs)
162 # ======== SINGLE EIG TESTS ===========================
165 add_lapack_test(snep.out nep.in xeigtsts)
168 add_lapack_test(ssep.out sep.in xeigtsts)
171 add_lapack_test(ssvd.out svd.in xeigtsts)
174 add_lapack_test(sec.out sec.in xeigtsts)
177 add_lapack_test(sed.out sed.in xeigtsts)
180 add_lapack_test(sgg.out sgg.in xeigtsts)
183 add_lapack_test(sgd.out sgd.in xeigtsts)
186 add_lapack_test(ssb.out ssb.in xeigtsts)
189 add_lapack_test(ssg.out ssg.in xeigtsts)
192 add_lapack_test(sbal.out sbal.in xeigtsts)
195 add_lapack_test(sbak.out sbak.in xeigtsts)
198 add_lapack_test(sgbal.out sgbal.in xeigtsts)
201 add_lapack_test(sgbak.out sgbak.in xeigtsts)
204 add_lapack_test(sbb.out sbb.in xeigtsts)
207 add_lapack_test(sglm.out glm.in xeigtsts)
210 add_lapack_test(sgqr.out gqr.in xeigtsts)
213 add_lapack_test(sgsv.out gsv.in xeigtsts)
216 add_lapack_test(scsd.out csd.in xeigtsts)
219 add_lapack_test(slse.out lse.in xeigtsts)
224 # ======== DOUBLE LIN TESTS ===========================
225 add_lapack_test(dtest.out dtest.in xlintstd)
227 # ======== DOUBLE RFP LIN TESTS ========================
228 add_lapack_test(dtest_rfp.out dtest_rfp.in xlintstrfd)
230 # ======== DOUBLE EIG TESTS ===========================
232 add_lapack_test(dnep.out nep.in xeigtstd)
235 add_lapack_test(dsep.out sep.in xeigtstd)
238 add_lapack_test(dsvd.out svd.in xeigtstd)
241 add_lapack_test(dec.out dec.in xeigtstd)
244 add_lapack_test(ded.out ded.in xeigtstd)
247 add_lapack_test(dgg.out dgg.in xeigtstd)
250 add_lapack_test(dgd.out dgd.in xeigtstd)
253 add_lapack_test(dsb.out dsb.in xeigtstd)
256 add_lapack_test(dsg.out dsg.in xeigtstd)
259 add_lapack_test(dbal.out dbal.in xeigtstd)
262 add_lapack_test(dbak.out dbak.in xeigtstd)
265 add_lapack_test(dgbal.out dgbal.in xeigtstd)
268 add_lapack_test(dgbak.out dgbak.in xeigtstd)
271 add_lapack_test(dbb.out dbb.in xeigtstd)
274 add_lapack_test(dglm.out glm.in xeigtstd)
277 add_lapack_test(dgqr.out gqr.in xeigtstd)
280 add_lapack_test(dgsv.out gsv.in xeigtstd)
283 add_lapack_test(dcsd.out csd.in xeigtstd)
286 add_lapack_test(dlse.out lse.in xeigtstd)
290 add_lapack_test(ctest.out ctest.in xlintstc)
292 # ======== COMPLEX RFP LIN TESTS ========================
293 add_lapack_test(ctest_rfp.out ctest_rfp.in xlintstrfc)
295 # ======== COMPLEX EIG TESTS ===========================
297 add_lapack_test(cnep.out nep.in xeigtstc)
300 add_lapack_test(csep.out sep.in xeigtstc)
303 add_lapack_test(csvd.out svd.in xeigtstc)
306 add_lapack_test(cec.out cec.in xeigtstc)
309 add_lapack_test(ced.out ced.in xeigtstc)
312 add_lapack_test(cgg.out cgg.in xeigtstc)
315 add_lapack_test(cgd.out cgd.in xeigtstc)
318 add_lapack_test(csb.out csb.in xeigtstc)
321 add_lapack_test(csg.out csg.in xeigtstc)
324 add_lapack_test(cbal.out cbal.in xeigtstc)
327 add_lapack_test(cbak.out cbak.in xeigtstc)
330 add_lapack_test(cgbal.out cgbal.in xeigtstc)
333 add_lapack_test(cgbak.out cgbak.in xeigtstc)
336 add_lapack_test(cbb.out cbb.in xeigtstc)
339 add_lapack_test(cglm.out glm.in xeigtstc)
342 add_lapack_test(cgqr.out gqr.in xeigtstc)
345 add_lapack_test(cgsv.out gsv.in xeigtstc)
348 add_lapack_test(ccsd.out csd.in xeigtstc)
351 add_lapack_test(clse.out lse.in xeigtstc)
356 # ======== COMPLEX16 LIN TESTS ========================
357 add_lapack_test(ztest.out ztest.in xlintstz)
359 # ======== COMPLEX16 RFP LIN TESTS ========================
360 add_lapack_test(ztest_rfp.out ztest_rfp.in xlintstrfz)
362 # ======== COMPLEX16 EIG TESTS ===========================
364 add_lapack_test(znep.out nep.in xeigtstz)
367 add_lapack_test(zsep.out sep.in xeigtstz)
370 add_lapack_test(zsvd.out svd.in xeigtstz)
373 add_lapack_test(zec.out zec.in xeigtstz)
376 add_lapack_test(zed.out zed.in xeigtstz)
379 add_lapack_test(zgg.out zgg.in xeigtstz)
382 add_lapack_test(zgd.out zgd.in xeigtstz)
385 add_lapack_test(zsb.out zsb.in xeigtstz)
388 add_lapack_test(zsg.out zsg.in xeigtstz)
391 add_lapack_test(zbal.out zbal.in xeigtstz)
394 add_lapack_test(zbak.out zbak.in xeigtstz)
397 add_lapack_test(zgbal.out zgbal.in xeigtstz)
400 add_lapack_test(zgbak.out zgbak.in xeigtstz)
403 add_lapack_test(zbb.out zbb.in xeigtstz)
406 add_lapack_test(zglm.out glm.in xeigtstz)
409 add_lapack_test(zgqr.out gqr.in xeigtstz)
412 add_lapack_test(zgsv.out gsv.in xeigtstz)
415 add_lapack_test(zcsd.out csd.in xeigtstz)
418 add_lapack_test(zlse.out lse.in xeigtstz)
425 # ======== SINGLE-DOUBLE PROTO LIN TESTS ==============
426 add_lapack_test(dstest.out dstest.in xlintstds)
434 # ======== COMPLEX-COMPLEX16 LIN TESTS ========================
435 add_lapack_test(zctest.out zctest.in xlintstzc)
439 # ==============================================================================
441 execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${LAPACK_SOURCE_DIR}/testing/lapack_testing.py ${LAPACK_BINARY_DIR})
443 NAME LAPACK_Test_Summary
444 WORKING_DIRECTORY ${LAPACK_BINARY_DIR}
445 COMMAND ${PYTHON_EXECUTABLE} "lapack_testing.py"