jni: set JAVA_HOME only if not defined
@@ -3,12 +3,14 @@ include (LibAddBinding)
include (SafeCheckSymbolExists)
if (DEPENDENCY_PHASE)
- if (APPLE)
+ set (JAVA_HOME $ENV{JAVA_HOME})
+ if (APPLE AND NOT DEFINED ${JAVA_HOME})
execute_process (
COMMAND "/usr/libexec/java_home --failfast"
ERROR_QUIET
OUTPUT_VARIABLE JAVA_HOME
OUTPUT_STRIP_TRAILING_WHITESPACE)
+ set (ENV{JAVA_HOME} ${JAVA_HOME})
endif ()
find_package (JNI QUIET)
