From 94c6295db1c7ae759b466d4fb06f25b889ac888b Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 22 Oct 2020 10:20:08 -0400 Subject: Help: Document site_name command use of HOSTNAME variable --- Help/command/site_name.rst | 4 ++++ 1 file changed, 4 insertions(+) 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. -- cgit v0.12 From 3f3762856fbe56a244ad45995e37b3318e80b119 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 22 Oct 2020 10:12:51 -0400 Subject: Tests: Add case verifying CTest module SITE variable --- Tests/RunCMake/CTest/RunCMakeTest.cmake | 1 + Tests/RunCMake/CTest/Site.cmake | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 Tests/RunCMake/CTest/Site.cmake 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() -- cgit v0.12 From 11d21c1c4e7028570e78c134b36187dbf03aaa4e Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 22 Oct 2020 10:20:45 -0400 Subject: CTest: Avoid invoking external tool to get the host name Populate the SITE cache entry using an internal query instead. --- Modules/CTest.cmake | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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}") -- cgit v0.12