blob: a92a2978b0daad8d1709be22167ee09879b997ac [file] [log] [blame]
Brian Silverman72890c22015-09-19 14:37:37 -04001
2macro(ei_add_property prop value)
Austin Schuh189376f2018-12-20 22:11:15 +11003 get_property(previous GLOBAL PROPERTY ${prop})
Brian Silverman72890c22015-09-19 14:37:37 -04004 if ((NOT previous) OR (previous STREQUAL ""))
5 set_property(GLOBAL PROPERTY ${prop} "${value}")
6 else()
7 set_property(GLOBAL PROPERTY ${prop} "${previous} ${value}")
Austin Schuh189376f2018-12-20 22:11:15 +11008 endif()
Brian Silverman72890c22015-09-19 14:37:37 -04009endmacro(ei_add_property)
10
11#internal. See documentation of ei_add_test for details.
12macro(ei_add_test_internal testname testname_with_suffix)
13 set(targetname ${testname_with_suffix})
14
Austin Schuh189376f2018-12-20 22:11:15 +110015 if(EIGEN_ADD_TEST_FILENAME_EXTENSION)
16 set(filename ${testname}.${EIGEN_ADD_TEST_FILENAME_EXTENSION})
17 else()
18 set(filename ${testname}.cpp)
19 endif()
20
21 if(EIGEN_ADD_TEST_FILENAME_EXTENSION STREQUAL cu)
22 if(EIGEN_TEST_CUDA_CLANG)
23 set_source_files_properties(${filename} PROPERTIES LANGUAGE CXX)
24 if(CUDA_64_BIT_DEVICE_CODE)
25 link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64")
26 else()
27 link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib")
28 endif()
29 if (${ARGC} GREATER 2)
30 add_executable(${targetname} ${filename})
31 else()
32 add_executable(${targetname} ${filename} OPTIONS ${ARGV2})
33 endif()
34 target_link_libraries(${targetname} "cudart_static" "cuda" "dl" "rt" "pthread")
35 else()
36 if (${ARGC} GREATER 2)
37 cuda_add_executable(${targetname} ${filename} OPTIONS ${ARGV2})
38 else()
39 cuda_add_executable(${targetname} ${filename})
40 endif()
41 endif()
42 else()
43 add_executable(${targetname} ${filename})
44 endif()
45
Brian Silverman72890c22015-09-19 14:37:37 -040046 if (targetname MATCHES "^eigen2_")
47 add_dependencies(eigen2_buildtests ${targetname})
48 else()
49 add_dependencies(buildtests ${targetname})
50 endif()
51
52 if(EIGEN_NO_ASSERTION_CHECKING)
53 ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_NO_ASSERTION_CHECKING=1")
54 else(EIGEN_NO_ASSERTION_CHECKING)
55 if(EIGEN_DEBUG_ASSERTS)
56 ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_DEBUG_ASSERTS=1")
57 endif(EIGEN_DEBUG_ASSERTS)
58 endif(EIGEN_NO_ASSERTION_CHECKING)
Austin Schuh189376f2018-12-20 22:11:15 +110059
Brian Silverman72890c22015-09-19 14:37:37 -040060 ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_MAX_SIZE=${EIGEN_TEST_MAX_SIZE}")
61
62 ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_FUNC=${testname}")
Austin Schuh189376f2018-12-20 22:11:15 +110063
64 if(MSVC)
Brian Silverman72890c22015-09-19 14:37:37 -040065 ei_add_target_property(${targetname} COMPILE_FLAGS "/bigobj")
Austin Schuh189376f2018-12-20 22:11:15 +110066 endif()
Brian Silverman72890c22015-09-19 14:37:37 -040067
68 # let the user pass flags.
69 if(${ARGC} GREATER 2)
70 ei_add_target_property(${targetname} COMPILE_FLAGS "${ARGV2}")
71 endif(${ARGC} GREATER 2)
Austin Schuh189376f2018-12-20 22:11:15 +110072
Brian Silverman72890c22015-09-19 14:37:37 -040073 if(EIGEN_TEST_CUSTOM_CXX_FLAGS)
74 ei_add_target_property(${targetname} COMPILE_FLAGS "${EIGEN_TEST_CUSTOM_CXX_FLAGS}")
75 endif()
76
77 if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
78 target_link_libraries(${targetname} ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
79 endif()
80 if(EXTERNAL_LIBS)
81 target_link_libraries(${targetname} ${EXTERNAL_LIBS})
82 endif()
83 if(EIGEN_TEST_CUSTOM_LINKER_FLAGS)
84 target_link_libraries(${targetname} ${EIGEN_TEST_CUSTOM_LINKER_FLAGS})
85 endif()
86
87 if(${ARGC} GREATER 3)
88 set(libs_to_link ${ARGV3})
89 # it could be that some cmake module provides a bad library string " " (just spaces),
90 # and that severely breaks target_link_libraries ("can't link to -l-lstdc++" errors).
91 # so we check for strings containing only spaces.
92 string(STRIP "${libs_to_link}" libs_to_link_stripped)
93 string(LENGTH "${libs_to_link_stripped}" libs_to_link_stripped_length)
94 if(${libs_to_link_stripped_length} GREATER 0)
95 # notice: no double quotes around ${libs_to_link} here. It may be a list.
96 target_link_libraries(${targetname} ${libs_to_link})
97 endif()
Brian Silverman72890c22015-09-19 14:37:37 -040098 endif()
Austin Schuh189376f2018-12-20 22:11:15 +110099
100 add_test(${testname_with_suffix} "${targetname}")
101
Brian Silverman72890c22015-09-19 14:37:37 -0400102 # Specify target and test labels accoirding to EIGEN_CURRENT_SUBPROJECT
Austin Schuh189376f2018-12-20 22:11:15 +1100103 get_property(current_subproject GLOBAL PROPERTY EIGEN_CURRENT_SUBPROJECT)
Brian Silverman72890c22015-09-19 14:37:37 -0400104 if ((current_subproject) AND (NOT (current_subproject STREQUAL "")))
105 set_property(TARGET ${targetname} PROPERTY LABELS "Build${current_subproject}")
106 add_dependencies("Build${current_subproject}" ${targetname})
107 set_property(TEST ${testname_with_suffix} PROPERTY LABELS "${current_subproject}")
108 endif()
109
110endmacro(ei_add_test_internal)
111
Austin Schuh189376f2018-12-20 22:11:15 +1100112# SYCL
113macro(ei_add_test_internal_sycl testname testname_with_suffix)
114 include_directories( SYSTEM ${COMPUTECPP_PACKAGE_ROOT_DIR}/include)
115 set(targetname ${testname_with_suffix})
116
117 if(EIGEN_ADD_TEST_FILENAME_EXTENSION)
118 set(filename ${testname}.${EIGEN_ADD_TEST_FILENAME_EXTENSION})
119 else()
120 set(filename ${testname}.cpp)
121 endif()
122
123 set( include_file ${CMAKE_CURRENT_BINARY_DIR}/inc_${filename})
124 set( bc_file ${CMAKE_CURRENT_BINARY_DIR}/${filename})
125 set( host_file ${CMAKE_CURRENT_SOURCE_DIR}/${filename})
126
127 ADD_CUSTOM_COMMAND(
128 OUTPUT ${include_file}
129 COMMAND ${CMAKE_COMMAND} -E echo "\\#include \\\"${host_file}\\\"" > ${include_file}
130 COMMAND ${CMAKE_COMMAND} -E echo "\\#include \\\"${bc_file}.sycl\\\"" >> ${include_file}
131 DEPENDS ${filename} ${bc_file}.sycl
132 COMMENT "Building ComputeCpp integration header file ${include_file}"
133 )
134 # Add a custom target for the generated integration header
135 add_custom_target(${testname}_integration_header_sycl DEPENDS ${include_file})
136
137 add_executable(${targetname} ${include_file})
138 add_dependencies(${targetname} ${testname}_integration_header_sycl)
139 add_sycl_to_target(${targetname} ${filename} ${CMAKE_CURRENT_BINARY_DIR})
140
141 if (targetname MATCHES "^eigen2_")
142 add_dependencies(eigen2_buildtests ${targetname})
143 else()
144 add_dependencies(buildtests ${targetname})
145 endif()
146
147 if(EIGEN_NO_ASSERTION_CHECKING)
148 ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_NO_ASSERTION_CHECKING=1")
149 else(EIGEN_NO_ASSERTION_CHECKING)
150 if(EIGEN_DEBUG_ASSERTS)
151 ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_DEBUG_ASSERTS=1")
152 endif(EIGEN_DEBUG_ASSERTS)
153 endif(EIGEN_NO_ASSERTION_CHECKING)
154
155 ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_MAX_SIZE=${EIGEN_TEST_MAX_SIZE}")
156
157 ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_FUNC=${testname}")
158
159 if(MSVC AND NOT EIGEN_SPLIT_LARGE_TESTS)
160 ei_add_target_property(${targetname} COMPILE_FLAGS "/bigobj")
161 endif()
162
163 # let the user pass flags.
164 if(${ARGC} GREATER 2)
165 ei_add_target_property(${targetname} COMPILE_FLAGS "${ARGV2}")
166 endif(${ARGC} GREATER 2)
167
168 if(EIGEN_TEST_CUSTOM_CXX_FLAGS)
169 ei_add_target_property(${targetname} COMPILE_FLAGS "${EIGEN_TEST_CUSTOM_CXX_FLAGS}")
170 endif()
171
172 if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
173 target_link_libraries(${targetname} ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
174 endif()
175 if(EXTERNAL_LIBS)
176 target_link_libraries(${targetname} ${EXTERNAL_LIBS})
177 endif()
178 if(EIGEN_TEST_CUSTOM_LINKER_FLAGS)
179 target_link_libraries(${targetname} ${EIGEN_TEST_CUSTOM_LINKER_FLAGS})
180 endif()
181
182 if(${ARGC} GREATER 3)
183 set(libs_to_link ${ARGV3})
184 # it could be that some cmake module provides a bad library string " " (just spaces),
185 # and that severely breaks target_link_libraries ("can't link to -l-lstdc++" errors).
186 # so we check for strings containing only spaces.
187 string(STRIP "${libs_to_link}" libs_to_link_stripped)
188 string(LENGTH "${libs_to_link_stripped}" libs_to_link_stripped_length)
189 if(${libs_to_link_stripped_length} GREATER 0)
190 # notice: no double quotes around ${libs_to_link} here. It may be a list.
191 target_link_libraries(${targetname} ${libs_to_link})
192 endif()
193 endif()
194
195 add_test(${testname_with_suffix} "${targetname}")
196
197 # Specify target and test labels according to EIGEN_CURRENT_SUBPROJECT
198 get_property(current_subproject GLOBAL PROPERTY EIGEN_CURRENT_SUBPROJECT)
199 if ((current_subproject) AND (NOT (current_subproject STREQUAL "")))
200 set_property(TARGET ${targetname} PROPERTY LABELS "Build${current_subproject}")
201 add_dependencies("Build${current_subproject}" ${targetname})
202 set_property(TEST ${testname_with_suffix} PROPERTY LABELS "${current_subproject}")
203 endif()
204
205
206endmacro(ei_add_test_internal_sycl)
207
208
Brian Silverman72890c22015-09-19 14:37:37 -0400209# Macro to add a test
210#
211# the unique mandatory parameter testname must correspond to a file
212# <testname>.cpp which follows this pattern:
213#
214# #include "main.h"
215# void test_<testname>() { ... }
216#
217# Depending on the contents of that file, this macro can have 2 behaviors,
218# see below.
219#
220# The optional 2nd parameter is libraries to link to.
221#
222# A. Default behavior
223#
224# this macro adds an executable <testname> as well as a ctest test
225# named <testname> too.
226#
227# On platforms with bash simply run:
228# "ctest -V" or "ctest -V -R <testname>"
229# On other platform use ctest as usual
230#
231# B. Multi-part behavior
232#
233# If the source file matches the regexp
234# CALL_SUBTEST_[0-9]+|EIGEN_TEST_PART_[0-9]+
235# then it is interpreted as a multi-part test. The behavior then depends on the
236# CMake option EIGEN_SPLIT_LARGE_TESTS, which is ON by default.
237#
238# If EIGEN_SPLIT_LARGE_TESTS is OFF, the behavior is the same as in A (the multi-part
239# aspect is ignored).
240#
241# If EIGEN_SPLIT_LARGE_TESTS is ON, the test is split into multiple executables
242# test_<testname>_<N>
243# where N runs from 1 to the greatest occurence found in the source file. Each of these
244# executables is built passing -DEIGEN_TEST_PART_N. This allows to split large tests
245# into smaller executables.
246#
247# Moreover, targets <testname> are still generated, they
248# have the effect of building all the parts of the test.
249#
250# Again, ctest -R allows to run all matching tests.
251macro(ei_add_test testname)
252 get_property(EIGEN_TESTS_LIST GLOBAL PROPERTY EIGEN_TESTS_LIST)
253 set(EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}${testname}\n")
254 set_property(GLOBAL PROPERTY EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}")
255
Austin Schuh189376f2018-12-20 22:11:15 +1100256 if(EIGEN_ADD_TEST_FILENAME_EXTENSION)
257 set(filename ${testname}.${EIGEN_ADD_TEST_FILENAME_EXTENSION})
258 else()
259 set(filename ${testname}.cpp)
260 endif()
261
262 file(READ "${filename}" test_source)
Brian Silverman72890c22015-09-19 14:37:37 -0400263 set(parts 0)
264 string(REGEX MATCHALL "CALL_SUBTEST_[0-9]+|EIGEN_TEST_PART_[0-9]+|EIGEN_SUFFIXES(;[0-9]+)+"
265 occurences "${test_source}")
266 string(REGEX REPLACE "CALL_SUBTEST_|EIGEN_TEST_PART_|EIGEN_SUFFIXES" "" suffixes "${occurences}")
267 list(REMOVE_DUPLICATES suffixes)
268 if(EIGEN_SPLIT_LARGE_TESTS AND suffixes)
269 add_custom_target(${testname})
270 foreach(suffix ${suffixes})
271 ei_add_test_internal(${testname} ${testname}_${suffix}
272 "${ARGV1} -DEIGEN_TEST_PART_${suffix}=1" "${ARGV2}")
273 add_dependencies(${testname} ${testname}_${suffix})
274 endforeach(suffix)
275 else(EIGEN_SPLIT_LARGE_TESTS AND suffixes)
276 set(symbols_to_enable_all_parts "")
277 foreach(suffix ${suffixes})
278 set(symbols_to_enable_all_parts
279 "${symbols_to_enable_all_parts} -DEIGEN_TEST_PART_${suffix}=1")
280 endforeach(suffix)
281 ei_add_test_internal(${testname} ${testname} "${ARGV1} ${symbols_to_enable_all_parts}" "${ARGV2}")
282 endif(EIGEN_SPLIT_LARGE_TESTS AND suffixes)
283endmacro(ei_add_test)
284
Austin Schuh189376f2018-12-20 22:11:15 +1100285macro(ei_add_test_sycl testname)
286 get_property(EIGEN_TESTS_LIST GLOBAL PROPERTY EIGEN_TESTS_LIST)
287 set(EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}${testname}\n")
288 set_property(GLOBAL PROPERTY EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}")
289
290 if(EIGEN_ADD_TEST_FILENAME_EXTENSION)
291 set(filename ${testname}.${EIGEN_ADD_TEST_FILENAME_EXTENSION})
292 else()
293 set(filename ${testname}.cpp)
294 endif()
295
296 file(READ "${filename}" test_source)
297 set(parts 0)
298 string(REGEX MATCHALL "CALL_SUBTEST_[0-9]+|EIGEN_TEST_PART_[0-9]+|EIGEN_SUFFIXES(;[0-9]+)+"
299 occurences "${test_source}")
300 string(REGEX REPLACE "CALL_SUBTEST_|EIGEN_TEST_PART_|EIGEN_SUFFIXES" "" suffixes "${occurences}")
301 list(REMOVE_DUPLICATES suffixes)
302 if(EIGEN_SPLIT_LARGE_TESTS AND suffixes)
303 add_custom_target(${testname})
304 foreach(suffix ${suffixes})
305 ei_add_test_internal_sycl(${testname} ${testname}_${suffix}
306 "${ARGV1} -DEIGEN_TEST_PART_${suffix}=1" "${ARGV2}")
307 add_dependencies(${testname} ${testname}_${suffix})
308 endforeach(suffix)
309 else(EIGEN_SPLIT_LARGE_TESTS AND suffixes)
310 set(symbols_to_enable_all_parts "")
311 foreach(suffix ${suffixes})
312 set(symbols_to_enable_all_parts
313 "${symbols_to_enable_all_parts} -DEIGEN_TEST_PART_${suffix}=1")
314 endforeach(suffix)
315 ei_add_test_internal_sycl(${testname} ${testname} "${ARGV1} ${symbols_to_enable_all_parts}" "${ARGV2}")
316 endif(EIGEN_SPLIT_LARGE_TESTS AND suffixes)
317endmacro(ei_add_test_sycl)
Brian Silverman72890c22015-09-19 14:37:37 -0400318
319# adds a failtest, i.e. a test that succeed if the program fails to compile
320# note that the test runner for these is CMake itself, when passed -DEIGEN_FAILTEST=ON
321# so here we're just running CMake commands immediately, we're not adding any targets.
322macro(ei_add_failtest testname)
323 get_property(EIGEN_FAILTEST_FAILURE_COUNT GLOBAL PROPERTY EIGEN_FAILTEST_FAILURE_COUNT)
324 get_property(EIGEN_FAILTEST_COUNT GLOBAL PROPERTY EIGEN_FAILTEST_COUNT)
325
326 message(STATUS "Checking failtest: ${testname}")
327 set(filename "${testname}.cpp")
328 file(READ "${filename}" test_source)
329
330 try_compile(succeeds_when_it_should_fail
331 "${CMAKE_CURRENT_BINARY_DIR}"
332 "${CMAKE_CURRENT_SOURCE_DIR}/${filename}"
333 COMPILE_DEFINITIONS "-DEIGEN_SHOULD_FAIL_TO_BUILD")
334 if (succeeds_when_it_should_fail)
335 message(STATUS "FAILED: ${testname} build succeeded when it should have failed")
336 endif()
337
338 try_compile(succeeds_when_it_should_succeed
339 "${CMAKE_CURRENT_BINARY_DIR}"
340 "${CMAKE_CURRENT_SOURCE_DIR}/${filename}"
341 COMPILE_DEFINITIONS)
342 if (NOT succeeds_when_it_should_succeed)
343 message(STATUS "FAILED: ${testname} build failed when it should have succeeded")
344 endif()
345
346 if (succeeds_when_it_should_fail OR NOT succeeds_when_it_should_succeed)
347 math(EXPR EIGEN_FAILTEST_FAILURE_COUNT ${EIGEN_FAILTEST_FAILURE_COUNT}+1)
348 endif()
349
350 math(EXPR EIGEN_FAILTEST_COUNT ${EIGEN_FAILTEST_COUNT}+1)
351
352 set_property(GLOBAL PROPERTY EIGEN_FAILTEST_FAILURE_COUNT ${EIGEN_FAILTEST_FAILURE_COUNT})
353 set_property(GLOBAL PROPERTY EIGEN_FAILTEST_COUNT ${EIGEN_FAILTEST_COUNT})
354endmacro(ei_add_failtest)
355
356# print a summary of the different options
357macro(ei_testing_print_summary)
358 message(STATUS "************************************************************")
359 message(STATUS "*** Eigen's unit tests configuration summary ***")
360 message(STATUS "************************************************************")
361 message(STATUS "")
362 message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
363 message(STATUS "Build site: ${SITE}")
364 message(STATUS "Build string: ${BUILDNAME}")
365 get_property(EIGEN_TESTING_SUMMARY GLOBAL PROPERTY EIGEN_TESTING_SUMMARY)
366 get_property(EIGEN_TESTED_BACKENDS GLOBAL PROPERTY EIGEN_TESTED_BACKENDS)
367 get_property(EIGEN_MISSING_BACKENDS GLOBAL PROPERTY EIGEN_MISSING_BACKENDS)
368 message(STATUS "Enabled backends: ${EIGEN_TESTED_BACKENDS}")
369 message(STATUS "Disabled backends: ${EIGEN_MISSING_BACKENDS}")
370
371 if(EIGEN_DEFAULT_TO_ROW_MAJOR)
372 message(STATUS "Default order: Row-major")
373 else()
374 message(STATUS "Default order: Column-major")
375 endif()
376
377 if(EIGEN_TEST_NO_EXPLICIT_ALIGNMENT)
378 message(STATUS "Explicit alignment (hence vectorization) disabled")
379 elseif(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION)
380 message(STATUS "Explicit vectorization disabled (alignment kept enabled)")
381 else()
Austin Schuh189376f2018-12-20 22:11:15 +1100382
Brian Silverman72890c22015-09-19 14:37:37 -0400383 message(STATUS "Maximal matrix/vector size: ${EIGEN_TEST_MAX_SIZE}")
384
385 if(EIGEN_TEST_SSE2)
386 message(STATUS "SSE2: ON")
387 else()
388 message(STATUS "SSE2: Using architecture defaults")
389 endif()
390
391 if(EIGEN_TEST_SSE3)
392 message(STATUS "SSE3: ON")
393 else()
394 message(STATUS "SSE3: Using architecture defaults")
395 endif()
396
397 if(EIGEN_TEST_SSSE3)
398 message(STATUS "SSSE3: ON")
399 else()
400 message(STATUS "SSSE3: Using architecture defaults")
401 endif()
402
403 if(EIGEN_TEST_SSE4_1)
404 message(STATUS "SSE4.1: ON")
405 else()
406 message(STATUS "SSE4.1: Using architecture defaults")
407 endif()
408
409 if(EIGEN_TEST_SSE4_2)
410 message(STATUS "SSE4.2: ON")
411 else()
412 message(STATUS "SSE4.2: Using architecture defaults")
413 endif()
414
Austin Schuh189376f2018-12-20 22:11:15 +1100415 if(EIGEN_TEST_AVX)
416 message(STATUS "AVX: ON")
417 else()
418 message(STATUS "AVX: Using architecture defaults")
419 endif()
420
421 if(EIGEN_TEST_FMA)
422 message(STATUS "FMA: ON")
423 else()
424 message(STATUS "FMA: Using architecture defaults")
425 endif()
426
427 if(EIGEN_TEST_AVX512)
428 message(STATUS "AVX512: ON")
429 else()
430 message(STATUS "AVX512: Using architecture defaults")
431 endif()
432
Brian Silverman72890c22015-09-19 14:37:37 -0400433 if(EIGEN_TEST_ALTIVEC)
434 message(STATUS "Altivec: ON")
435 else()
436 message(STATUS "Altivec: Using architecture defaults")
437 endif()
438
Austin Schuh189376f2018-12-20 22:11:15 +1100439 if(EIGEN_TEST_VSX)
440 message(STATUS "VSX: ON")
441 else()
442 message(STATUS "VSX: Using architecture defaults")
443 endif()
444
Brian Silverman72890c22015-09-19 14:37:37 -0400445 if(EIGEN_TEST_NEON)
446 message(STATUS "ARM NEON: ON")
447 else()
448 message(STATUS "ARM NEON: Using architecture defaults")
449 endif()
450
Austin Schuh189376f2018-12-20 22:11:15 +1100451 if(EIGEN_TEST_NEON64)
452 message(STATUS "ARMv8 NEON: ON")
453 else()
454 message(STATUS "ARMv8 NEON: Using architecture defaults")
455 endif()
456
457 if(EIGEN_TEST_ZVECTOR)
458 message(STATUS "S390X ZVECTOR: ON")
459 else()
460 message(STATUS "S390X ZVECTOR: Using architecture defaults")
461 endif()
462
463 if(EIGEN_TEST_CXX11)
464 message(STATUS "C++11: ON")
465 else()
466 message(STATUS "C++11: OFF")
467 endif()
468
469 if(EIGEN_TEST_SYCL)
470 message(STATUS "SYCL: ON")
471 else()
472 message(STATUS "SYCL: OFF")
473 endif()
474 if(EIGEN_TEST_CUDA)
475 if(EIGEN_TEST_CUDA_CLANG)
476 message(STATUS "CUDA: ON (using clang)")
477 else()
478 message(STATUS "CUDA: ON (using nvcc)")
479 endif()
480 else()
481 message(STATUS "CUDA: OFF")
482 endif()
483
Brian Silverman72890c22015-09-19 14:37:37 -0400484 endif() # vectorization / alignment options
485
486 message(STATUS "\n${EIGEN_TESTING_SUMMARY}")
487
488 message(STATUS "************************************************************")
489endmacro(ei_testing_print_summary)
490
491macro(ei_init_testing)
492 define_property(GLOBAL PROPERTY EIGEN_CURRENT_SUBPROJECT BRIEF_DOCS " " FULL_DOCS " ")
493 define_property(GLOBAL PROPERTY EIGEN_TESTED_BACKENDS BRIEF_DOCS " " FULL_DOCS " ")
494 define_property(GLOBAL PROPERTY EIGEN_MISSING_BACKENDS BRIEF_DOCS " " FULL_DOCS " ")
495 define_property(GLOBAL PROPERTY EIGEN_TESTING_SUMMARY BRIEF_DOCS " " FULL_DOCS " ")
496 define_property(GLOBAL PROPERTY EIGEN_TESTS_LIST BRIEF_DOCS " " FULL_DOCS " ")
497
498 set_property(GLOBAL PROPERTY EIGEN_TESTED_BACKENDS "")
499 set_property(GLOBAL PROPERTY EIGEN_MISSING_BACKENDS "")
500 set_property(GLOBAL PROPERTY EIGEN_TESTING_SUMMARY "")
501 set_property(GLOBAL PROPERTY EIGEN_TESTS_LIST "")
502
503 define_property(GLOBAL PROPERTY EIGEN_FAILTEST_FAILURE_COUNT BRIEF_DOCS " " FULL_DOCS " ")
504 define_property(GLOBAL PROPERTY EIGEN_FAILTEST_COUNT BRIEF_DOCS " " FULL_DOCS " ")
505
506 set_property(GLOBAL PROPERTY EIGEN_FAILTEST_FAILURE_COUNT "0")
507 set_property(GLOBAL PROPERTY EIGEN_FAILTEST_COUNT "0")
Austin Schuh189376f2018-12-20 22:11:15 +1100508
Brian Silverman72890c22015-09-19 14:37:37 -0400509 # uncomment anytime you change the ei_get_compilerver_from_cxx_version_string macro
510 # ei_test_get_compilerver_from_cxx_version_string()
511endmacro(ei_init_testing)
512
513macro(ei_set_sitename)
514 # if the sitename is not yet set, try to set it
515 if(NOT ${SITE} OR ${SITE} STREQUAL "")
516 set(eigen_computername $ENV{COMPUTERNAME})
Austin Schuh189376f2018-12-20 22:11:15 +1100517 set(eigen_hostname $ENV{HOSTNAME})
Brian Silverman72890c22015-09-19 14:37:37 -0400518 if(eigen_hostname)
519 set(SITE ${eigen_hostname})
Austin Schuh189376f2018-12-20 22:11:15 +1100520 elseif(eigen_computername)
521 set(SITE ${eigen_computername})
Brian Silverman72890c22015-09-19 14:37:37 -0400522 endif()
523 endif()
524 # in case it is already set, enforce lower case
525 if(SITE)
526 string(TOLOWER ${SITE} SITE)
Austin Schuh189376f2018-12-20 22:11:15 +1100527 endif()
Brian Silverman72890c22015-09-19 14:37:37 -0400528endmacro(ei_set_sitename)
529
530macro(ei_get_compilerver VAR)
Austin Schuh189376f2018-12-20 22:11:15 +1100531 if(MSVC)
532 # on windows system, we use a modified CMake script
533 include(EigenDetermineVSServicePack)
534 EigenDetermineVSServicePack( my_service_pack )
Brian Silverman72890c22015-09-19 14:37:37 -0400535
Austin Schuh189376f2018-12-20 22:11:15 +1100536 if( my_service_pack )
537 set(${VAR} ${my_service_pack})
538 else()
539 set(${VAR} "na")
540 endif()
Brian Silverman72890c22015-09-19 14:37:37 -0400541 else()
Brian Silverman72890c22015-09-19 14:37:37 -0400542 # on all other system we rely on ${CMAKE_CXX_COMPILER}
543 # supporting a "--version" or "/version" flag
Austin Schuh189376f2018-12-20 22:11:15 +1100544
545 if(WIN32 AND ${CMAKE_CXX_COMPILER_ID} EQUAL "Intel")
Brian Silverman72890c22015-09-19 14:37:37 -0400546 set(EIGEN_CXX_FLAG_VERSION "/version")
547 else()
548 set(EIGEN_CXX_FLAG_VERSION "--version")
549 endif()
Austin Schuh189376f2018-12-20 22:11:15 +1100550
551 execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${EIGEN_CXX_FLAG_VERSION}
552 OUTPUT_VARIABLE eigen_cxx_compiler_version_string OUTPUT_STRIP_TRAILING_WHITESPACE)
553 string(REGEX REPLACE "[\n\r].*" "" eigen_cxx_compiler_version_string ${eigen_cxx_compiler_version_string})
554
Brian Silverman72890c22015-09-19 14:37:37 -0400555 ei_get_compilerver_from_cxx_version_string("${eigen_cxx_compiler_version_string}" CNAME CVER)
556 set(${VAR} "${CNAME}-${CVER}")
Austin Schuh189376f2018-12-20 22:11:15 +1100557
Brian Silverman72890c22015-09-19 14:37:37 -0400558 endif()
559endmacro(ei_get_compilerver)
560
561# Extract compiler name and version from a raw version string
562# WARNING: if you edit thid macro, then please test it by uncommenting
563# the testing macro call in ei_init_testing() of the EigenTesting.cmake file.
564# See also the ei_test_get_compilerver_from_cxx_version_string macro at the end of the file
565macro(ei_get_compilerver_from_cxx_version_string VERSTRING CNAME CVER)
Austin Schuh189376f2018-12-20 22:11:15 +1100566 # extract possible compiler names
Brian Silverman72890c22015-09-19 14:37:37 -0400567 string(REGEX MATCH "g\\+\\+" ei_has_gpp ${VERSTRING})
568 string(REGEX MATCH "llvm|LLVM" ei_has_llvm ${VERSTRING})
569 string(REGEX MATCH "gcc|GCC" ei_has_gcc ${VERSTRING})
570 string(REGEX MATCH "icpc|ICC" ei_has_icpc ${VERSTRING})
571 string(REGEX MATCH "clang|CLANG" ei_has_clang ${VERSTRING})
Austin Schuh189376f2018-12-20 22:11:15 +1100572
Brian Silverman72890c22015-09-19 14:37:37 -0400573 # combine them
574 if((ei_has_llvm) AND (ei_has_gpp OR ei_has_gcc))
575 set(${CNAME} "llvm-g++")
576 elseif((ei_has_llvm) AND (ei_has_clang))
577 set(${CNAME} "llvm-clang++")
Austin Schuh189376f2018-12-20 22:11:15 +1100578 elseif(ei_has_clang)
579 set(${CNAME} "clang++")
Brian Silverman72890c22015-09-19 14:37:37 -0400580 elseif(ei_has_icpc)
581 set(${CNAME} "icpc")
582 elseif(ei_has_gpp OR ei_has_gcc)
583 set(${CNAME} "g++")
584 else()
585 set(${CNAME} "_")
586 endif()
Austin Schuh189376f2018-12-20 22:11:15 +1100587
Brian Silverman72890c22015-09-19 14:37:37 -0400588 # extract possible version numbers
589 # first try to extract 3 isolated numbers:
590 string(REGEX MATCH " [0-9]+\\.[0-9]+\\.[0-9]+" eicver ${VERSTRING})
591 if(NOT eicver)
592 # try to extract 2 isolated ones:
593 string(REGEX MATCH " [0-9]+\\.[0-9]+" eicver ${VERSTRING})
594 if(NOT eicver)
595 # try to extract 3:
596 string(REGEX MATCH "[^0-9][0-9]+\\.[0-9]+\\.[0-9]+" eicver ${VERSTRING})
597 if(NOT eicver)
598 # try to extract 2:
599 string(REGEX MATCH "[^0-9][0-9]+\\.[0-9]+" eicver ${VERSTRING})
600 else()
601 set(eicver " _")
602 endif()
603 endif()
604 endif()
Austin Schuh189376f2018-12-20 22:11:15 +1100605
Brian Silverman72890c22015-09-19 14:37:37 -0400606 string(REGEX REPLACE ".(.*)" "\\1" ${CVER} ${eicver})
Austin Schuh189376f2018-12-20 22:11:15 +1100607
Brian Silverman72890c22015-09-19 14:37:37 -0400608endmacro(ei_get_compilerver_from_cxx_version_string)
609
610macro(ei_get_cxxflags VAR)
611 set(${VAR} "")
612 ei_is_64bit_env(IS_64BIT_ENV)
613 if(EIGEN_TEST_NEON)
614 set(${VAR} NEON)
Austin Schuh189376f2018-12-20 22:11:15 +1100615 elseif(EIGEN_TEST_NEON64)
616 set(${VAR} NEON)
617 elseif(EIGEN_TEST_ZVECTOR)
618 set(${VAR} ZVECTOR)
619 elseif(EIGEN_TEST_VSX)
620 set(${VAR} VSX)
Brian Silverman72890c22015-09-19 14:37:37 -0400621 elseif(EIGEN_TEST_ALTIVEC)
622 set(${VAR} ALVEC)
Austin Schuh189376f2018-12-20 22:11:15 +1100623 elseif(EIGEN_TEST_FMA)
624 set(${VAR} FMA)
625 elseif(EIGEN_TEST_AVX)
626 set(${VAR} AVX)
Brian Silverman72890c22015-09-19 14:37:37 -0400627 elseif(EIGEN_TEST_SSE4_2)
628 set(${VAR} SSE42)
629 elseif(EIGEN_TEST_SSE4_1)
630 set(${VAR} SSE41)
631 elseif(EIGEN_TEST_SSSE3)
632 set(${VAR} SSSE3)
633 elseif(EIGEN_TEST_SSE3)
634 set(${VAR} SSE3)
635 elseif(EIGEN_TEST_SSE2 OR IS_64BIT_ENV)
Austin Schuh189376f2018-12-20 22:11:15 +1100636 set(${VAR} SSE2)
Brian Silverman72890c22015-09-19 14:37:37 -0400637 endif()
638
639 if(EIGEN_TEST_OPENMP)
640 if (${VAR} STREQUAL "")
Austin Schuh189376f2018-12-20 22:11:15 +1100641 set(${VAR} OMP)
642 else()
643 set(${VAR} ${${VAR}}-OMP)
644 endif()
Brian Silverman72890c22015-09-19 14:37:37 -0400645 endif()
Austin Schuh189376f2018-12-20 22:11:15 +1100646
Brian Silverman72890c22015-09-19 14:37:37 -0400647 if(EIGEN_DEFAULT_TO_ROW_MAJOR)
648 if (${VAR} STREQUAL "")
Austin Schuh189376f2018-12-20 22:11:15 +1100649 set(${VAR} ROW)
650 else()
651 set(${VAR} ${${VAR}}-ROWMAJ)
652 endif()
Brian Silverman72890c22015-09-19 14:37:37 -0400653 endif()
654endmacro(ei_get_cxxflags)
655
656macro(ei_set_build_string)
657 ei_get_compilerver(LOCAL_COMPILER_VERSION)
658 ei_get_cxxflags(LOCAL_COMPILER_FLAGS)
Austin Schuh189376f2018-12-20 22:11:15 +1100659
Brian Silverman72890c22015-09-19 14:37:37 -0400660 include(EigenDetermineOSVersion)
661 DetermineOSVersion(OS_VERSION)
662
663 set(TMP_BUILD_STRING ${OS_VERSION}-${LOCAL_COMPILER_VERSION})
664
665 if (NOT ${LOCAL_COMPILER_FLAGS} STREQUAL "")
666 set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-${LOCAL_COMPILER_FLAGS})
667 endif()
668
669 ei_is_64bit_env(IS_64BIT_ENV)
670 if(NOT IS_64BIT_ENV)
671 set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-32bit)
672 else()
673 set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-64bit)
674 endif()
Austin Schuh189376f2018-12-20 22:11:15 +1100675
676 if(EIGEN_TEST_CXX11)
677 set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-cxx11)
678 endif()
679
Brian Silverman72890c22015-09-19 14:37:37 -0400680 if(EIGEN_BUILD_STRING_SUFFIX)
681 set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-${EIGEN_BUILD_STRING_SUFFIX})
682 endif()
683
684 string(TOLOWER ${TMP_BUILD_STRING} BUILDNAME)
685endmacro(ei_set_build_string)
686
687macro(ei_is_64bit_env VAR)
688 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
689 set(${VAR} 1)
690 elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
691 set(${VAR} 0)
692 else()
693 message(WARNING "Unsupported pointer size. Please contact the authors.")
694 endif()
695endmacro(ei_is_64bit_env)
696
697
698# helper macro for testing ei_get_compilerver_from_cxx_version_string
699# STR: raw version string
700# REFNAME: expected compiler name
701# REFVER: expected compiler version
702macro(ei_test1_get_compilerver_from_cxx_version_string STR REFNAME REFVER)
703 ei_get_compilerver_from_cxx_version_string(${STR} CNAME CVER)
704 if((NOT ${REFNAME} STREQUAL ${CNAME}) OR (NOT ${REFVER} STREQUAL ${CVER}))
705 message("STATUS ei_get_compilerver_from_cxx_version_string error:")
706 message("Expected \"${REFNAME}-${REFVER}\", got \"${CNAME}-${CVER}\"")
707 endif()
708endmacro(ei_test1_get_compilerver_from_cxx_version_string)
709
710# macro for testing ei_get_compilerver_from_cxx_version_string
711# feel free to add more version strings
712macro(ei_test_get_compilerver_from_cxx_version_string)
713 ei_test1_get_compilerver_from_cxx_version_string("g++ (SUSE Linux) 4.5.3 20110428 [gcc-4_5-branch revision 173117]" "g++" "4.5.3")
714 ei_test1_get_compilerver_from_cxx_version_string("c++ (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)" "g++" "4.5.1")
715 ei_test1_get_compilerver_from_cxx_version_string("icpc (ICC) 11.0 20081105" "icpc" "11.0")
716 ei_test1_get_compilerver_from_cxx_version_string("g++-3.4 (GCC) 3.4.6" "g++" "3.4.6")
717 ei_test1_get_compilerver_from_cxx_version_string("SUSE Linux clang version 3.0 (branches/release_30 145598) (based on LLVM 3.0)" "llvm-clang++" "3.0")
718 ei_test1_get_compilerver_from_cxx_version_string("icpc (ICC) 12.0.5 20110719" "icpc" "12.0.5")
719 ei_test1_get_compilerver_from_cxx_version_string("Apple clang version 2.1 (tags/Apple/clang-163.7.1) (based on LLVM 3.0svn)" "llvm-clang++" "2.1")
720 ei_test1_get_compilerver_from_cxx_version_string("i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)" "llvm-g++" "4.2.1")
721 ei_test1_get_compilerver_from_cxx_version_string("g++-mp-4.4 (GCC) 4.4.6" "g++" "4.4.6")
722 ei_test1_get_compilerver_from_cxx_version_string("g++-mp-4.4 (GCC) 2011" "g++" "4.4")
723endmacro(ei_test_get_compilerver_from_cxx_version_string)