1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-18 17:31:57 +08:00

KWSys 2023-08-22 (7f82ad45)

Code extracted from:

    https://gitlab.kitware.com/utils/kwsys.git

at commit 7f82ad457aad02839c5974225fec7092e155d700 (master).

Upstream Shortlog
-----------------

scivision (5):
      12825be6 lint: use foreach(... IN {ITEMS,LISTS} ...)
      f10cb6ad lint: use modern add_test(NAME ... COMMAND ...)
      ebb95153 lint: set_property(TEST
      f26b1b39 SystemInformation: use std::cerr like rest of KWSys
      3c403fa9 SystemInformation: Replace C-style cast with reinterpret_cast
This commit is contained in:
KWSys Upstream
2023-08-22 10:07:31 -04:00
committed by Brad King
parent 5df527f7af
commit c7b30fa8b3
2 changed files with 30 additions and 24 deletions

View File

@@ -634,7 +634,7 @@ set(cppclasses
Directory DynamicLoader Encoding Glob RegularExpression SystemTools
CommandLineArguments FStream SystemInformation ConsoleBuf Status
)
foreach(cpp ${cppclasses})
foreach(cpp IN LISTS cppclasses)
if(KWSYS_USE_${cpp})
# Use the corresponding class.
set(KWSYS_CLASSES ${KWSYS_CLASSES} ${cpp})
@@ -647,7 +647,7 @@ foreach(cpp ${cppclasses})
endforeach()
# Add selected C components.
foreach(c
foreach(c IN ITEMS
Process Base64 Encoding MD5 Terminal System String
)
if(KWSYS_USE_${c})
@@ -679,7 +679,7 @@ if(KWSYS_USE_Process)
endif()
# Add selected C sources.
foreach(c Base64 Encoding MD5 Terminal System String)
foreach(c IN ITEMS Base64 Encoding MD5 Terminal System String)
if(KWSYS_USE_${c})
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}C.c)
list(APPEND KWSYS_C_SRCS ${c}C.c)
@@ -690,7 +690,7 @@ foreach(c Base64 Encoding MD5 Terminal System String)
endforeach()
# Configure headers of C++ classes and construct the list of sources.
foreach(c ${KWSYS_CLASSES})
foreach(c IN LISTS KWSYS_CLASSES)
# Add this source to the list of source files for the library.
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}CXX.cxx)
list(APPEND KWSYS_CXX_SRCS ${c}CXX.cxx)
@@ -712,7 +712,7 @@ foreach(c ${KWSYS_CLASSES})
endforeach()
# Configure C headers.
foreach(h ${KWSYS_H_FILES})
foreach(h IN LISTS KWSYS_H_FILES)
# Configure the header into the given directory.
configure_file(${PROJECT_SOURCE_DIR}/${h}.h.in ${KWSYS_HEADER_DIR}/${h}.h
@ONLY IMMEDIATE)
@@ -727,7 +727,7 @@ foreach(h ${KWSYS_H_FILES})
endforeach()
# Configure other C++ headers.
foreach(h ${KWSYS_HXX_FILES})
foreach(h IN LISTS KWSYS_HXX_FILES)
# Configure the header into the given directory.
configure_file(${PROJECT_SOURCE_DIR}/${h}.hxx.in ${KWSYS_HEADER_DIR}/${h}.hxx
@ONLY IMMEDIATE)
@@ -956,9 +956,11 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
add_executable(${KWSYS_NAMESPACE}TestsC ${KWSYS_C_TEST_SRCS})
set_property(TARGET ${KWSYS_NAMESPACE}TestsC PROPERTY LABELS ${KWSYS_LABELS_EXE})
target_link_libraries(${KWSYS_NAMESPACE}TestsC ${KWSYS_TARGET_C_LINK})
foreach(testfile ${KWSYS_C_TESTS})
foreach(testfile IN LISTS KWSYS_C_TESTS)
get_filename_component(test "${testfile}" NAME_WE)
add_test(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}})
add_test(NAME kwsys.${test}
COMMAND ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}}
)
set_property(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
endforeach()
@@ -1080,9 +1082,11 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
-p
some junk at the end
)
foreach(testfile ${KWSYS_CXX_TESTS})
foreach(testfile IN LISTS KWSYS_CXX_TESTS)
get_filename_component(test "${testfile}" NAME_WE)
add_test(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsCxx ${test} ${KWSYS_TEST_ARGS_${test}})
add_test(NAME kwsys.${test}
COMMAND ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsCxx ${test} ${KWSYS_TEST_ARGS_${test}}
)
set_property(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
endforeach()
@@ -1091,10 +1095,12 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
set_property(TARGET ${KWSYS_NAMESPACE}TestProcess PROPERTY LABELS ${KWSYS_LABELS_EXE})
target_link_libraries(${KWSYS_NAMESPACE}TestProcess ${KWSYS_TARGET_C_LINK})
#set(KWSYS_TEST_PROCESS_7 7) # uncomment to run timing-sensitive test locally
foreach(n 1 2 3 4 5 6 ${KWSYS_TEST_PROCESS_7} 9 10)
add_test(kwsys.testProcess-${n} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestProcess ${n})
foreach(n IN ITEMS 1 2 3 4 5 6 ${KWSYS_TEST_PROCESS_7} 9 10)
add_test(NAME kwsys.testProcess-${n}
COMMAND ${EXEC_DIR}/${KWSYS_NAMESPACE}TestProcess ${n}
)
set_property(TEST kwsys.testProcess-${n} PROPERTY LABELS ${KWSYS_LABELS_TEST})
set_tests_properties(kwsys.testProcess-${n} PROPERTIES TIMEOUT 120)
set_property(TEST kwsys.testProcess-${n} PROPERTY TIMEOUT 120)
endforeach()
set(testProcess_COMPILE_FLAGS "")
@@ -1121,9 +1127,9 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
# Configure some test properties.
if(KWSYS_STANDALONE)
# We expect test to fail
set_tests_properties(kwsys.testFail PROPERTIES WILL_FAIL ON)
set_property(TEST kwsys.testFail PROPERTY WILL_FAIL ON)
get_test_property(kwsys.testFail WILL_FAIL wfv)
set_tests_properties(kwsys.testFail PROPERTIES MEASUREMENT "Some Key=Some Value")
set_property(TEST kwsys.testFail PROPERTY MEASUREMENT "Some Key=Some Value")
message(STATUS "GET_TEST_PROPERTY returned: ${wfv}")
endif()
@@ -1133,7 +1139,7 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
# Suppress known consistent failures on buggy systems.
if(KWSYS_TEST_BOGUS_FAILURES)
set_tests_properties(${KWSYS_TEST_BOGUS_FAILURES} PROPERTIES WILL_FAIL ON)
set_property(TEST ${KWSYS_TEST_BOGUS_FAILURES} PROPERTY WILL_FAIL ON)
endif()
endif()

View File

@@ -3443,7 +3443,7 @@ bool SystemInformationImplementation::RetrieveInformationFromCpuInfoFile()
FILE* fd = fopen("/proc/cpuinfo", "r");
if (!fd) {
std::cout << "Problem opening /proc/cpuinfo" << std::endl;
std::cerr << "Problem opening /proc/cpuinfo\n";
return false;
}
@@ -3454,7 +3454,7 @@ bool SystemInformationImplementation::RetrieveInformationFromCpuInfoFile()
}
fclose(fd);
if (fileSize < 2) {
std::cout << "No data in /proc/cpuinfo" << std::endl;
std::cerr << "No data in /proc/cpuinfo\n";
return false;
}
buffer.resize(fileSize - 2);
@@ -4162,7 +4162,7 @@ bool SystemInformationImplementation::QueryLinuxMemory()
struct utsname unameInfo;
int errorFlag = uname(&unameInfo);
if (errorFlag != 0) {
std::cout << "Problem calling uname(): " << strerror(errno) << std::endl;
std::cerr << "Problem calling uname(): " << strerror(errno) << "\n";
return false;
}
@@ -4182,7 +4182,7 @@ bool SystemInformationImplementation::QueryLinuxMemory()
FILE* fd = fopen("/proc/meminfo", "r");
if (!fd) {
std::cout << "Problem opening /proc/meminfo" << std::endl;
std::cerr << "Problem opening /proc/meminfo\n";
return false;
}
@@ -4221,7 +4221,7 @@ bool SystemInformationImplementation::QueryLinuxMemory()
this->TotalVirtualMemory = value[mSwapTotal] / 1024;
this->AvailableVirtualMemory = value[mSwapFree] / 1024;
} else {
std::cout << "Problem parsing /proc/meminfo" << std::endl;
std::cerr << "Problem parsing /proc/meminfo\n";
fclose(fd);
return false;
}
@@ -4248,7 +4248,7 @@ bool SystemInformationImplementation::QueryLinuxMemory()
this->AvailablePhysicalMemory =
(ap + buffersMem + cachedMem) >> 10 >> 10;
} else {
std::cout << "Problem parsing /proc/meminfo" << std::endl;
std::cerr << "Problem parsing /proc/meminfo\n";
fclose(fd);
return false;
}
@@ -4472,8 +4472,8 @@ void SystemInformationImplementation::CPUCountWindows()
typedef BOOL(WINAPI * GetLogicalProcessorInformationType)(
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD);
static GetLogicalProcessorInformationType pGetLogicalProcessorInformation =
(GetLogicalProcessorInformationType)GetProcAddress(
GetModuleHandleW(L"kernel32"), "GetLogicalProcessorInformation");
reinterpret_cast<GetLogicalProcessorInformationType>(GetProcAddress(
GetModuleHandleW(L"kernel32"), "GetLogicalProcessorInformation"));
if (!pGetLogicalProcessorInformation) {
// Fallback to approximate implementation on ancient Windows versions.