Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame^] | 1 | |
| 2 | macro(ei_add_property prop value) |
| 3 | get_property(previous GLOBAL PROPERTY ${prop}) |
| 4 | if ((NOT previous) OR (previous STREQUAL "")) |
| 5 | set_property(GLOBAL PROPERTY ${prop} "${value}") |
| 6 | else() |
| 7 | set_property(GLOBAL PROPERTY ${prop} "${previous} ${value}") |
| 8 | endif() |
| 9 | endmacro(ei_add_property) |
| 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 | |
| 15 | set(filename ${testname}.cpp) |
| 16 | add_executable(${targetname} ${filename}) |
| 17 | if (targetname MATCHES "^eigen2_") |
| 18 | add_dependencies(eigen2_buildtests ${targetname}) |
| 19 | else() |
| 20 | add_dependencies(buildtests ${targetname}) |
| 21 | endif() |
| 22 | |
| 23 | if(EIGEN_NO_ASSERTION_CHECKING) |
| 24 | ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_NO_ASSERTION_CHECKING=1") |
| 25 | else(EIGEN_NO_ASSERTION_CHECKING) |
| 26 | if(EIGEN_DEBUG_ASSERTS) |
| 27 | ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_DEBUG_ASSERTS=1") |
| 28 | endif(EIGEN_DEBUG_ASSERTS) |
| 29 | endif(EIGEN_NO_ASSERTION_CHECKING) |
| 30 | |
| 31 | ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_MAX_SIZE=${EIGEN_TEST_MAX_SIZE}") |
| 32 | |
| 33 | ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_FUNC=${testname}") |
| 34 | |
| 35 | if(MSVC AND NOT EIGEN_SPLIT_LARGE_TESTS) |
| 36 | ei_add_target_property(${targetname} COMPILE_FLAGS "/bigobj") |
| 37 | endif() |
| 38 | |
| 39 | # let the user pass flags. |
| 40 | if(${ARGC} GREATER 2) |
| 41 | ei_add_target_property(${targetname} COMPILE_FLAGS "${ARGV2}") |
| 42 | endif(${ARGC} GREATER 2) |
| 43 | |
| 44 | if(EIGEN_TEST_CUSTOM_CXX_FLAGS) |
| 45 | ei_add_target_property(${targetname} COMPILE_FLAGS "${EIGEN_TEST_CUSTOM_CXX_FLAGS}") |
| 46 | endif() |
| 47 | |
| 48 | if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO) |
| 49 | target_link_libraries(${targetname} ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}) |
| 50 | endif() |
| 51 | if(EXTERNAL_LIBS) |
| 52 | target_link_libraries(${targetname} ${EXTERNAL_LIBS}) |
| 53 | endif() |
| 54 | if(EIGEN_TEST_CUSTOM_LINKER_FLAGS) |
| 55 | target_link_libraries(${targetname} ${EIGEN_TEST_CUSTOM_LINKER_FLAGS}) |
| 56 | endif() |
| 57 | |
| 58 | if(${ARGC} GREATER 3) |
| 59 | set(libs_to_link ${ARGV3}) |
| 60 | # it could be that some cmake module provides a bad library string " " (just spaces), |
| 61 | # and that severely breaks target_link_libraries ("can't link to -l-lstdc++" errors). |
| 62 | # so we check for strings containing only spaces. |
| 63 | string(STRIP "${libs_to_link}" libs_to_link_stripped) |
| 64 | string(LENGTH "${libs_to_link_stripped}" libs_to_link_stripped_length) |
| 65 | if(${libs_to_link_stripped_length} GREATER 0) |
| 66 | # notice: no double quotes around ${libs_to_link} here. It may be a list. |
| 67 | target_link_libraries(${targetname} ${libs_to_link}) |
| 68 | endif() |
| 69 | endif() |
| 70 | |
| 71 | if(EIGEN_BIN_BASH_EXISTS) |
| 72 | add_test(${testname_with_suffix} "${Eigen_SOURCE_DIR}/test/runtest.sh" "${testname_with_suffix}") |
| 73 | else() |
| 74 | add_test(${testname_with_suffix} "${targetname}") |
| 75 | endif() |
| 76 | |
| 77 | # Specify target and test labels accoirding to EIGEN_CURRENT_SUBPROJECT |
| 78 | get_property(current_subproject GLOBAL PROPERTY EIGEN_CURRENT_SUBPROJECT) |
| 79 | if ((current_subproject) AND (NOT (current_subproject STREQUAL ""))) |
| 80 | set_property(TARGET ${targetname} PROPERTY LABELS "Build${current_subproject}") |
| 81 | add_dependencies("Build${current_subproject}" ${targetname}) |
| 82 | set_property(TEST ${testname_with_suffix} PROPERTY LABELS "${current_subproject}") |
| 83 | endif() |
| 84 | |
| 85 | endmacro(ei_add_test_internal) |
| 86 | |
| 87 | # Macro to add a test |
| 88 | # |
| 89 | # the unique mandatory parameter testname must correspond to a file |
| 90 | # <testname>.cpp which follows this pattern: |
| 91 | # |
| 92 | # #include "main.h" |
| 93 | # void test_<testname>() { ... } |
| 94 | # |
| 95 | # Depending on the contents of that file, this macro can have 2 behaviors, |
| 96 | # see below. |
| 97 | # |
| 98 | # The optional 2nd parameter is libraries to link to. |
| 99 | # |
| 100 | # A. Default behavior |
| 101 | # |
| 102 | # this macro adds an executable <testname> as well as a ctest test |
| 103 | # named <testname> too. |
| 104 | # |
| 105 | # On platforms with bash simply run: |
| 106 | # "ctest -V" or "ctest -V -R <testname>" |
| 107 | # On other platform use ctest as usual |
| 108 | # |
| 109 | # B. Multi-part behavior |
| 110 | # |
| 111 | # If the source file matches the regexp |
| 112 | # CALL_SUBTEST_[0-9]+|EIGEN_TEST_PART_[0-9]+ |
| 113 | # then it is interpreted as a multi-part test. The behavior then depends on the |
| 114 | # CMake option EIGEN_SPLIT_LARGE_TESTS, which is ON by default. |
| 115 | # |
| 116 | # If EIGEN_SPLIT_LARGE_TESTS is OFF, the behavior is the same as in A (the multi-part |
| 117 | # aspect is ignored). |
| 118 | # |
| 119 | # If EIGEN_SPLIT_LARGE_TESTS is ON, the test is split into multiple executables |
| 120 | # test_<testname>_<N> |
| 121 | # where N runs from 1 to the greatest occurence found in the source file. Each of these |
| 122 | # executables is built passing -DEIGEN_TEST_PART_N. This allows to split large tests |
| 123 | # into smaller executables. |
| 124 | # |
| 125 | # Moreover, targets <testname> are still generated, they |
| 126 | # have the effect of building all the parts of the test. |
| 127 | # |
| 128 | # Again, ctest -R allows to run all matching tests. |
| 129 | macro(ei_add_test testname) |
| 130 | get_property(EIGEN_TESTS_LIST GLOBAL PROPERTY EIGEN_TESTS_LIST) |
| 131 | set(EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}${testname}\n") |
| 132 | set_property(GLOBAL PROPERTY EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}") |
| 133 | |
| 134 | file(READ "${testname}.cpp" test_source) |
| 135 | set(parts 0) |
| 136 | string(REGEX MATCHALL "CALL_SUBTEST_[0-9]+|EIGEN_TEST_PART_[0-9]+|EIGEN_SUFFIXES(;[0-9]+)+" |
| 137 | occurences "${test_source}") |
| 138 | string(REGEX REPLACE "CALL_SUBTEST_|EIGEN_TEST_PART_|EIGEN_SUFFIXES" "" suffixes "${occurences}") |
| 139 | list(REMOVE_DUPLICATES suffixes) |
| 140 | if(EIGEN_SPLIT_LARGE_TESTS AND suffixes) |
| 141 | add_custom_target(${testname}) |
| 142 | foreach(suffix ${suffixes}) |
| 143 | ei_add_test_internal(${testname} ${testname}_${suffix} |
| 144 | "${ARGV1} -DEIGEN_TEST_PART_${suffix}=1" "${ARGV2}") |
| 145 | add_dependencies(${testname} ${testname}_${suffix}) |
| 146 | endforeach(suffix) |
| 147 | else(EIGEN_SPLIT_LARGE_TESTS AND suffixes) |
| 148 | set(symbols_to_enable_all_parts "") |
| 149 | foreach(suffix ${suffixes}) |
| 150 | set(symbols_to_enable_all_parts |
| 151 | "${symbols_to_enable_all_parts} -DEIGEN_TEST_PART_${suffix}=1") |
| 152 | endforeach(suffix) |
| 153 | ei_add_test_internal(${testname} ${testname} "${ARGV1} ${symbols_to_enable_all_parts}" "${ARGV2}") |
| 154 | endif(EIGEN_SPLIT_LARGE_TESTS AND suffixes) |
| 155 | endmacro(ei_add_test) |
| 156 | |
| 157 | |
| 158 | # adds a failtest, i.e. a test that succeed if the program fails to compile |
| 159 | # note that the test runner for these is CMake itself, when passed -DEIGEN_FAILTEST=ON |
| 160 | # so here we're just running CMake commands immediately, we're not adding any targets. |
| 161 | macro(ei_add_failtest testname) |
| 162 | get_property(EIGEN_FAILTEST_FAILURE_COUNT GLOBAL PROPERTY EIGEN_FAILTEST_FAILURE_COUNT) |
| 163 | get_property(EIGEN_FAILTEST_COUNT GLOBAL PROPERTY EIGEN_FAILTEST_COUNT) |
| 164 | |
| 165 | message(STATUS "Checking failtest: ${testname}") |
| 166 | set(filename "${testname}.cpp") |
| 167 | file(READ "${filename}" test_source) |
| 168 | |
| 169 | try_compile(succeeds_when_it_should_fail |
| 170 | "${CMAKE_CURRENT_BINARY_DIR}" |
| 171 | "${CMAKE_CURRENT_SOURCE_DIR}/${filename}" |
| 172 | COMPILE_DEFINITIONS "-DEIGEN_SHOULD_FAIL_TO_BUILD") |
| 173 | if (succeeds_when_it_should_fail) |
| 174 | message(STATUS "FAILED: ${testname} build succeeded when it should have failed") |
| 175 | endif() |
| 176 | |
| 177 | try_compile(succeeds_when_it_should_succeed |
| 178 | "${CMAKE_CURRENT_BINARY_DIR}" |
| 179 | "${CMAKE_CURRENT_SOURCE_DIR}/${filename}" |
| 180 | COMPILE_DEFINITIONS) |
| 181 | if (NOT succeeds_when_it_should_succeed) |
| 182 | message(STATUS "FAILED: ${testname} build failed when it should have succeeded") |
| 183 | endif() |
| 184 | |
| 185 | if (succeeds_when_it_should_fail OR NOT succeeds_when_it_should_succeed) |
| 186 | math(EXPR EIGEN_FAILTEST_FAILURE_COUNT ${EIGEN_FAILTEST_FAILURE_COUNT}+1) |
| 187 | endif() |
| 188 | |
| 189 | math(EXPR EIGEN_FAILTEST_COUNT ${EIGEN_FAILTEST_COUNT}+1) |
| 190 | |
| 191 | set_property(GLOBAL PROPERTY EIGEN_FAILTEST_FAILURE_COUNT ${EIGEN_FAILTEST_FAILURE_COUNT}) |
| 192 | set_property(GLOBAL PROPERTY EIGEN_FAILTEST_COUNT ${EIGEN_FAILTEST_COUNT}) |
| 193 | endmacro(ei_add_failtest) |
| 194 | |
| 195 | # print a summary of the different options |
| 196 | macro(ei_testing_print_summary) |
| 197 | message(STATUS "************************************************************") |
| 198 | message(STATUS "*** Eigen's unit tests configuration summary ***") |
| 199 | message(STATUS "************************************************************") |
| 200 | message(STATUS "") |
| 201 | message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") |
| 202 | message(STATUS "Build site: ${SITE}") |
| 203 | message(STATUS "Build string: ${BUILDNAME}") |
| 204 | get_property(EIGEN_TESTING_SUMMARY GLOBAL PROPERTY EIGEN_TESTING_SUMMARY) |
| 205 | get_property(EIGEN_TESTED_BACKENDS GLOBAL PROPERTY EIGEN_TESTED_BACKENDS) |
| 206 | get_property(EIGEN_MISSING_BACKENDS GLOBAL PROPERTY EIGEN_MISSING_BACKENDS) |
| 207 | message(STATUS "Enabled backends: ${EIGEN_TESTED_BACKENDS}") |
| 208 | message(STATUS "Disabled backends: ${EIGEN_MISSING_BACKENDS}") |
| 209 | |
| 210 | if(EIGEN_DEFAULT_TO_ROW_MAJOR) |
| 211 | message(STATUS "Default order: Row-major") |
| 212 | else() |
| 213 | message(STATUS "Default order: Column-major") |
| 214 | endif() |
| 215 | |
| 216 | if(EIGEN_TEST_NO_EXPLICIT_ALIGNMENT) |
| 217 | message(STATUS "Explicit alignment (hence vectorization) disabled") |
| 218 | elseif(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION) |
| 219 | message(STATUS "Explicit vectorization disabled (alignment kept enabled)") |
| 220 | else() |
| 221 | |
| 222 | message(STATUS "Maximal matrix/vector size: ${EIGEN_TEST_MAX_SIZE}") |
| 223 | |
| 224 | if(EIGEN_TEST_SSE2) |
| 225 | message(STATUS "SSE2: ON") |
| 226 | else() |
| 227 | message(STATUS "SSE2: Using architecture defaults") |
| 228 | endif() |
| 229 | |
| 230 | if(EIGEN_TEST_SSE3) |
| 231 | message(STATUS "SSE3: ON") |
| 232 | else() |
| 233 | message(STATUS "SSE3: Using architecture defaults") |
| 234 | endif() |
| 235 | |
| 236 | if(EIGEN_TEST_SSSE3) |
| 237 | message(STATUS "SSSE3: ON") |
| 238 | else() |
| 239 | message(STATUS "SSSE3: Using architecture defaults") |
| 240 | endif() |
| 241 | |
| 242 | if(EIGEN_TEST_SSE4_1) |
| 243 | message(STATUS "SSE4.1: ON") |
| 244 | else() |
| 245 | message(STATUS "SSE4.1: Using architecture defaults") |
| 246 | endif() |
| 247 | |
| 248 | if(EIGEN_TEST_SSE4_2) |
| 249 | message(STATUS "SSE4.2: ON") |
| 250 | else() |
| 251 | message(STATUS "SSE4.2: Using architecture defaults") |
| 252 | endif() |
| 253 | |
| 254 | if(EIGEN_TEST_ALTIVEC) |
| 255 | message(STATUS "Altivec: ON") |
| 256 | else() |
| 257 | message(STATUS "Altivec: Using architecture defaults") |
| 258 | endif() |
| 259 | |
| 260 | if(EIGEN_TEST_NEON) |
| 261 | message(STATUS "ARM NEON: ON") |
| 262 | else() |
| 263 | message(STATUS "ARM NEON: Using architecture defaults") |
| 264 | endif() |
| 265 | |
| 266 | endif() # vectorization / alignment options |
| 267 | |
| 268 | message(STATUS "\n${EIGEN_TESTING_SUMMARY}") |
| 269 | |
| 270 | message(STATUS "************************************************************") |
| 271 | endmacro(ei_testing_print_summary) |
| 272 | |
| 273 | macro(ei_init_testing) |
| 274 | define_property(GLOBAL PROPERTY EIGEN_CURRENT_SUBPROJECT BRIEF_DOCS " " FULL_DOCS " ") |
| 275 | define_property(GLOBAL PROPERTY EIGEN_TESTED_BACKENDS BRIEF_DOCS " " FULL_DOCS " ") |
| 276 | define_property(GLOBAL PROPERTY EIGEN_MISSING_BACKENDS BRIEF_DOCS " " FULL_DOCS " ") |
| 277 | define_property(GLOBAL PROPERTY EIGEN_TESTING_SUMMARY BRIEF_DOCS " " FULL_DOCS " ") |
| 278 | define_property(GLOBAL PROPERTY EIGEN_TESTS_LIST BRIEF_DOCS " " FULL_DOCS " ") |
| 279 | |
| 280 | set_property(GLOBAL PROPERTY EIGEN_TESTED_BACKENDS "") |
| 281 | set_property(GLOBAL PROPERTY EIGEN_MISSING_BACKENDS "") |
| 282 | set_property(GLOBAL PROPERTY EIGEN_TESTING_SUMMARY "") |
| 283 | set_property(GLOBAL PROPERTY EIGEN_TESTS_LIST "") |
| 284 | |
| 285 | define_property(GLOBAL PROPERTY EIGEN_FAILTEST_FAILURE_COUNT BRIEF_DOCS " " FULL_DOCS " ") |
| 286 | define_property(GLOBAL PROPERTY EIGEN_FAILTEST_COUNT BRIEF_DOCS " " FULL_DOCS " ") |
| 287 | |
| 288 | set_property(GLOBAL PROPERTY EIGEN_FAILTEST_FAILURE_COUNT "0") |
| 289 | set_property(GLOBAL PROPERTY EIGEN_FAILTEST_COUNT "0") |
| 290 | |
| 291 | # uncomment anytime you change the ei_get_compilerver_from_cxx_version_string macro |
| 292 | # ei_test_get_compilerver_from_cxx_version_string() |
| 293 | endmacro(ei_init_testing) |
| 294 | |
| 295 | macro(ei_set_sitename) |
| 296 | # if the sitename is not yet set, try to set it |
| 297 | if(NOT ${SITE} OR ${SITE} STREQUAL "") |
| 298 | set(eigen_computername $ENV{COMPUTERNAME}) |
| 299 | set(eigen_hostname $ENV{HOSTNAME}) |
| 300 | if(eigen_hostname) |
| 301 | set(SITE ${eigen_hostname}) |
| 302 | elseif(eigen_computername) |
| 303 | set(SITE ${eigen_computername}) |
| 304 | endif() |
| 305 | endif() |
| 306 | # in case it is already set, enforce lower case |
| 307 | if(SITE) |
| 308 | string(TOLOWER ${SITE} SITE) |
| 309 | endif() |
| 310 | endmacro(ei_set_sitename) |
| 311 | |
| 312 | macro(ei_get_compilerver VAR) |
| 313 | if(MSVC) |
| 314 | # on windows system, we use a modified CMake script |
| 315 | include(EigenDetermineVSServicePack) |
| 316 | EigenDetermineVSServicePack( my_service_pack ) |
| 317 | |
| 318 | if( my_service_pack ) |
| 319 | set(${VAR} ${my_service_pack}) |
| 320 | else() |
| 321 | set(${VAR} "na") |
| 322 | endif() |
| 323 | else() |
| 324 | # on all other system we rely on ${CMAKE_CXX_COMPILER} |
| 325 | # supporting a "--version" or "/version" flag |
| 326 | |
| 327 | if(WIN32 AND NOT CYGWIN) |
| 328 | set(EIGEN_CXX_FLAG_VERSION "/version") |
| 329 | else() |
| 330 | set(EIGEN_CXX_FLAG_VERSION "--version") |
| 331 | endif() |
| 332 | |
| 333 | # check whether the head command exists |
| 334 | find_program(HEAD_EXE head NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_CMAKE_SYSTEM_PATH) |
| 335 | if(HEAD_EXE) |
| 336 | execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${EIGEN_CXX_FLAG_VERSION} |
| 337 | COMMAND head -n 1 |
| 338 | OUTPUT_VARIABLE eigen_cxx_compiler_version_string OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 339 | else() |
| 340 | execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${EIGEN_CXX_FLAG_VERSION} |
| 341 | OUTPUT_VARIABLE eigen_cxx_compiler_version_string OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 342 | string(REGEX REPLACE "[\n\r].*" "" eigen_cxx_compiler_version_string ${eigen_cxx_compiler_version_string}) |
| 343 | endif() |
| 344 | |
| 345 | ei_get_compilerver_from_cxx_version_string("${eigen_cxx_compiler_version_string}" CNAME CVER) |
| 346 | set(${VAR} "${CNAME}-${CVER}") |
| 347 | |
| 348 | endif() |
| 349 | endmacro(ei_get_compilerver) |
| 350 | |
| 351 | # Extract compiler name and version from a raw version string |
| 352 | # WARNING: if you edit thid macro, then please test it by uncommenting |
| 353 | # the testing macro call in ei_init_testing() of the EigenTesting.cmake file. |
| 354 | # See also the ei_test_get_compilerver_from_cxx_version_string macro at the end of the file |
| 355 | macro(ei_get_compilerver_from_cxx_version_string VERSTRING CNAME CVER) |
| 356 | # extract possible compiler names |
| 357 | string(REGEX MATCH "g\\+\\+" ei_has_gpp ${VERSTRING}) |
| 358 | string(REGEX MATCH "llvm|LLVM" ei_has_llvm ${VERSTRING}) |
| 359 | string(REGEX MATCH "gcc|GCC" ei_has_gcc ${VERSTRING}) |
| 360 | string(REGEX MATCH "icpc|ICC" ei_has_icpc ${VERSTRING}) |
| 361 | string(REGEX MATCH "clang|CLANG" ei_has_clang ${VERSTRING}) |
| 362 | |
| 363 | # combine them |
| 364 | if((ei_has_llvm) AND (ei_has_gpp OR ei_has_gcc)) |
| 365 | set(${CNAME} "llvm-g++") |
| 366 | elseif((ei_has_llvm) AND (ei_has_clang)) |
| 367 | set(${CNAME} "llvm-clang++") |
| 368 | elseif(ei_has_icpc) |
| 369 | set(${CNAME} "icpc") |
| 370 | elseif(ei_has_gpp OR ei_has_gcc) |
| 371 | set(${CNAME} "g++") |
| 372 | else() |
| 373 | set(${CNAME} "_") |
| 374 | endif() |
| 375 | |
| 376 | # extract possible version numbers |
| 377 | # first try to extract 3 isolated numbers: |
| 378 | string(REGEX MATCH " [0-9]+\\.[0-9]+\\.[0-9]+" eicver ${VERSTRING}) |
| 379 | if(NOT eicver) |
| 380 | # try to extract 2 isolated ones: |
| 381 | string(REGEX MATCH " [0-9]+\\.[0-9]+" eicver ${VERSTRING}) |
| 382 | if(NOT eicver) |
| 383 | # try to extract 3: |
| 384 | string(REGEX MATCH "[^0-9][0-9]+\\.[0-9]+\\.[0-9]+" eicver ${VERSTRING}) |
| 385 | if(NOT eicver) |
| 386 | # try to extract 2: |
| 387 | string(REGEX MATCH "[^0-9][0-9]+\\.[0-9]+" eicver ${VERSTRING}) |
| 388 | else() |
| 389 | set(eicver " _") |
| 390 | endif() |
| 391 | endif() |
| 392 | endif() |
| 393 | |
| 394 | string(REGEX REPLACE ".(.*)" "\\1" ${CVER} ${eicver}) |
| 395 | |
| 396 | endmacro(ei_get_compilerver_from_cxx_version_string) |
| 397 | |
| 398 | macro(ei_get_cxxflags VAR) |
| 399 | set(${VAR} "") |
| 400 | ei_is_64bit_env(IS_64BIT_ENV) |
| 401 | if(EIGEN_TEST_NEON) |
| 402 | set(${VAR} NEON) |
| 403 | elseif(EIGEN_TEST_ALTIVEC) |
| 404 | set(${VAR} ALVEC) |
| 405 | elseif(EIGEN_TEST_SSE4_2) |
| 406 | set(${VAR} SSE42) |
| 407 | elseif(EIGEN_TEST_SSE4_1) |
| 408 | set(${VAR} SSE41) |
| 409 | elseif(EIGEN_TEST_SSSE3) |
| 410 | set(${VAR} SSSE3) |
| 411 | elseif(EIGEN_TEST_SSE3) |
| 412 | set(${VAR} SSE3) |
| 413 | elseif(EIGEN_TEST_SSE2 OR IS_64BIT_ENV) |
| 414 | set(${VAR} SSE2) |
| 415 | endif() |
| 416 | |
| 417 | if(EIGEN_TEST_OPENMP) |
| 418 | if (${VAR} STREQUAL "") |
| 419 | set(${VAR} OMP) |
| 420 | else() |
| 421 | set(${VAR} ${${VAR}}-OMP) |
| 422 | endif() |
| 423 | endif() |
| 424 | |
| 425 | if(EIGEN_DEFAULT_TO_ROW_MAJOR) |
| 426 | if (${VAR} STREQUAL "") |
| 427 | set(${VAR} ROW) |
| 428 | else() |
| 429 | set(${VAR} ${${VAR}}-ROWMAJ) |
| 430 | endif() |
| 431 | endif() |
| 432 | endmacro(ei_get_cxxflags) |
| 433 | |
| 434 | macro(ei_set_build_string) |
| 435 | ei_get_compilerver(LOCAL_COMPILER_VERSION) |
| 436 | ei_get_cxxflags(LOCAL_COMPILER_FLAGS) |
| 437 | |
| 438 | include(EigenDetermineOSVersion) |
| 439 | DetermineOSVersion(OS_VERSION) |
| 440 | |
| 441 | set(TMP_BUILD_STRING ${OS_VERSION}-${LOCAL_COMPILER_VERSION}) |
| 442 | |
| 443 | if (NOT ${LOCAL_COMPILER_FLAGS} STREQUAL "") |
| 444 | set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-${LOCAL_COMPILER_FLAGS}) |
| 445 | endif() |
| 446 | |
| 447 | ei_is_64bit_env(IS_64BIT_ENV) |
| 448 | if(NOT IS_64BIT_ENV) |
| 449 | set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-32bit) |
| 450 | else() |
| 451 | set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-64bit) |
| 452 | endif() |
| 453 | |
| 454 | if(EIGEN_BUILD_STRING_SUFFIX) |
| 455 | set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-${EIGEN_BUILD_STRING_SUFFIX}) |
| 456 | endif() |
| 457 | |
| 458 | string(TOLOWER ${TMP_BUILD_STRING} BUILDNAME) |
| 459 | endmacro(ei_set_build_string) |
| 460 | |
| 461 | macro(ei_is_64bit_env VAR) |
| 462 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) |
| 463 | set(${VAR} 1) |
| 464 | elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) |
| 465 | set(${VAR} 0) |
| 466 | else() |
| 467 | message(WARNING "Unsupported pointer size. Please contact the authors.") |
| 468 | endif() |
| 469 | endmacro(ei_is_64bit_env) |
| 470 | |
| 471 | |
| 472 | # helper macro for testing ei_get_compilerver_from_cxx_version_string |
| 473 | # STR: raw version string |
| 474 | # REFNAME: expected compiler name |
| 475 | # REFVER: expected compiler version |
| 476 | macro(ei_test1_get_compilerver_from_cxx_version_string STR REFNAME REFVER) |
| 477 | ei_get_compilerver_from_cxx_version_string(${STR} CNAME CVER) |
| 478 | if((NOT ${REFNAME} STREQUAL ${CNAME}) OR (NOT ${REFVER} STREQUAL ${CVER})) |
| 479 | message("STATUS ei_get_compilerver_from_cxx_version_string error:") |
| 480 | message("Expected \"${REFNAME}-${REFVER}\", got \"${CNAME}-${CVER}\"") |
| 481 | endif() |
| 482 | endmacro(ei_test1_get_compilerver_from_cxx_version_string) |
| 483 | |
| 484 | # macro for testing ei_get_compilerver_from_cxx_version_string |
| 485 | # feel free to add more version strings |
| 486 | macro(ei_test_get_compilerver_from_cxx_version_string) |
| 487 | 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") |
| 488 | ei_test1_get_compilerver_from_cxx_version_string("c++ (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)" "g++" "4.5.1") |
| 489 | ei_test1_get_compilerver_from_cxx_version_string("icpc (ICC) 11.0 20081105" "icpc" "11.0") |
| 490 | ei_test1_get_compilerver_from_cxx_version_string("g++-3.4 (GCC) 3.4.6" "g++" "3.4.6") |
| 491 | 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") |
| 492 | ei_test1_get_compilerver_from_cxx_version_string("icpc (ICC) 12.0.5 20110719" "icpc" "12.0.5") |
| 493 | 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") |
| 494 | 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") |
| 495 | ei_test1_get_compilerver_from_cxx_version_string("g++-mp-4.4 (GCC) 4.4.6" "g++" "4.4.6") |
| 496 | ei_test1_get_compilerver_from_cxx_version_string("g++-mp-4.4 (GCC) 2011" "g++" "4.4") |
| 497 | endmacro(ei_test_get_compilerver_from_cxx_version_string) |