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 ${CMAKE_CXX_COMPILER_ID} EQUAL "Intel")
|
---|
328 | set(EIGEN_CXX_FLAG_VERSION "/version")
|
---|
329 | else()
|
---|
330 | set(EIGEN_CXX_FLAG_VERSION "--version")
|
---|
331 | endif()
|
---|
332 |
|
---|
333 | execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${EIGEN_CXX_FLAG_VERSION}
|
---|
334 | OUTPUT_VARIABLE eigen_cxx_compiler_version_string OUTPUT_STRIP_TRAILING_WHITESPACE)
|
---|
335 | string(REGEX REPLACE "[\n\r].*" "" eigen_cxx_compiler_version_string ${eigen_cxx_compiler_version_string})
|
---|
336 |
|
---|
337 | ei_get_compilerver_from_cxx_version_string("${eigen_cxx_compiler_version_string}" CNAME CVER)
|
---|
338 | set(${VAR} "${CNAME}-${CVER}")
|
---|
339 |
|
---|
340 | endif()
|
---|
341 | endmacro(ei_get_compilerver)
|
---|
342 |
|
---|
343 | # Extract compiler name and version from a raw version string
|
---|
344 | # WARNING: if you edit thid macro, then please test it by uncommenting
|
---|
345 | # the testing macro call in ei_init_testing() of the EigenTesting.cmake file.
|
---|
346 | # See also the ei_test_get_compilerver_from_cxx_version_string macro at the end of the file
|
---|
347 | macro(ei_get_compilerver_from_cxx_version_string VERSTRING CNAME CVER)
|
---|
348 | # extract possible compiler names
|
---|
349 | string(REGEX MATCH "g\\+\\+" ei_has_gpp ${VERSTRING})
|
---|
350 | string(REGEX MATCH "llvm|LLVM" ei_has_llvm ${VERSTRING})
|
---|
351 | string(REGEX MATCH "gcc|GCC" ei_has_gcc ${VERSTRING})
|
---|
352 | string(REGEX MATCH "icpc|ICC" ei_has_icpc ${VERSTRING})
|
---|
353 | string(REGEX MATCH "clang|CLANG" ei_has_clang ${VERSTRING})
|
---|
354 |
|
---|
355 | # combine them
|
---|
356 | if((ei_has_llvm) AND (ei_has_gpp OR ei_has_gcc))
|
---|
357 | set(${CNAME} "llvm-g++")
|
---|
358 | elseif((ei_has_llvm) AND (ei_has_clang))
|
---|
359 | set(${CNAME} "llvm-clang++")
|
---|
360 | elseif(ei_has_icpc)
|
---|
361 | set(${CNAME} "icpc")
|
---|
362 | elseif(ei_has_gpp OR ei_has_gcc)
|
---|
363 | set(${CNAME} "g++")
|
---|
364 | else()
|
---|
365 | set(${CNAME} "_")
|
---|
366 | endif()
|
---|
367 |
|
---|
368 | # extract possible version numbers
|
---|
369 | # first try to extract 3 isolated numbers:
|
---|
370 | string(REGEX MATCH " [0-9]+\\.[0-9]+\\.[0-9]+" eicver ${VERSTRING})
|
---|
371 | if(NOT eicver)
|
---|
372 | # try to extract 2 isolated ones:
|
---|
373 | string(REGEX MATCH " [0-9]+\\.[0-9]+" eicver ${VERSTRING})
|
---|
374 | if(NOT eicver)
|
---|
375 | # try to extract 3:
|
---|
376 | string(REGEX MATCH "[^0-9][0-9]+\\.[0-9]+\\.[0-9]+" eicver ${VERSTRING})
|
---|
377 | if(NOT eicver)
|
---|
378 | # try to extract 2:
|
---|
379 | string(REGEX MATCH "[^0-9][0-9]+\\.[0-9]+" eicver ${VERSTRING})
|
---|
380 | else()
|
---|
381 | set(eicver " _")
|
---|
382 | endif()
|
---|
383 | endif()
|
---|
384 | endif()
|
---|
385 |
|
---|
386 | string(REGEX REPLACE ".(.*)" "\\1" ${CVER} ${eicver})
|
---|
387 |
|
---|
388 | endmacro(ei_get_compilerver_from_cxx_version_string)
|
---|
389 |
|
---|
390 | macro(ei_get_cxxflags VAR)
|
---|
391 | set(${VAR} "")
|
---|
392 | ei_is_64bit_env(IS_64BIT_ENV)
|
---|
393 | if(EIGEN_TEST_NEON)
|
---|
394 | set(${VAR} NEON)
|
---|
395 | elseif(EIGEN_TEST_ALTIVEC)
|
---|
396 | set(${VAR} ALVEC)
|
---|
397 | elseif(EIGEN_TEST_SSE4_2)
|
---|
398 | set(${VAR} SSE42)
|
---|
399 | elseif(EIGEN_TEST_SSE4_1)
|
---|
400 | set(${VAR} SSE41)
|
---|
401 | elseif(EIGEN_TEST_SSSE3)
|
---|
402 | set(${VAR} SSSE3)
|
---|
403 | elseif(EIGEN_TEST_SSE3)
|
---|
404 | set(${VAR} SSE3)
|
---|
405 | elseif(EIGEN_TEST_SSE2 OR IS_64BIT_ENV)
|
---|
406 | set(${VAR} SSE2)
|
---|
407 | endif()
|
---|
408 |
|
---|
409 | if(EIGEN_TEST_OPENMP)
|
---|
410 | if (${VAR} STREQUAL "")
|
---|
411 | set(${VAR} OMP)
|
---|
412 | else()
|
---|
413 | set(${VAR} ${${VAR}}-OMP)
|
---|
414 | endif()
|
---|
415 | endif()
|
---|
416 |
|
---|
417 | if(EIGEN_DEFAULT_TO_ROW_MAJOR)
|
---|
418 | if (${VAR} STREQUAL "")
|
---|
419 | set(${VAR} ROW)
|
---|
420 | else()
|
---|
421 | set(${VAR} ${${VAR}}-ROWMAJ)
|
---|
422 | endif()
|
---|
423 | endif()
|
---|
424 | endmacro(ei_get_cxxflags)
|
---|
425 |
|
---|
426 | macro(ei_set_build_string)
|
---|
427 | ei_get_compilerver(LOCAL_COMPILER_VERSION)
|
---|
428 | ei_get_cxxflags(LOCAL_COMPILER_FLAGS)
|
---|
429 |
|
---|
430 | include(EigenDetermineOSVersion)
|
---|
431 | DetermineOSVersion(OS_VERSION)
|
---|
432 |
|
---|
433 | set(TMP_BUILD_STRING ${OS_VERSION}-${LOCAL_COMPILER_VERSION})
|
---|
434 |
|
---|
435 | if (NOT ${LOCAL_COMPILER_FLAGS} STREQUAL "")
|
---|
436 | set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-${LOCAL_COMPILER_FLAGS})
|
---|
437 | endif()
|
---|
438 |
|
---|
439 | ei_is_64bit_env(IS_64BIT_ENV)
|
---|
440 | if(NOT IS_64BIT_ENV)
|
---|
441 | set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-32bit)
|
---|
442 | else()
|
---|
443 | set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-64bit)
|
---|
444 | endif()
|
---|
445 |
|
---|
446 | if(EIGEN_BUILD_STRING_SUFFIX)
|
---|
447 | set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-${EIGEN_BUILD_STRING_SUFFIX})
|
---|
448 | endif()
|
---|
449 |
|
---|
450 | string(TOLOWER ${TMP_BUILD_STRING} BUILDNAME)
|
---|
451 | endmacro(ei_set_build_string)
|
---|
452 |
|
---|
453 | macro(ei_is_64bit_env VAR)
|
---|
454 | if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
---|
455 | set(${VAR} 1)
|
---|
456 | elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
---|
457 | set(${VAR} 0)
|
---|
458 | else()
|
---|
459 | message(WARNING "Unsupported pointer size. Please contact the authors.")
|
---|
460 | endif()
|
---|
461 | endmacro(ei_is_64bit_env)
|
---|
462 |
|
---|
463 |
|
---|
464 | # helper macro for testing ei_get_compilerver_from_cxx_version_string
|
---|
465 | # STR: raw version string
|
---|
466 | # REFNAME: expected compiler name
|
---|
467 | # REFVER: expected compiler version
|
---|
468 | macro(ei_test1_get_compilerver_from_cxx_version_string STR REFNAME REFVER)
|
---|
469 | ei_get_compilerver_from_cxx_version_string(${STR} CNAME CVER)
|
---|
470 | if((NOT ${REFNAME} STREQUAL ${CNAME}) OR (NOT ${REFVER} STREQUAL ${CVER}))
|
---|
471 | message("STATUS ei_get_compilerver_from_cxx_version_string error:")
|
---|
472 | message("Expected \"${REFNAME}-${REFVER}\", got \"${CNAME}-${CVER}\"")
|
---|
473 | endif()
|
---|
474 | endmacro(ei_test1_get_compilerver_from_cxx_version_string)
|
---|
475 |
|
---|
476 | # macro for testing ei_get_compilerver_from_cxx_version_string
|
---|
477 | # feel free to add more version strings
|
---|
478 | macro(ei_test_get_compilerver_from_cxx_version_string)
|
---|
479 | 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")
|
---|
480 | ei_test1_get_compilerver_from_cxx_version_string("c++ (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4)" "g++" "4.5.1")
|
---|
481 | ei_test1_get_compilerver_from_cxx_version_string("icpc (ICC) 11.0 20081105" "icpc" "11.0")
|
---|
482 | ei_test1_get_compilerver_from_cxx_version_string("g++-3.4 (GCC) 3.4.6" "g++" "3.4.6")
|
---|
483 | 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")
|
---|
484 | ei_test1_get_compilerver_from_cxx_version_string("icpc (ICC) 12.0.5 20110719" "icpc" "12.0.5")
|
---|
485 | 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")
|
---|
486 | 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")
|
---|
487 | ei_test1_get_compilerver_from_cxx_version_string("g++-mp-4.4 (GCC) 4.4.6" "g++" "4.4.6")
|
---|
488 | ei_test1_get_compilerver_from_cxx_version_string("g++-mp-4.4 (GCC) 2011" "g++" "4.4")
|
---|
489 | endmacro(ei_test_get_compilerver_from_cxx_version_string)
|
---|