summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeFindJavaCommon.cmake
diff options
context:
space:
mode:
authorSeth R Johnson <johnsonsr@ornl.gov>2022-05-26 11:09:53 (GMT)
committerSeth R Johnson <johnsonsr@ornl.gov>2022-05-31 11:34:49 (GMT)
commit3acbe073baa2f884073f5d864a17a642d8f24715 (patch)
tree8be5a7c06524a8d74980f07cfb41d6c2a20869a8 /Modules/CMakeFindJavaCommon.cmake
parent35d975fe4a5726ab901742f30ef53a6551adef43 (diff)
downloadCMake-3acbe073baa2f884073f5d864a17a642d8f24715.zip
CMake-3acbe073baa2f884073f5d864a17a642d8f24715.tar.gz
CMake-3acbe073baa2f884073f5d864a17a642d8f24715.tar.bz2
FindJava: improve failure/verbosity when 'java -version' fails
On macOS monterey, `java -version` returns ``` The operation couldn’t be completed. Unable to locate a Java Runtime. Please visit http://www.java.com for information on installing Java. ``` which does not match the existing regex. Instead of hitting a fatal error if required, reset the variable and let FindPackage handle the result. If `QUIET` is requested, don't print anything if the version query fails. Otherwise, print the message. Additionally, clean up temporary variables set by the execute_process commands.
Diffstat (limited to 'Modules/CMakeFindJavaCommon.cmake')
-rw-r--r--Modules/CMakeFindJavaCommon.cmake5
1 files changed, 4 insertions, 1 deletions
diff --git a/Modules/CMakeFindJavaCommon.cmake b/Modules/CMakeFindJavaCommon.cmake
index 46b6280..c6e3348 100644
--- a/Modules/CMakeFindJavaCommon.cmake
+++ b/Modules/CMakeFindJavaCommon.cmake
@@ -19,7 +19,10 @@ else()
set(_CMD_JAVA_HOME "")
if(APPLE AND EXISTS /usr/libexec/java_home)
execute_process(COMMAND /usr/libexec/java_home
- OUTPUT_VARIABLE _CMD_JAVA_HOME OUTPUT_STRIP_TRAILING_WHITESPACE)
+ OUTPUT_VARIABLE _CMD_JAVA_HOME
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET
+ )
endif()
if(_CMD_JAVA_HOME AND IS_DIRECTORY "${_CMD_JAVA_HOME}")
set(_JAVA_HOME "${_CMD_JAVA_HOME}")