diff options
author | Nils Gladitz <nilsgladitz@gmail.com> | 2013-06-15 05:38:23 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-06-19 12:46:37 (GMT) |
commit | bb71a3a0dfaba317c7a98b92301310e15f602c38 (patch) | |
tree | 0ae6f7bd8a4dfe223333aeda53ecdb49e5e3dc10 /Tests/CMakeTests | |
parent | dea8271840b69bef078d7af324a72636ff195c94 (diff) | |
download | CMake-bb71a3a0dfaba317c7a98b92301310e15f602c38.zip CMake-bb71a3a0dfaba317c7a98b92301310e15f602c38.tar.gz CMake-bb71a3a0dfaba317c7a98b92301310e15f602c38.tar.bz2 |
Add cmake_host_system_information command
Expose the internal system information API to the CMake language. For
example, it is useful to see how much memory the system has available to
estimate an upper limit of tests that can run in parallel.
Diffstat (limited to 'Tests/CMakeTests')
6 files changed, 42 insertions, 0 deletions
diff --git a/Tests/CMakeTests/CMakeHostSystemInformation-BadArg1.cmake b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg1.cmake new file mode 100644 index 0000000..1655eb4 --- /dev/null +++ b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg1.cmake @@ -0,0 +1 @@ +cmake_host_system_information(HOSTNAME) diff --git a/Tests/CMakeTests/CMakeHostSystemInformation-BadArg2.cmake b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg2.cmake new file mode 100644 index 0000000..1f056d5 --- /dev/null +++ b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg2.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT FQDN HOSTNAME) diff --git a/Tests/CMakeTests/CMakeHostSystemInformation-BadArg3.cmake b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg3.cmake new file mode 100644 index 0000000..9c5a558 --- /dev/null +++ b/Tests/CMakeTests/CMakeHostSystemInformation-BadArg3.cmake @@ -0,0 +1 @@ +cmake_host_system_information(RESULT RESULT QUERY FOOBAR) diff --git a/Tests/CMakeTests/CMakeHostSystemInformation-QueryList.cmake b/Tests/CMakeTests/CMakeHostSystemInformation-QueryList.cmake new file mode 100644 index 0000000..1c3156d --- /dev/null +++ b/Tests/CMakeTests/CMakeHostSystemInformation-QueryList.cmake @@ -0,0 +1,5 @@ +cmake_host_system_information(RESULT RESULT + QUERY NUMBER_OF_LOGICAL_CORES NUMBER_OF_PHYSICAL_CORES +) + +message("[${RESULT}]") diff --git a/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in b/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in new file mode 100644 index 0000000..3294a2f --- /dev/null +++ b/Tests/CMakeTests/CMakeHostSystemInformationTest.cmake.in @@ -0,0 +1,33 @@ +set(BadArg1-RESULT 1) +set(BadArg1-STDERR "missing RESULT specification") +set(BadArg2-RESULT 1) +set(BadArg2-STDERR "missing QUERY specification") +set(BadArg3-RESULT 1) +set(BadArg3-STDERR "does not recognize <key> FOOBAR") +set(QueryList-RESULT 0) +set(QueryList-STDERR "\\[[0-9]+;[0-9]+\\]") + +function(try_and_print key) + cmake_host_system_information(RESULT RESULT QUERY ${key}) + message(STATUS "[${key}] [${RESULT}]") +endfunction() + +message("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") + +try_and_print(NUMBER_OF_LOGICAL_CORES) +try_and_print(NUMBER_OF_PHYSICAL_CORES) +try_and_print(HOSTNAME) +try_and_print(FQDN) +try_and_print(TOTAL_VIRTUAL_MEMORY) +try_and_print(AVAILABLE_VIRTUAL_MEMORY) +try_and_print(TOTAL_PHYSICAL_MEMORY) +try_and_print(AVAILABLE_PHYSICAL_MEMORY) + +include("@CMAKE_CURRENT_SOURCE_DIR@/CheckCMakeTest.cmake") + +check_cmake_test(CMakeHostSystemInformation + BadArg1 + BadArg2 + BadArg3 + QueryList +) diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt index b049995..344b772 100644 --- a/Tests/CMakeTests/CMakeLists.txt +++ b/Tests/CMakeTests/CMakeLists.txt @@ -32,6 +32,7 @@ AddCMakeTest(CompilerIdVendor "") AddCMakeTest(ProcessorCount "-DKWSYS_TEST_EXE=$<TARGET_FILE:cmsysTestsCxx>") AddCMakeTest(PushCheckState "") AddCMakeTest(While "") +AddCMakeTest(CMakeHostSystemInformation "") AddCMakeTest(FileDownload "") set_property(TEST CMake.FileDownload PROPERTY |