I feel like I'm taking the position the great Greg KH has in Linux kernel development: the maintainer of crap. You write it "QNX" but you speak it "crap". Don't get me wrong, I hate this stuff. But I have to deal with it so I want CMake work there properly to reduce my pain.
So here is a fix for the ProcessorCount.cmake module to work properly there. This also makes it possible on all platforms that have getconf to detect if _NPROCESSORS_ONLN is not supported. I would love to see if someone of Kitware could get into contact with the guys at QNX. AFAIK there is sort of a free partner program where you get developer licenses of their OS. I have two virtual machines (Linux KVM) running with 6.4.1 and 6.5.0 which works (for some values of works). If you would go and throw something like 6.3.2, 6.4.1, and 6.5.0 in virtual machines you could make them build cmake nightly and test all this stuff. Sadly I can't use my work machines for that (for different reasons). Eike
From b33fc35b4b3e75e36da2a27083060e6cb5d95b7f Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer <[email protected]> Date: Sat, 6 Nov 2010 11:20:35 +0100 Subject: [PATCH] Fix ProcessorCount.cmake returning bad stuff If getconf is present but does not understand _NPROCESSORS_ONLN this went undetected by the testcase but the stderr output cluttered the console. QNX is such a case. Implement a different way to get the processor count there. --- Modules/ProcessorCount.cmake | 34 +++++++++++++++++++++++++++------- 1 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake index b46a012..51fcb20 100644 --- a/Modules/ProcessorCount.cmake +++ b/Modules/ProcessorCount.cmake @@ -45,15 +45,35 @@ function(ProcessorCount var) # Linux and other systems with getconf: execute_process(COMMAND ${ProcessorCount_cmd_getconf} _NPROCESSORS_ONLN OUTPUT_STRIP_TRAILING_WHITESPACE - OUTPUT_VARIABLE count) - else() - # Linux and other systems with /proc/cpuinfo: - set(cpuinfo_file /proc/cpuinfo) - if(EXISTS "${cpuinfo_file}") - file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$") - list(LENGTH procs count) + RESULT_VARIABLE res + OUTPUT_VARIABLE count + ERROR_VARIABLE trash) + if(res EQUAL 0) + set(${var} ${count} PARENT_SCOPE) + return() endif() endif() + + # Linux and other systems with /proc/cpuinfo: + set(cpuinfo_file /proc/cpuinfo) + if(EXISTS "${cpuinfo_file}") + file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$") + list(LENGTH procs count) + set(${var} ${count} PARENT_SCOPE) + return() + endif() + + # QNX has pidin + find_program(ProcessorCount_cmd_pidin pidin) + if(ProcessorCount_cmd_pidin) + execute_process(COMMAND ${ProcessorCount_cmd_pidin} info + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE pidin_output) + string(REGEX MATCHALL "Processor[0-9]+: " procs "${pidin_output}") + list(LENGTH procs count) + set(${var} ${count} PARENT_SCOPE) + return() + endif() endif() set(${var} ${count} PARENT_SCOPE) -- 1.7.1
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ cmake-developers mailing list [email protected] http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers
