You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

544 lines
20 KiB

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