Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 1 | |
| 2 | macro(ei_add_property prop value) |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 3 | get_property(previous GLOBAL PROPERTY ${prop}) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 4 | if ((NOT previous) OR (previous STREQUAL "")) |
| 5 | set_property(GLOBAL PROPERTY ${prop} "${value}") |
| 6 | else() |
| 7 | set_property(GLOBAL PROPERTY ${prop} "${previous} ${value}") |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 8 | endif() |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 9 | endmacro() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 10 | |
| 11 | #internal. See documentation of ei_add_test for details. |
| 12 | macro(ei_add_test_internal testname testname_with_suffix) |
| 13 | set(targetname ${testname_with_suffix}) |
| 14 | |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 15 | 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 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 21 | # Add the current target to the list of subtest targets |
| 22 | get_property(EIGEN_SUBTESTS_LIST GLOBAL PROPERTY EIGEN_SUBTESTS_LIST) |
| 23 | set(EIGEN_SUBTESTS_LIST "${EIGEN_SUBTESTS_LIST}${targetname}\n") |
| 24 | set_property(GLOBAL PROPERTY EIGEN_SUBTESTS_LIST "${EIGEN_SUBTESTS_LIST}") |
| 25 | |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 26 | if(EIGEN_ADD_TEST_FILENAME_EXTENSION STREQUAL cu) |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 27 | if(EIGEN_TEST_HIP) |
| 28 | hip_reset_flags() |
| 29 | hip_add_executable(${targetname} ${filename} HIPCC_OPTIONS "-DEIGEN_USE_HIP ${ARGV2}") |
| 30 | elseif(EIGEN_TEST_CUDA_CLANG) |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 31 | set_source_files_properties(${filename} PROPERTIES LANGUAGE CXX) |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 32 | |
| 33 | if(CUDA_64_BIT_DEVICE_CODE AND (EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/lib64")) |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 34 | link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64") |
| 35 | else() |
| 36 | link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib") |
| 37 | endif() |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 38 | |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 39 | if (${ARGC} GREATER 2) |
| 40 | add_executable(${targetname} ${filename}) |
| 41 | else() |
| 42 | add_executable(${targetname} ${filename} OPTIONS ${ARGV2}) |
| 43 | endif() |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 44 | set(CUDA_CLANG_LINK_LIBRARIES "cudart_static" "cuda" "dl" "pthread") |
| 45 | if (CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 46 | set(CUDA_CLANG_LINK_LIBRARIES ${CUDA_CLANG_LINK_LIBRARIES} "rt") |
| 47 | endif() |
| 48 | target_link_libraries(${targetname} ${CUDA_CLANG_LINK_LIBRARIES}) |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 49 | else() |
| 50 | if (${ARGC} GREATER 2) |
| 51 | cuda_add_executable(${targetname} ${filename} OPTIONS ${ARGV2}) |
| 52 | else() |
| 53 | cuda_add_executable(${targetname} ${filename}) |
| 54 | endif() |
| 55 | endif() |
| 56 | else() |
| 57 | add_executable(${targetname} ${filename}) |
| 58 | endif() |
| 59 | |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 60 | if (targetname MATCHES "^eigen2_") |
| 61 | add_dependencies(eigen2_buildtests ${targetname}) |
| 62 | else() |
| 63 | add_dependencies(buildtests ${targetname}) |
| 64 | endif() |
| 65 | |
| 66 | if(EIGEN_NO_ASSERTION_CHECKING) |
| 67 | ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_NO_ASSERTION_CHECKING=1") |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 68 | else() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 69 | if(EIGEN_DEBUG_ASSERTS) |
| 70 | ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_DEBUG_ASSERTS=1") |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 71 | endif() |
| 72 | endif() |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 73 | |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 74 | ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_MAX_SIZE=${EIGEN_TEST_MAX_SIZE}") |
| 75 | |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 76 | if(MSVC) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 77 | ei_add_target_property(${targetname} COMPILE_FLAGS "/bigobj") |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 78 | endif() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 79 | |
| 80 | # let the user pass flags. |
| 81 | if(${ARGC} GREATER 2) |
| 82 | ei_add_target_property(${targetname} COMPILE_FLAGS "${ARGV2}") |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 83 | endif() |
| 84 | |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 85 | if(EIGEN_TEST_CUSTOM_CXX_FLAGS) |
| 86 | ei_add_target_property(${targetname} COMPILE_FLAGS "${EIGEN_TEST_CUSTOM_CXX_FLAGS}") |
| 87 | endif() |
| 88 | |
| 89 | if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO) |
| 90 | target_link_libraries(${targetname} ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}) |
| 91 | endif() |
| 92 | if(EXTERNAL_LIBS) |
| 93 | target_link_libraries(${targetname} ${EXTERNAL_LIBS}) |
| 94 | endif() |
| 95 | if(EIGEN_TEST_CUSTOM_LINKER_FLAGS) |
| 96 | target_link_libraries(${targetname} ${EIGEN_TEST_CUSTOM_LINKER_FLAGS}) |
| 97 | endif() |
| 98 | |
| 99 | if(${ARGC} GREATER 3) |
| 100 | set(libs_to_link ${ARGV3}) |
| 101 | # it could be that some cmake module provides a bad library string " " (just spaces), |
| 102 | # and that severely breaks target_link_libraries ("can't link to -l-lstdc++" errors). |
| 103 | # so we check for strings containing only spaces. |
| 104 | string(STRIP "${libs_to_link}" libs_to_link_stripped) |
| 105 | string(LENGTH "${libs_to_link_stripped}" libs_to_link_stripped_length) |
| 106 | if(${libs_to_link_stripped_length} GREATER 0) |
| 107 | # notice: no double quotes around ${libs_to_link} here. It may be a list. |
| 108 | target_link_libraries(${targetname} ${libs_to_link}) |
| 109 | endif() |
| 110 | endif() |
| 111 | |
| 112 | add_test(${testname_with_suffix} "${targetname}") |
| 113 | |
| 114 | # Specify target and test labels according to EIGEN_CURRENT_SUBPROJECT |
| 115 | get_property(current_subproject GLOBAL PROPERTY EIGEN_CURRENT_SUBPROJECT) |
| 116 | if ((current_subproject) AND (NOT (current_subproject STREQUAL ""))) |
| 117 | set_property(TARGET ${targetname} PROPERTY LABELS "Build${current_subproject}") |
| 118 | add_dependencies("Build${current_subproject}" ${targetname}) |
| 119 | set_property(TEST ${testname_with_suffix} PROPERTY LABELS "${current_subproject}") |
| 120 | endif() |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 121 | if(EIGEN_SYCL) |
| 122 | # Force include of the SYCL file at the end to avoid errors. |
| 123 | set_property(TARGET ${targetname} PROPERTY COMPUTECPP_INCLUDE_AFTER 1) |
| 124 | # Set COMPILE_FLAGS to COMPILE_DEFINITIONS instead to avoid having to duplicate the flags |
| 125 | # to the device compiler. |
| 126 | get_target_property(target_compile_flags ${targetname} COMPILE_FLAGS) |
| 127 | separate_arguments(target_compile_flags) |
| 128 | foreach(flag ${target_compile_flags}) |
| 129 | if(${flag} MATCHES "^-D.*") |
| 130 | string(REPLACE "-D" "" definition_flag ${flag}) |
| 131 | set_property(TARGET ${targetname} APPEND PROPERTY COMPILE_DEFINITIONS ${definition_flag}) |
| 132 | list(REMOVE_ITEM target_compile_flags ${flag}) |
| 133 | endif() |
| 134 | endforeach() |
| 135 | set_property(TARGET ${targetname} PROPERTY COMPILE_FLAGS ${target_compile_flags}) |
| 136 | # Link against pthread and add sycl to target |
| 137 | set(THREADS_PREFER_PTHREAD_FLAG ON) |
| 138 | find_package(Threads REQUIRED) |
| 139 | target_link_libraries(${targetname} Threads::Threads) |
| 140 | add_sycl_to_target(TARGET ${targetname} SOURCES ${filename}) |
| 141 | endif(EIGEN_SYCL) |
| 142 | endmacro(ei_add_test_internal) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 143 | # Macro to add a test |
| 144 | # |
| 145 | # the unique mandatory parameter testname must correspond to a file |
| 146 | # <testname>.cpp which follows this pattern: |
| 147 | # |
| 148 | # #include "main.h" |
| 149 | # void test_<testname>() { ... } |
| 150 | # |
| 151 | # Depending on the contents of that file, this macro can have 2 behaviors, |
| 152 | # see below. |
| 153 | # |
| 154 | # The optional 2nd parameter is libraries to link to. |
| 155 | # |
| 156 | # A. Default behavior |
| 157 | # |
| 158 | # this macro adds an executable <testname> as well as a ctest test |
| 159 | # named <testname> too. |
| 160 | # |
| 161 | # On platforms with bash simply run: |
| 162 | # "ctest -V" or "ctest -V -R <testname>" |
| 163 | # On other platform use ctest as usual |
| 164 | # |
| 165 | # B. Multi-part behavior |
| 166 | # |
| 167 | # If the source file matches the regexp |
| 168 | # CALL_SUBTEST_[0-9]+|EIGEN_TEST_PART_[0-9]+ |
| 169 | # then it is interpreted as a multi-part test. The behavior then depends on the |
| 170 | # CMake option EIGEN_SPLIT_LARGE_TESTS, which is ON by default. |
| 171 | # |
| 172 | # If EIGEN_SPLIT_LARGE_TESTS is OFF, the behavior is the same as in A (the multi-part |
| 173 | # aspect is ignored). |
| 174 | # |
| 175 | # If EIGEN_SPLIT_LARGE_TESTS is ON, the test is split into multiple executables |
| 176 | # test_<testname>_<N> |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 177 | # where N runs from 1 to the greatest occurrence found in the source file. Each of these |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 178 | # executables is built passing -DEIGEN_TEST_PART_N. This allows to split large tests |
| 179 | # into smaller executables. |
| 180 | # |
| 181 | # Moreover, targets <testname> are still generated, they |
| 182 | # have the effect of building all the parts of the test. |
| 183 | # |
| 184 | # Again, ctest -R allows to run all matching tests. |
| 185 | macro(ei_add_test testname) |
| 186 | get_property(EIGEN_TESTS_LIST GLOBAL PROPERTY EIGEN_TESTS_LIST) |
| 187 | set(EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}${testname}\n") |
| 188 | set_property(GLOBAL PROPERTY EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}") |
| 189 | |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 190 | if(EIGEN_ADD_TEST_FILENAME_EXTENSION) |
| 191 | set(filename ${testname}.${EIGEN_ADD_TEST_FILENAME_EXTENSION}) |
| 192 | else() |
| 193 | set(filename ${testname}.cpp) |
| 194 | endif() |
| 195 | |
| 196 | file(READ "${filename}" test_source) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 197 | string(REGEX MATCHALL "CALL_SUBTEST_[0-9]+|EIGEN_TEST_PART_[0-9]+|EIGEN_SUFFIXES(;[0-9]+)+" |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 198 | occurrences "${test_source}") |
| 199 | string(REGEX REPLACE "CALL_SUBTEST_|EIGEN_TEST_PART_|EIGEN_SUFFIXES" "" suffixes "${occurrences}") |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 200 | list(REMOVE_DUPLICATES suffixes) |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 201 | set(explicit_suffixes "") |
| 202 | if( (NOT EIGEN_SPLIT_LARGE_TESTS) AND suffixes) |
| 203 | # Check whether we have EIGEN_TEST_PART_* statements, in which case we likely must enforce splitting. |
| 204 | # For instance, indexed_view activate a different c++ version for each part. |
| 205 | string(REGEX MATCHALL "EIGEN_TEST_PART_[0-9]+" occurrences "${test_source}") |
| 206 | string(REGEX REPLACE "EIGEN_TEST_PART_" "" explicit_suffixes "${occurrences}") |
| 207 | list(REMOVE_DUPLICATES explicit_suffixes) |
| 208 | endif() |
| 209 | if( (EIGEN_SPLIT_LARGE_TESTS AND suffixes) OR explicit_suffixes) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 210 | add_custom_target(${testname}) |
| 211 | foreach(suffix ${suffixes}) |
| 212 | ei_add_test_internal(${testname} ${testname}_${suffix} |
| 213 | "${ARGV1} -DEIGEN_TEST_PART_${suffix}=1" "${ARGV2}") |
| 214 | add_dependencies(${testname} ${testname}_${suffix}) |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 215 | endforeach() |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 216 | else() |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 217 | ei_add_test_internal(${testname} ${testname} "${ARGV1} -DEIGEN_TEST_PART_ALL=1" "${ARGV2}") |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 218 | endif() |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 219 | endmacro() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 220 | |
| 221 | # adds a failtest, i.e. a test that succeed if the program fails to compile |
| 222 | # note that the test runner for these is CMake itself, when passed -DEIGEN_FAILTEST=ON |
| 223 | # so here we're just running CMake commands immediately, we're not adding any targets. |
| 224 | macro(ei_add_failtest testname) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 225 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 226 | set(test_target_ok ${testname}_ok) |
| 227 | set(test_target_ko ${testname}_ko) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 228 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 229 | # Add executables |
| 230 | add_executable(${test_target_ok} ${testname}.cpp) |
| 231 | add_executable(${test_target_ko} ${testname}.cpp) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 232 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 233 | # Remove them from the normal build process |
| 234 | set_target_properties(${test_target_ok} ${test_target_ko} PROPERTIES |
| 235 | EXCLUDE_FROM_ALL TRUE |
| 236 | EXCLUDE_FROM_DEFAULT_BUILD TRUE) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 237 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 238 | # Configure the failing test |
| 239 | target_compile_definitions(${test_target_ko} PRIVATE EIGEN_SHOULD_FAIL_TO_BUILD) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 240 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 241 | # Add the tests to ctest. |
| 242 | add_test(NAME ${test_target_ok} |
| 243 | COMMAND ${CMAKE_COMMAND} --build . --target ${test_target_ok} --config $<CONFIGURATION> |
| 244 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) |
| 245 | add_test(NAME ${test_target_ko} |
| 246 | COMMAND ${CMAKE_COMMAND} --build . --target ${test_target_ko} --config $<CONFIGURATION> |
| 247 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 248 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 249 | # Expect the second test to fail |
| 250 | set_tests_properties(${test_target_ko} PROPERTIES WILL_FAIL TRUE) |
| 251 | endmacro() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 252 | |
| 253 | # print a summary of the different options |
| 254 | macro(ei_testing_print_summary) |
| 255 | message(STATUS "************************************************************") |
| 256 | message(STATUS "*** Eigen's unit tests configuration summary ***") |
| 257 | message(STATUS "************************************************************") |
| 258 | message(STATUS "") |
| 259 | message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") |
| 260 | message(STATUS "Build site: ${SITE}") |
| 261 | message(STATUS "Build string: ${BUILDNAME}") |
| 262 | get_property(EIGEN_TESTING_SUMMARY GLOBAL PROPERTY EIGEN_TESTING_SUMMARY) |
| 263 | get_property(EIGEN_TESTED_BACKENDS GLOBAL PROPERTY EIGEN_TESTED_BACKENDS) |
| 264 | get_property(EIGEN_MISSING_BACKENDS GLOBAL PROPERTY EIGEN_MISSING_BACKENDS) |
| 265 | message(STATUS "Enabled backends: ${EIGEN_TESTED_BACKENDS}") |
| 266 | message(STATUS "Disabled backends: ${EIGEN_MISSING_BACKENDS}") |
| 267 | |
| 268 | if(EIGEN_DEFAULT_TO_ROW_MAJOR) |
| 269 | message(STATUS "Default order: Row-major") |
| 270 | else() |
| 271 | message(STATUS "Default order: Column-major") |
| 272 | endif() |
| 273 | |
| 274 | if(EIGEN_TEST_NO_EXPLICIT_ALIGNMENT) |
| 275 | message(STATUS "Explicit alignment (hence vectorization) disabled") |
| 276 | elseif(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION) |
| 277 | message(STATUS "Explicit vectorization disabled (alignment kept enabled)") |
| 278 | else() |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 279 | |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 280 | message(STATUS "Maximal matrix/vector size: ${EIGEN_TEST_MAX_SIZE}") |
| 281 | |
| 282 | if(EIGEN_TEST_SSE2) |
| 283 | message(STATUS "SSE2: ON") |
| 284 | else() |
| 285 | message(STATUS "SSE2: Using architecture defaults") |
| 286 | endif() |
| 287 | |
| 288 | if(EIGEN_TEST_SSE3) |
| 289 | message(STATUS "SSE3: ON") |
| 290 | else() |
| 291 | message(STATUS "SSE3: Using architecture defaults") |
| 292 | endif() |
| 293 | |
| 294 | if(EIGEN_TEST_SSSE3) |
| 295 | message(STATUS "SSSE3: ON") |
| 296 | else() |
| 297 | message(STATUS "SSSE3: Using architecture defaults") |
| 298 | endif() |
| 299 | |
| 300 | if(EIGEN_TEST_SSE4_1) |
| 301 | message(STATUS "SSE4.1: ON") |
| 302 | else() |
| 303 | message(STATUS "SSE4.1: Using architecture defaults") |
| 304 | endif() |
| 305 | |
| 306 | if(EIGEN_TEST_SSE4_2) |
| 307 | message(STATUS "SSE4.2: ON") |
| 308 | else() |
| 309 | message(STATUS "SSE4.2: Using architecture defaults") |
| 310 | endif() |
| 311 | |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 312 | if(EIGEN_TEST_AVX) |
| 313 | message(STATUS "AVX: ON") |
| 314 | else() |
| 315 | message(STATUS "AVX: Using architecture defaults") |
| 316 | endif() |
| 317 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 318 | if(EIGEN_TEST_AVX2) |
| 319 | message(STATUS "AVX2: ON") |
| 320 | else() |
| 321 | message(STATUS "AVX2: Using architecture defaults") |
| 322 | endif() |
| 323 | |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 324 | if(EIGEN_TEST_FMA) |
| 325 | message(STATUS "FMA: ON") |
| 326 | else() |
| 327 | message(STATUS "FMA: Using architecture defaults") |
| 328 | endif() |
| 329 | |
| 330 | if(EIGEN_TEST_AVX512) |
| 331 | message(STATUS "AVX512: ON") |
| 332 | else() |
| 333 | message(STATUS "AVX512: Using architecture defaults") |
| 334 | endif() |
| 335 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 336 | if(EIGEN_TEST_AVX512DQ) |
| 337 | message(STATUS "AVX512DQ: ON") |
| 338 | else() |
| 339 | message(STATUS "AVX512DQ: Using architecture defaults") |
| 340 | endif() |
| 341 | |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 342 | if(EIGEN_TEST_ALTIVEC) |
| 343 | message(STATUS "Altivec: ON") |
| 344 | else() |
| 345 | message(STATUS "Altivec: Using architecture defaults") |
| 346 | endif() |
| 347 | |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 348 | if(EIGEN_TEST_VSX) |
| 349 | message(STATUS "VSX: ON") |
| 350 | else() |
| 351 | message(STATUS "VSX: Using architecture defaults") |
| 352 | endif() |
| 353 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 354 | if(EIGEN_TEST_MSA) |
| 355 | message(STATUS "MIPS MSA: ON") |
| 356 | else() |
| 357 | message(STATUS "MIPS MSA: Using architecture defaults") |
| 358 | endif() |
| 359 | |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 360 | if(EIGEN_TEST_NEON) |
| 361 | message(STATUS "ARM NEON: ON") |
| 362 | else() |
| 363 | message(STATUS "ARM NEON: Using architecture defaults") |
| 364 | endif() |
| 365 | |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 366 | if(EIGEN_TEST_NEON64) |
| 367 | message(STATUS "ARMv8 NEON: ON") |
| 368 | else() |
| 369 | message(STATUS "ARMv8 NEON: Using architecture defaults") |
| 370 | endif() |
| 371 | |
| 372 | if(EIGEN_TEST_ZVECTOR) |
| 373 | message(STATUS "S390X ZVECTOR: ON") |
| 374 | else() |
| 375 | message(STATUS "S390X ZVECTOR: Using architecture defaults") |
| 376 | endif() |
| 377 | |
| 378 | if(EIGEN_TEST_CXX11) |
| 379 | message(STATUS "C++11: ON") |
| 380 | else() |
| 381 | message(STATUS "C++11: OFF") |
| 382 | endif() |
| 383 | |
| 384 | if(EIGEN_TEST_SYCL) |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 385 | if(EIGEN_SYCL_TRISYCL) |
| 386 | message(STATUS "SYCL: ON (using triSYCL)") |
| 387 | else() |
| 388 | message(STATUS "SYCL: ON (using computeCPP)") |
| 389 | endif() |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 390 | else() |
| 391 | message(STATUS "SYCL: OFF") |
| 392 | endif() |
| 393 | if(EIGEN_TEST_CUDA) |
| 394 | if(EIGEN_TEST_CUDA_CLANG) |
| 395 | message(STATUS "CUDA: ON (using clang)") |
| 396 | else() |
| 397 | message(STATUS "CUDA: ON (using nvcc)") |
| 398 | endif() |
| 399 | else() |
| 400 | message(STATUS "CUDA: OFF") |
| 401 | endif() |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 402 | if(EIGEN_TEST_HIP) |
| 403 | message(STATUS "HIP: ON (using hipcc)") |
| 404 | else() |
| 405 | message(STATUS "HIP: OFF") |
| 406 | endif() |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 407 | |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 408 | endif() # vectorization / alignment options |
| 409 | |
| 410 | message(STATUS "\n${EIGEN_TESTING_SUMMARY}") |
| 411 | |
| 412 | message(STATUS "************************************************************") |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 413 | endmacro() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 414 | |
| 415 | macro(ei_init_testing) |
| 416 | define_property(GLOBAL PROPERTY EIGEN_CURRENT_SUBPROJECT BRIEF_DOCS " " FULL_DOCS " ") |
| 417 | define_property(GLOBAL PROPERTY EIGEN_TESTED_BACKENDS BRIEF_DOCS " " FULL_DOCS " ") |
| 418 | define_property(GLOBAL PROPERTY EIGEN_MISSING_BACKENDS BRIEF_DOCS " " FULL_DOCS " ") |
| 419 | define_property(GLOBAL PROPERTY EIGEN_TESTING_SUMMARY BRIEF_DOCS " " FULL_DOCS " ") |
| 420 | define_property(GLOBAL PROPERTY EIGEN_TESTS_LIST BRIEF_DOCS " " FULL_DOCS " ") |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 421 | define_property(GLOBAL PROPERTY EIGEN_SUBTESTS_LIST BRIEF_DOCS " " FULL_DOCS " ") |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 422 | |
| 423 | set_property(GLOBAL PROPERTY EIGEN_TESTED_BACKENDS "") |
| 424 | set_property(GLOBAL PROPERTY EIGEN_MISSING_BACKENDS "") |
| 425 | set_property(GLOBAL PROPERTY EIGEN_TESTING_SUMMARY "") |
| 426 | set_property(GLOBAL PROPERTY EIGEN_TESTS_LIST "") |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 427 | set_property(GLOBAL PROPERTY EIGEN_SUBTESTS_LIST "") |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 428 | |
| 429 | define_property(GLOBAL PROPERTY EIGEN_FAILTEST_FAILURE_COUNT BRIEF_DOCS " " FULL_DOCS " ") |
| 430 | define_property(GLOBAL PROPERTY EIGEN_FAILTEST_COUNT BRIEF_DOCS " " FULL_DOCS " ") |
| 431 | |
| 432 | set_property(GLOBAL PROPERTY EIGEN_FAILTEST_FAILURE_COUNT "0") |
| 433 | set_property(GLOBAL PROPERTY EIGEN_FAILTEST_COUNT "0") |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 434 | |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 435 | # uncomment anytime you change the ei_get_compilerver_from_cxx_version_string macro |
| 436 | # ei_test_get_compilerver_from_cxx_version_string() |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 437 | endmacro() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 438 | |
| 439 | macro(ei_set_sitename) |
| 440 | # if the sitename is not yet set, try to set it |
| 441 | if(NOT ${SITE} OR ${SITE} STREQUAL "") |
| 442 | set(eigen_computername $ENV{COMPUTERNAME}) |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 443 | set(eigen_hostname $ENV{HOSTNAME}) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 444 | if(eigen_hostname) |
| 445 | set(SITE ${eigen_hostname}) |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 446 | elseif(eigen_computername) |
| 447 | set(SITE ${eigen_computername}) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 448 | endif() |
| 449 | endif() |
| 450 | # in case it is already set, enforce lower case |
| 451 | if(SITE) |
| 452 | string(TOLOWER ${SITE} SITE) |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 453 | endif() |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 454 | endmacro() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 455 | |
| 456 | macro(ei_get_compilerver VAR) |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 457 | if(MSVC) |
| 458 | # on windows system, we use a modified CMake script |
| 459 | include(EigenDetermineVSServicePack) |
| 460 | EigenDetermineVSServicePack( my_service_pack ) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 461 | |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 462 | if( my_service_pack ) |
| 463 | set(${VAR} ${my_service_pack}) |
| 464 | else() |
| 465 | set(${VAR} "na") |
| 466 | endif() |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 467 | elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "PGI") |
| 468 | set(${VAR} "${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}") |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 469 | else() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 470 | # on all other system we rely on ${CMAKE_CXX_COMPILER} |
| 471 | # supporting a "--version" or "/version" flag |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 472 | |
| 473 | if(WIN32 AND ${CMAKE_CXX_COMPILER_ID} EQUAL "Intel") |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 474 | set(EIGEN_CXX_FLAG_VERSION "/version") |
| 475 | else() |
| 476 | set(EIGEN_CXX_FLAG_VERSION "--version") |
| 477 | endif() |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 478 | |
| 479 | execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${EIGEN_CXX_FLAG_VERSION} |
| 480 | OUTPUT_VARIABLE eigen_cxx_compiler_version_string OUTPUT_STRIP_TRAILING_WHITESPACE) |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 481 | string(REGEX REPLACE "^[ \n\r]+" "" eigen_cxx_compiler_version_string ${eigen_cxx_compiler_version_string}) |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 482 | string(REGEX REPLACE "[\n\r].*" "" eigen_cxx_compiler_version_string ${eigen_cxx_compiler_version_string}) |
| 483 | |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 484 | ei_get_compilerver_from_cxx_version_string("${eigen_cxx_compiler_version_string}" CNAME CVER) |
| 485 | set(${VAR} "${CNAME}-${CVER}") |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 486 | |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 487 | endif() |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 488 | endmacro() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 489 | |
| 490 | # Extract compiler name and version from a raw version string |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 491 | # WARNING: if you edit this macro, then please test it by uncommenting |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 492 | # the testing macro call in ei_init_testing() of the EigenTesting.cmake file. |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 493 | # See also the ei_test_get_compilerver_from_cxx_version_string macro at the end |
| 494 | # of the file |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 495 | macro(ei_get_compilerver_from_cxx_version_string VERSTRING CNAME CVER) |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 496 | # extract possible compiler names |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 497 | string(REGEX MATCH "g\\+\\+" ei_has_gpp ${VERSTRING}) |
| 498 | string(REGEX MATCH "llvm|LLVM" ei_has_llvm ${VERSTRING}) |
| 499 | string(REGEX MATCH "gcc|GCC" ei_has_gcc ${VERSTRING}) |
| 500 | string(REGEX MATCH "icpc|ICC" ei_has_icpc ${VERSTRING}) |
| 501 | string(REGEX MATCH "clang|CLANG" ei_has_clang ${VERSTRING}) |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 502 | string(REGEX MATCH "mingw32" ei_has_mingw ${VERSTRING}) |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 503 | |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 504 | # combine them |
| 505 | if((ei_has_llvm) AND (ei_has_gpp OR ei_has_gcc)) |
| 506 | set(${CNAME} "llvm-g++") |
| 507 | elseif((ei_has_llvm) AND (ei_has_clang)) |
| 508 | set(${CNAME} "llvm-clang++") |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 509 | elseif(ei_has_clang) |
| 510 | set(${CNAME} "clang++") |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 511 | elseif ((ei_has_mingw) AND (ei_has_gpp OR ei_has_gcc)) |
| 512 | set(${CNAME} "mingw32-g++") |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 513 | elseif(ei_has_icpc) |
| 514 | set(${CNAME} "icpc") |
| 515 | elseif(ei_has_gpp OR ei_has_gcc) |
| 516 | set(${CNAME} "g++") |
| 517 | else() |
| 518 | set(${CNAME} "_") |
| 519 | endif() |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 520 | |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 521 | # extract possible version numbers |
| 522 | # first try to extract 3 isolated numbers: |
| 523 | string(REGEX MATCH " [0-9]+\\.[0-9]+\\.[0-9]+" eicver ${VERSTRING}) |
| 524 | if(NOT eicver) |
| 525 | # try to extract 2 isolated ones: |
| 526 | string(REGEX MATCH " [0-9]+\\.[0-9]+" eicver ${VERSTRING}) |
| 527 | if(NOT eicver) |
| 528 | # try to extract 3: |
| 529 | string(REGEX MATCH "[^0-9][0-9]+\\.[0-9]+\\.[0-9]+" eicver ${VERSTRING}) |
| 530 | if(NOT eicver) |
| 531 | # try to extract 2: |
| 532 | string(REGEX MATCH "[^0-9][0-9]+\\.[0-9]+" eicver ${VERSTRING}) |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 533 | if (NOT eicver AND ei_has_mingw) |
| 534 | # try to extract 1 number plus suffix: |
| 535 | string(REGEX MATCH "[^0-9][0-9]+-win32" eicver ${VERSTRING}) |
| 536 | endif() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 537 | endif() |
| 538 | endif() |
| 539 | endif() |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 540 | |
| 541 | if (NOT eicver) |
| 542 | set(eicver " _") |
| 543 | endif() |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 544 | |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 545 | string(REGEX REPLACE ".(.*)" "\\1" ${CVER} ${eicver}) |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 546 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 547 | endmacro() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 548 | |
| 549 | macro(ei_get_cxxflags VAR) |
| 550 | set(${VAR} "") |
| 551 | ei_is_64bit_env(IS_64BIT_ENV) |
| 552 | if(EIGEN_TEST_NEON) |
| 553 | set(${VAR} NEON) |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 554 | elseif(EIGEN_TEST_NEON64) |
| 555 | set(${VAR} NEON) |
| 556 | elseif(EIGEN_TEST_ZVECTOR) |
| 557 | set(${VAR} ZVECTOR) |
| 558 | elseif(EIGEN_TEST_VSX) |
| 559 | set(${VAR} VSX) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 560 | elseif(EIGEN_TEST_ALTIVEC) |
| 561 | set(${VAR} ALVEC) |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 562 | elseif(EIGEN_TEST_FMA) |
| 563 | set(${VAR} FMA) |
| 564 | elseif(EIGEN_TEST_AVX) |
| 565 | set(${VAR} AVX) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 566 | elseif(EIGEN_TEST_SSE4_2) |
| 567 | set(${VAR} SSE42) |
| 568 | elseif(EIGEN_TEST_SSE4_1) |
| 569 | set(${VAR} SSE41) |
| 570 | elseif(EIGEN_TEST_SSSE3) |
| 571 | set(${VAR} SSSE3) |
| 572 | elseif(EIGEN_TEST_SSE3) |
| 573 | set(${VAR} SSE3) |
| 574 | elseif(EIGEN_TEST_SSE2 OR IS_64BIT_ENV) |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 575 | set(${VAR} SSE2) |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 576 | elseif(EIGEN_TEST_MSA) |
| 577 | set(${VAR} MSA) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 578 | endif() |
| 579 | |
| 580 | if(EIGEN_TEST_OPENMP) |
| 581 | if (${VAR} STREQUAL "") |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 582 | set(${VAR} OMP) |
| 583 | else() |
| 584 | set(${VAR} ${${VAR}}-OMP) |
| 585 | endif() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 586 | endif() |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 587 | |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 588 | if(EIGEN_DEFAULT_TO_ROW_MAJOR) |
| 589 | if (${VAR} STREQUAL "") |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 590 | set(${VAR} ROW) |
| 591 | else() |
| 592 | set(${VAR} ${${VAR}}-ROWMAJ) |
| 593 | endif() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 594 | endif() |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 595 | endmacro() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 596 | |
| 597 | macro(ei_set_build_string) |
| 598 | ei_get_compilerver(LOCAL_COMPILER_VERSION) |
| 599 | ei_get_cxxflags(LOCAL_COMPILER_FLAGS) |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 600 | |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 601 | include(EigenDetermineOSVersion) |
| 602 | DetermineOSVersion(OS_VERSION) |
| 603 | |
| 604 | set(TMP_BUILD_STRING ${OS_VERSION}-${LOCAL_COMPILER_VERSION}) |
| 605 | |
| 606 | if (NOT ${LOCAL_COMPILER_FLAGS} STREQUAL "") |
| 607 | set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-${LOCAL_COMPILER_FLAGS}) |
| 608 | endif() |
| 609 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 610 | if(EIGEN_TEST_EXTERNAL_BLAS) |
| 611 | set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-external_blas) |
| 612 | endif() |
| 613 | |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 614 | ei_is_64bit_env(IS_64BIT_ENV) |
| 615 | if(NOT IS_64BIT_ENV) |
| 616 | set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-32bit) |
| 617 | else() |
| 618 | set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-64bit) |
| 619 | endif() |
Austin Schuh | 189376f | 2018-12-20 22:11:15 +1100 | [diff] [blame] | 620 | |
| 621 | if(EIGEN_TEST_CXX11) |
| 622 | set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-cxx11) |
| 623 | endif() |
| 624 | |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 625 | if(EIGEN_BUILD_STRING_SUFFIX) |
| 626 | set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-${EIGEN_BUILD_STRING_SUFFIX}) |
| 627 | endif() |
| 628 | |
| 629 | string(TOLOWER ${TMP_BUILD_STRING} BUILDNAME) |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 630 | endmacro() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 631 | |
| 632 | macro(ei_is_64bit_env VAR) |
| 633 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) |
| 634 | set(${VAR} 1) |
| 635 | elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) |
| 636 | set(${VAR} 0) |
| 637 | else() |
| 638 | message(WARNING "Unsupported pointer size. Please contact the authors.") |
| 639 | endif() |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 640 | endmacro() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 641 | |
| 642 | |
| 643 | # helper macro for testing ei_get_compilerver_from_cxx_version_string |
| 644 | # STR: raw version string |
| 645 | # REFNAME: expected compiler name |
| 646 | # REFVER: expected compiler version |
| 647 | macro(ei_test1_get_compilerver_from_cxx_version_string STR REFNAME REFVER) |
| 648 | ei_get_compilerver_from_cxx_version_string(${STR} CNAME CVER) |
| 649 | if((NOT ${REFNAME} STREQUAL ${CNAME}) OR (NOT ${REFVER} STREQUAL ${CVER})) |
| 650 | message("STATUS ei_get_compilerver_from_cxx_version_string error:") |
| 651 | message("Expected \"${REFNAME}-${REFVER}\", got \"${CNAME}-${CVER}\"") |
| 652 | endif() |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 653 | endmacro() |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 654 | |
| 655 | # macro for testing ei_get_compilerver_from_cxx_version_string |
| 656 | # feel free to add more version strings |
| 657 | macro(ei_test_get_compilerver_from_cxx_version_string) |
| 658 | 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") |
| 659 | ei_test1_get_compilerver_from_cxx_version_string("c++ (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)" "g++" "4.5.1") |
| 660 | ei_test1_get_compilerver_from_cxx_version_string("icpc (ICC) 11.0 20081105" "icpc" "11.0") |
| 661 | ei_test1_get_compilerver_from_cxx_version_string("g++-3.4 (GCC) 3.4.6" "g++" "3.4.6") |
| 662 | 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") |
| 663 | ei_test1_get_compilerver_from_cxx_version_string("icpc (ICC) 12.0.5 20110719" "icpc" "12.0.5") |
| 664 | 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") |
| 665 | 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") |
| 666 | ei_test1_get_compilerver_from_cxx_version_string("g++-mp-4.4 (GCC) 4.4.6" "g++" "4.4.6") |
| 667 | ei_test1_get_compilerver_from_cxx_version_string("g++-mp-4.4 (GCC) 2011" "g++" "4.4") |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 668 | ei_test1_get_compilerver_from_cxx_version_string("x86_64-w64-mingw32-g++ (GCC) 10-win32 20210110" "mingw32-g++" "10-win32") |
| 669 | endmacro() |
| 670 | |
| 671 | # Split all tests listed in EIGEN_TESTS_LIST into num_splits many targets |
| 672 | # named buildtestspartN with N = { 0, ..., num_splits-1}. |
| 673 | # |
| 674 | # The intention behind the existance of this macro is the size of Eigen's |
| 675 | # testsuite. Together with the relativly big compile-times building all tests |
| 676 | # can take a substantial amount of time depending on the available hardware. |
| 677 | # |
| 678 | # The last buildtestspartN target will build possible remaining tests. |
| 679 | # |
| 680 | # An example: |
| 681 | # |
| 682 | # EIGEN_TESTS_LIST= [ test1, test2, test3, test4, test5, test6, test7 ] |
| 683 | # |
| 684 | # A call to ei_split_testsuite(3) creates the following targets with dependencies |
| 685 | # |
| 686 | # Target Dependencies |
| 687 | # ------ ------------ |
| 688 | # buildtestspart0 test1, test2 |
| 689 | # buildtestspart1 test3, test4 |
| 690 | # buildtestspart2 test5, test6, test7 |
| 691 | # |
| 692 | macro(ei_split_testsuite num_splits) |
| 693 | get_property(EIGEN_TESTS_LIST GLOBAL PROPERTY EIGEN_TESTS_LIST) |
| 694 | |
| 695 | # Translate EIGEN_TESTS_LIST into a CMake list |
| 696 | string(REGEX REPLACE "\n" " " EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}") |
| 697 | set(EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}") |
| 698 | separate_arguments(EIGEN_TESTS_LIST) |
| 699 | |
| 700 | set(eigen_test_count "0") |
| 701 | foreach(t IN ITEMS ${EIGEN_TESTS_LIST}) |
| 702 | math(EXPR eigen_test_count "${eigen_test_count}+1") |
| 703 | endforeach() |
| 704 | |
| 705 | # Get number of tests per target |
| 706 | math(EXPR num_tests_per_target "${eigen_test_count}/${num_splits} - ${eigen_test_count}/${num_splits} % 1") |
| 707 | |
| 708 | set(test_idx "0") |
| 709 | math(EXPR target_bound "${num_splits}-1") |
| 710 | foreach(part RANGE "0" "${target_bound}") |
| 711 | # Create target |
| 712 | set(current_target "buildtestspart${part}") |
| 713 | add_custom_target("${current_target}") |
| 714 | math(EXPR upper_bound "${test_idx} + ${num_tests_per_target} - 1") |
| 715 | foreach(test_idx RANGE "${test_idx}" "${upper_bound}") |
| 716 | list(GET EIGEN_TESTS_LIST "${test_idx}" curr_test) |
| 717 | add_dependencies("${current_target}" "${curr_test}") |
| 718 | endforeach() |
| 719 | math(EXPR test_idx "${test_idx} + ${num_tests_per_target}") |
| 720 | endforeach() |
| 721 | |
| 722 | # Handle the possibly remaining tests |
| 723 | math(EXPR test_idx "${num_splits} * ${num_tests_per_target}") |
| 724 | math(EXPR target_bound "${eigen_test_count} - 1") |
| 725 | foreach(test_idx RANGE "${test_idx}" "${target_bound}") |
| 726 | list(GET EIGEN_TESTS_LIST "${test_idx}" curr_test) |
| 727 | add_dependencies("${current_target}" "${curr_test}") |
| 728 | endforeach() |
| 729 | endmacro(ei_split_testsuite num_splits) |
| 730 | |
| 731 | # Defines the custom command buildsmoketests to build a number of tests |
| 732 | # specified in smoke_test_list. |
| 733 | # |
| 734 | # Test in smoke_test_list can be either test targets (e.g. packetmath) or |
| 735 | # subtests targets (e.g. packetmath_2). If any of the test are not available |
| 736 | # in the current configuration they are just skipped. |
| 737 | # |
| 738 | # All tests added via this macro are labeled with the smoketest label. This |
| 739 | # allows running smoketests only using ctest. |
| 740 | # |
| 741 | # Smoke tests are intended to be run before the whole test suite is invoked, |
| 742 | # e.g., to smoke test patches. |
| 743 | macro(ei_add_smoke_tests smoke_test_list) |
| 744 | # Set the build target to build smoketests |
| 745 | set(buildtarget "buildsmoketests") |
| 746 | add_custom_target("${buildtarget}") |
| 747 | |
| 748 | # Get list of all tests and translate it into a CMake list |
| 749 | get_property(EIGEN_TESTS_LIST GLOBAL PROPERTY EIGEN_TESTS_LIST) |
| 750 | string(REGEX REPLACE "\n" " " EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}") |
| 751 | set(EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}") |
| 752 | separate_arguments(EIGEN_TESTS_LIST) |
| 753 | |
| 754 | # Check if the test in smoke_test_list is a currently valid test target |
| 755 | foreach(test IN ITEMS ${smoke_test_list}) |
| 756 | # Add tests in smoke_test_list to our smoke test target but only if the test |
| 757 | # is currently available, i.e., is in EIGEN_SUBTESTS_LIST |
| 758 | if ("${test}" IN_LIST EIGEN_TESTS_LIST) |
| 759 | add_dependencies("${buildtarget}" "${test}") |
| 760 | # In the case of a test we match all subtests |
| 761 | set(ctest_regex "${ctest_regex}^${test}_[0-9]+$$|") |
| 762 | endif() |
| 763 | endforeach() |
| 764 | |
| 765 | # Get list of all subtests and translate it into a CMake list |
| 766 | get_property(EIGEN_SUBTESTS_LIST GLOBAL PROPERTY EIGEN_SUBTESTS_LIST) |
| 767 | string(REGEX REPLACE "\n" " " EIGEN_SUBTESTS_LIST "${EIGEN_SUBTESTS_LIST}") |
| 768 | set(EIGEN_SUBTESTS_LIST "${EIGEN_SUBTESTS_LIST}") |
| 769 | separate_arguments(EIGEN_SUBTESTS_LIST) |
| 770 | |
| 771 | # Check if the test in smoke_test_list is a currently valid subtest target |
| 772 | foreach(test IN ITEMS ${smoke_test_list}) |
| 773 | # Add tests in smoke_test_list to our smoke test target but only if the test |
| 774 | # is currently available, i.e., is in EIGEN_SUBTESTS_LIST |
| 775 | if ("${test}" IN_LIST EIGEN_SUBTESTS_LIST) |
| 776 | add_dependencies("${buildtarget}" "${test}") |
| 777 | # Add label smoketest to be able to run smoketests using ctest |
| 778 | get_property(test_labels TEST ${test} PROPERTY LABELS) |
| 779 | set_property(TEST ${test} PROPERTY LABELS "${test_labels};smoketest") |
| 780 | endif() |
| 781 | endforeach() |
| 782 | endmacro(ei_add_smoke_tests) |