2017-06-19 22:15:19 +08:00
|
|
|
# Distributed under the OSI-approved BSD 3-Clause License. See https://cmake.org/licensing for details.
|
2016-02-29 10:43:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
# Do not include this module directly from code outside CMake!
|
|
|
|
set(_JAVA_HOME "")
|
|
|
|
if(JAVA_HOME AND IS_DIRECTORY "${JAVA_HOME}")
|
|
|
|
set(_JAVA_HOME "${JAVA_HOME}")
|
|
|
|
set(_JAVA_HOME_EXPLICIT 1)
|
2017-06-19 22:15:19 +08:00
|
|
|
else()
|
2016-02-29 10:43:00 +08:00
|
|
|
set(_ENV_JAVA_HOME "")
|
|
|
|
if(DEFINED ENV{JAVA_HOME})
|
|
|
|
file(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _ENV_JAVA_HOME)
|
2017-06-19 22:15:19 +08:00
|
|
|
endif()
|
2016-02-29 10:43:00 +08:00
|
|
|
if(_ENV_JAVA_HOME AND IS_DIRECTORY "${_ENV_JAVA_HOME}")
|
|
|
|
set(_JAVA_HOME "${_ENV_JAVA_HOME}")
|
|
|
|
set(_JAVA_HOME_EXPLICIT 1)
|
2017-06-19 22:15:19 +08:00
|
|
|
else()
|
2016-02-29 10:43:00 +08:00
|
|
|
set(_CMD_JAVA_HOME "")
|
2019-08-30 03:43:35 +08:00
|
|
|
if(APPLE AND EXISTS "/usr/libexec/java_home")
|
2016-02-29 10:43:00 +08:00
|
|
|
execute_process(COMMAND /usr/libexec/java_home
|
|
|
|
OUTPUT_VARIABLE _CMD_JAVA_HOME OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2017-06-19 22:15:19 +08:00
|
|
|
endif()
|
2016-02-29 10:43:00 +08:00
|
|
|
if(_CMD_JAVA_HOME AND IS_DIRECTORY "${_CMD_JAVA_HOME}")
|
|
|
|
set(_JAVA_HOME "${_CMD_JAVA_HOME}")
|
|
|
|
set(_JAVA_HOME_EXPLICIT 0)
|
2017-06-19 22:15:19 +08:00
|
|
|
endif()
|
2016-02-29 10:43:00 +08:00
|
|
|
unset(_CMD_JAVA_HOME)
|
2017-06-19 22:15:19 +08:00
|
|
|
endif()
|
2016-02-29 10:43:00 +08:00
|
|
|
unset(_ENV_JAVA_HOME)
|
2017-06-19 22:15:19 +08:00
|
|
|
endif()
|