From e8051b1f20d90cbefd672d1ba108362f9c55c2db Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 8 Jul 2020 16:12:19 -0400 Subject: FindJava: Update check to avoid accepting macOS stub 'java' as Java Since commit dd378258f1 (FindJava: Do not accept OS X stub 'java' as Java, 2014-10-24, v3.1.0-rc3~29^2) we try to avoid using the macOS `/usr/bin/java` stub if no underlying implementation of Java is actually installed. However, the message that `/usr/bin/java` prints when there is no Java available has changed since then. Update our check to also look for the new message. While at it, revise the way we suppress `Java_JAVA_EXECUTABLE`. Previously we set its cache entry to `Java_JAVA_EXECUTABLE-NOTFOUND`, but that would cause the same find-and-reject sequence to be followed every time CMake runs in a build tree. Instead, use the approach from commit 2c0db404d1 (FindSubversion: Do not accept macOS stub without Xcode implementation, 2020-05-28, v3.18.0-rc1~67^2). Leave the cache entry alone and just set a normal variable of the same name to hide it. --- Modules/FindJava.cmake | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake index 945df3c..9db740b 100644 --- a/Modules/FindJava.cmake +++ b/Modules/FindJava.cmake @@ -160,9 +160,8 @@ if(Java_JAVA_EXECUTABLE) OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE) if( res ) - if(var MATCHES "No Java runtime present, requesting install") - set_property(CACHE Java_JAVA_EXECUTABLE - PROPERTY VALUE "Java_JAVA_EXECUTABLE-NOTFOUND") + if(var MATCHES "Unable to locate a Java Runtime to invoke|No Java runtime present, requesting install") + set(Java_JAVA_EXECUTABLE Java_JAVA_EXECUTABLE-NOTFOUND) elseif(${Java_FIND_REQUIRED}) message( FATAL_ERROR "Error executing java -version" ) else() -- cgit v0.12