mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-19 11:18:40 +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:

committed by
Brad King

parent
5df527f7af
commit
c7b30fa8b3
@@ -634,7 +634,7 @@ set(cppclasses
|
|||||||
Directory DynamicLoader Encoding Glob RegularExpression SystemTools
|
Directory DynamicLoader Encoding Glob RegularExpression SystemTools
|
||||||
CommandLineArguments FStream SystemInformation ConsoleBuf Status
|
CommandLineArguments FStream SystemInformation ConsoleBuf Status
|
||||||
)
|
)
|
||||||
foreach(cpp ${cppclasses})
|
foreach(cpp IN LISTS cppclasses)
|
||||||
if(KWSYS_USE_${cpp})
|
if(KWSYS_USE_${cpp})
|
||||||
# Use the corresponding class.
|
# Use the corresponding class.
|
||||||
set(KWSYS_CLASSES ${KWSYS_CLASSES} ${cpp})
|
set(KWSYS_CLASSES ${KWSYS_CLASSES} ${cpp})
|
||||||
@@ -647,7 +647,7 @@ foreach(cpp ${cppclasses})
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Add selected C components.
|
# Add selected C components.
|
||||||
foreach(c
|
foreach(c IN ITEMS
|
||||||
Process Base64 Encoding MD5 Terminal System String
|
Process Base64 Encoding MD5 Terminal System String
|
||||||
)
|
)
|
||||||
if(KWSYS_USE_${c})
|
if(KWSYS_USE_${c})
|
||||||
@@ -679,7 +679,7 @@ if(KWSYS_USE_Process)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Add selected C sources.
|
# 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(KWSYS_USE_${c})
|
||||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}C.c)
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}C.c)
|
||||||
list(APPEND KWSYS_C_SRCS ${c}C.c)
|
list(APPEND KWSYS_C_SRCS ${c}C.c)
|
||||||
@@ -690,7 +690,7 @@ foreach(c Base64 Encoding MD5 Terminal System String)
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Configure headers of C++ classes and construct the list of sources.
|
# 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.
|
# Add this source to the list of source files for the library.
|
||||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}CXX.cxx)
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}CXX.cxx)
|
||||||
list(APPEND KWSYS_CXX_SRCS ${c}CXX.cxx)
|
list(APPEND KWSYS_CXX_SRCS ${c}CXX.cxx)
|
||||||
@@ -712,7 +712,7 @@ foreach(c ${KWSYS_CLASSES})
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Configure C headers.
|
# Configure C headers.
|
||||||
foreach(h ${KWSYS_H_FILES})
|
foreach(h IN LISTS KWSYS_H_FILES)
|
||||||
# Configure the header into the given directory.
|
# Configure the header into the given directory.
|
||||||
configure_file(${PROJECT_SOURCE_DIR}/${h}.h.in ${KWSYS_HEADER_DIR}/${h}.h
|
configure_file(${PROJECT_SOURCE_DIR}/${h}.h.in ${KWSYS_HEADER_DIR}/${h}.h
|
||||||
@ONLY IMMEDIATE)
|
@ONLY IMMEDIATE)
|
||||||
@@ -727,7 +727,7 @@ foreach(h ${KWSYS_H_FILES})
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Configure other C++ headers.
|
# Configure other C++ headers.
|
||||||
foreach(h ${KWSYS_HXX_FILES})
|
foreach(h IN LISTS KWSYS_HXX_FILES)
|
||||||
# Configure the header into the given directory.
|
# Configure the header into the given directory.
|
||||||
configure_file(${PROJECT_SOURCE_DIR}/${h}.hxx.in ${KWSYS_HEADER_DIR}/${h}.hxx
|
configure_file(${PROJECT_SOURCE_DIR}/${h}.hxx.in ${KWSYS_HEADER_DIR}/${h}.hxx
|
||||||
@ONLY IMMEDIATE)
|
@ONLY IMMEDIATE)
|
||||||
@@ -956,9 +956,11 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
|
|||||||
add_executable(${KWSYS_NAMESPACE}TestsC ${KWSYS_C_TEST_SRCS})
|
add_executable(${KWSYS_NAMESPACE}TestsC ${KWSYS_C_TEST_SRCS})
|
||||||
set_property(TARGET ${KWSYS_NAMESPACE}TestsC PROPERTY LABELS ${KWSYS_LABELS_EXE})
|
set_property(TARGET ${KWSYS_NAMESPACE}TestsC PROPERTY LABELS ${KWSYS_LABELS_EXE})
|
||||||
target_link_libraries(${KWSYS_NAMESPACE}TestsC ${KWSYS_TARGET_C_LINK})
|
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)
|
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})
|
set_property(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
@@ -1080,9 +1082,11 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
|
|||||||
-p
|
-p
|
||||||
some junk at the end
|
some junk at the end
|
||||||
)
|
)
|
||||||
foreach(testfile ${KWSYS_CXX_TESTS})
|
foreach(testfile IN LISTS KWSYS_CXX_TESTS)
|
||||||
get_filename_component(test "${testfile}" NAME_WE)
|
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})
|
set_property(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
@@ -1091,10 +1095,12 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
|
|||||||
set_property(TARGET ${KWSYS_NAMESPACE}TestProcess PROPERTY LABELS ${KWSYS_LABELS_EXE})
|
set_property(TARGET ${KWSYS_NAMESPACE}TestProcess PROPERTY LABELS ${KWSYS_LABELS_EXE})
|
||||||
target_link_libraries(${KWSYS_NAMESPACE}TestProcess ${KWSYS_TARGET_C_LINK})
|
target_link_libraries(${KWSYS_NAMESPACE}TestProcess ${KWSYS_TARGET_C_LINK})
|
||||||
#set(KWSYS_TEST_PROCESS_7 7) # uncomment to run timing-sensitive test locally
|
#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)
|
foreach(n IN ITEMS 1 2 3 4 5 6 ${KWSYS_TEST_PROCESS_7} 9 10)
|
||||||
add_test(kwsys.testProcess-${n} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestProcess ${n})
|
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_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()
|
endforeach()
|
||||||
|
|
||||||
set(testProcess_COMPILE_FLAGS "")
|
set(testProcess_COMPILE_FLAGS "")
|
||||||
@@ -1121,9 +1127,9 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
|
|||||||
# Configure some test properties.
|
# Configure some test properties.
|
||||||
if(KWSYS_STANDALONE)
|
if(KWSYS_STANDALONE)
|
||||||
# We expect test to fail
|
# 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)
|
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}")
|
message(STATUS "GET_TEST_PROPERTY returned: ${wfv}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -1133,7 +1139,7 @@ if(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
|
|||||||
|
|
||||||
# Suppress known consistent failures on buggy systems.
|
# Suppress known consistent failures on buggy systems.
|
||||||
if(KWSYS_TEST_BOGUS_FAILURES)
|
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()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
@@ -3443,7 +3443,7 @@ bool SystemInformationImplementation::RetrieveInformationFromCpuInfoFile()
|
|||||||
|
|
||||||
FILE* fd = fopen("/proc/cpuinfo", "r");
|
FILE* fd = fopen("/proc/cpuinfo", "r");
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
std::cout << "Problem opening /proc/cpuinfo" << std::endl;
|
std::cerr << "Problem opening /proc/cpuinfo\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3454,7 +3454,7 @@ bool SystemInformationImplementation::RetrieveInformationFromCpuInfoFile()
|
|||||||
}
|
}
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
if (fileSize < 2) {
|
if (fileSize < 2) {
|
||||||
std::cout << "No data in /proc/cpuinfo" << std::endl;
|
std::cerr << "No data in /proc/cpuinfo\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
buffer.resize(fileSize - 2);
|
buffer.resize(fileSize - 2);
|
||||||
@@ -4162,7 +4162,7 @@ bool SystemInformationImplementation::QueryLinuxMemory()
|
|||||||
struct utsname unameInfo;
|
struct utsname unameInfo;
|
||||||
int errorFlag = uname(&unameInfo);
|
int errorFlag = uname(&unameInfo);
|
||||||
if (errorFlag != 0) {
|
if (errorFlag != 0) {
|
||||||
std::cout << "Problem calling uname(): " << strerror(errno) << std::endl;
|
std::cerr << "Problem calling uname(): " << strerror(errno) << "\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4182,7 +4182,7 @@ bool SystemInformationImplementation::QueryLinuxMemory()
|
|||||||
|
|
||||||
FILE* fd = fopen("/proc/meminfo", "r");
|
FILE* fd = fopen("/proc/meminfo", "r");
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
std::cout << "Problem opening /proc/meminfo" << std::endl;
|
std::cerr << "Problem opening /proc/meminfo\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4221,7 +4221,7 @@ bool SystemInformationImplementation::QueryLinuxMemory()
|
|||||||
this->TotalVirtualMemory = value[mSwapTotal] / 1024;
|
this->TotalVirtualMemory = value[mSwapTotal] / 1024;
|
||||||
this->AvailableVirtualMemory = value[mSwapFree] / 1024;
|
this->AvailableVirtualMemory = value[mSwapFree] / 1024;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Problem parsing /proc/meminfo" << std::endl;
|
std::cerr << "Problem parsing /proc/meminfo\n";
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -4248,7 +4248,7 @@ bool SystemInformationImplementation::QueryLinuxMemory()
|
|||||||
this->AvailablePhysicalMemory =
|
this->AvailablePhysicalMemory =
|
||||||
(ap + buffersMem + cachedMem) >> 10 >> 10;
|
(ap + buffersMem + cachedMem) >> 10 >> 10;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Problem parsing /proc/meminfo" << std::endl;
|
std::cerr << "Problem parsing /proc/meminfo\n";
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -4472,8 +4472,8 @@ void SystemInformationImplementation::CPUCountWindows()
|
|||||||
typedef BOOL(WINAPI * GetLogicalProcessorInformationType)(
|
typedef BOOL(WINAPI * GetLogicalProcessorInformationType)(
|
||||||
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD);
|
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD);
|
||||||
static GetLogicalProcessorInformationType pGetLogicalProcessorInformation =
|
static GetLogicalProcessorInformationType pGetLogicalProcessorInformation =
|
||||||
(GetLogicalProcessorInformationType)GetProcAddress(
|
reinterpret_cast<GetLogicalProcessorInformationType>(GetProcAddress(
|
||||||
GetModuleHandleW(L"kernel32"), "GetLogicalProcessorInformation");
|
GetModuleHandleW(L"kernel32"), "GetLogicalProcessorInformation"));
|
||||||
|
|
||||||
if (!pGetLogicalProcessorInformation) {
|
if (!pGetLogicalProcessorInformation) {
|
||||||
// Fallback to approximate implementation on ancient Windows versions.
|
// Fallback to approximate implementation on ancient Windows versions.
|
||||||
|
Reference in New Issue
Block a user