diff options
author | Brad King <brad.king@kitware.com> | 2014-01-29 18:51:32 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-01-29 19:12:54 (GMT) |
commit | dd72b19f861d6c39796fdf9950f585f0368348a9 (patch) | |
tree | 02e78d8c94f13c74ebc5c1e06837103f964f4aca /Modules/CMakeFindJavaCommon.cmake | |
parent | 70560ee1466ffc73878afa7ad34937bf154903f6 (diff) | |
download | CMake-dd72b19f861d6c39796fdf9950f585f0368348a9.zip CMake-dd72b19f861d6c39796fdf9950f585f0368348a9.tar.gz CMake-dd72b19f861d6c39796fdf9950f585f0368348a9.tar.bz2 |
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 <larrys@dakotacarto.com>
Diffstat (limited to 'Modules/CMakeFindJavaCommon.cmake')
-rw-r--r-- | Modules/CMakeFindJavaCommon.cmake | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Modules/CMakeFindJavaCommon.cmake b/Modules/CMakeFindJavaCommon.cmake index fd52689..fcf0389 100644 --- a/Modules/CMakeFindJavaCommon.cmake +++ b/Modules/CMakeFindJavaCommon.cmake @@ -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() |