diff options
-rw-r--r-- | Tests/CMakeTests/ProcessorCountTest.cmake.in | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/Tests/CMakeTests/ProcessorCountTest.cmake.in b/Tests/CMakeTests/ProcessorCountTest.cmake.in index ac7a1da..6550973 100644 --- a/Tests/CMakeTests/ProcessorCountTest.cmake.in +++ b/Tests/CMakeTests/ProcessorCountTest.cmake.in @@ -3,11 +3,45 @@ include(ProcessorCount) ProcessorCount(processor_count) message("processor_count='${processor_count}'") -if(NOT processor_count MATCHES "^[0-9]+$") - message(FATAL_ERROR "ProcessorCount function returned a non-integer") +execute_process( + COMMAND "@CMAKE_BINARY_DIR@/Source/kwsys/$ENV{CMAKE_CONFIG_TYPE}/cmsysTestsCxx" + testSystemInformation + OUTPUT_VARIABLE out) +string(REGEX REPLACE "(.*)GetNumberOfPhysicalCPU:.([0-9]*)(.*)" "\\2" + system_info_processor_count "${out}") +message("system_info_processor_count='${system_info_processor_count}'") + +if(system_info_processor_count EQUAL processor_count) + message("processor count matches system information") endif() +# Evaluate possible error conditions: +# +set(err 0) + if(processor_count EQUAL 0) - message(FATAL_ERROR "could not determine number of processors + set(err 1) + message("could not determine number of processors - Additional code for this platform needed in ProcessorCount.cmake?") endif() + +if(NOT system_info_processor_count EQUAL processor_count) + set(err 2) + message("SystemInformation and ProcessorCount.cmake disagree:\n" + "processor_count='${processor_count}'\n" + "SystemInformation processor_count='${system_info_processor_count}'") +endif() + +if(NOT processor_count MATCHES "^[0-9]+$") + set(err 3) + message("ProcessorCount function returned a non-integer") +endif() + +if(NOT system_info_processor_count MATCHES "^[0-9]+$") + set(err 4) + message("SystemInformation ProcessorCount function returned a non-integer") +endif() + +if(err) + message(FATAL_ERROR "err='${err}'") +endif() |