summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeTests/ProcessorCountTest.cmake.in
blob: c653628e7042aef55d4004e899778c9fec669321 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
include(ProcessorCount)

ProcessorCount(processor_count)
message("processor_count='${processor_count}'")

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()

message("")
message("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
message("")
message("out='${out}'")
message("")

# Evaluate possible error conditions:
#
set(err 0)

if(processor_count EQUAL 0)
  set(err 1)
  message("err 1")
  message("could not determine number of processors
- Additional code for this platform needed in ProcessorCount.cmake?")
  message("")
endif()

if(NOT system_info_processor_count EQUAL processor_count)
  set(err 2)
  message("err 2")
  message("SystemInformation and ProcessorCount.cmake disagree:\n"
    "processor_count='${processor_count}'\n"
    "SystemInformation processor_count='${system_info_processor_count}'")
  message("")
endif()

if(NOT processor_count MATCHES "^[0-9]+$")
  set(err 3)
  message("err 3")
  message("ProcessorCount function returned a non-integer")
  message("")
endif()

if(NOT system_info_processor_count MATCHES "^[0-9]+$")
  set(err 4)
  message("err 4")
  message("SystemInformation ProcessorCount function returned a non-integer")
  message("")
endif()

# TODO: Make this test fail again, once all the dev work is done...
#
if(err)
#  message(FATAL_ERROR "err='${err}'")
endif()