Commit dd72b19f authored by Brad King's avatar Brad King

Find{Java,JNI}: Use /usr/libexec/java_home on OS X

If no JAVA_HOME or ENV{JAVA_HOME} is set then try running this
tool to get the system default Java home.
Suggested-by: Larry Shaffer's avatarLarry Shaffer <larrys@dakotacarto.com>
parent 70560ee1
......@@ -25,6 +25,17 @@ else()
if(_ENV_JAVA_HOME AND IS_DIRECTORY "${_ENV_JAVA_HOME}")
set(_JAVA_HOME "${_ENV_JAVA_HOME}")
set(_JAVA_HOME_EXPLICIT 1)
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)
endif()
if(_CMD_JAVA_HOME AND IS_DIRECTORY "${_CMD_JAVA_HOME}")
set(_JAVA_HOME "${_CMD_JAVA_HOME}")
set(_JAVA_HOME_EXPLICIT 0)
endif()
unset(_CMD_JAVA_HOME)
endif()
unset(_ENV_JAVA_HOME)
endif()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment