summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-10-23 13:02:31 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-10-23 13:02:37 (GMT)
commitb91dd2c639ba095a3fca006c1e00f6f3aa33a995 (patch)
tree51868f4ffc1e1b1a0a042ec993cd519a1c0cac97
parenta541921c56bb7dcd0e248928a2d8a215e7643b1c (diff)
parent11d21c1c4e7028570e78c134b36187dbf03aaa4e (diff)
downloadCMake-b91dd2c639ba095a3fca006c1e00f6f3aa33a995.zip
CMake-b91dd2c639ba095a3fca006c1e00f6f3aa33a995.tar.gz
CMake-b91dd2c639ba095a3fca006c1e00f6f3aa33a995.tar.bz2
Merge topic 'ctest-hostname-cleanup'
11d21c1c4e CTest: Avoid invoking external tool to get the host name 3f3762856f Tests: Add case verifying CTest module SITE variable 94c6295db1 Help: Document site_name command use of HOSTNAME variable Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !5407
-rw-r--r--Help/command/site_name.rst4
-rw-r--r--Modules/CTest.cmake9
-rw-r--r--Tests/RunCMake/CTest/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/CTest/Site.cmake5
4 files changed, 18 insertions, 1 deletions
diff --git a/Help/command/site_name.rst b/Help/command/site_name.rst
index 1bcaead..09b5a9f 100644
--- a/Help/command/site_name.rst
+++ b/Help/command/site_name.rst
@@ -6,3 +6,7 @@ Set the given variable to the name of the computer.
.. code-block:: cmake
site_name(variable)
+
+On UNIX-like platforms, if the variable ``HOSTNAME`` is set, its value
+will be executed as a command expected to print out the host name,
+much like the ``hostname`` command-line tool.
diff --git a/Modules/CTest.cmake b/Modules/CTest.cmake
index 8109108..ca9fcf5 100644
--- a/Modules/CTest.cmake
+++ b/Modules/CTest.cmake
@@ -194,7 +194,14 @@ if(BUILD_TESTING)
"Extra command line flags to pass to the coverage tool")
# set the site name
- site_name(SITE)
+ if(COMMAND cmake_host_system_information)
+ cmake_host_system_information(RESULT _ctest_hostname QUERY HOSTNAME)
+ set(SITE "${_ctest_hostname}" CACHE STRING "Name of the computer/site where compile is being run")
+ unset(_ctest_hostname)
+ else()
+ # This code path is needed for CMake itself during bootstrap.
+ site_name(SITE)
+ endif()
# set the build name
if(NOT BUILDNAME)
set(DART_COMPILER "${CMAKE_CXX_COMPILER}")
diff --git a/Tests/RunCMake/CTest/RunCMakeTest.cmake b/Tests/RunCMake/CTest/RunCMakeTest.cmake
index ffc8f78..b81f319 100644
--- a/Tests/RunCMake/CTest/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CTest/RunCMakeTest.cmake
@@ -5,6 +5,7 @@ run_cmake(BeforeProject)
unset(RunCMake_TEST_OPTIONS)
run_cmake(NotOn)
+run_cmake(Site)
function(run_CMakeCTestArguments)
run_cmake_with_options(CMakeCTestArguments "-DCMAKE_CTEST_ARGUMENTS=--quiet\\;--output-log\\;output-log.txt")
diff --git a/Tests/RunCMake/CTest/Site.cmake b/Tests/RunCMake/CTest/Site.cmake
new file mode 100644
index 0000000..2c96f23
--- /dev/null
+++ b/Tests/RunCMake/CTest/Site.cmake
@@ -0,0 +1,5 @@
+include(CTest)
+get_property(site CACHE SITE PROPERTY VALUE)
+if(NOT "${site}" STREQUAL "${SITE}")
+ message(FATAL_ERROR "SITE is not a cache entry")
+endif()