|
| 1 | + |
| 2 | +#============================================================================= |
| 3 | +# Copyright 2013-2014 Kitware, Inc. |
| 4 | +# |
| 5 | +# Distributed under the OSI-approved BSD License (the "License"); |
| 6 | +# see accompanying file Copyright.txt for details. |
| 7 | +# |
| 8 | +# This software is distributed WITHOUT ANY WARRANTY; without even the |
| 9 | +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 10 | +# See the License for more information. |
| 11 | +#============================================================================= |
| 12 | +# (To distribute this file outside of CMake, substitute the full |
| 13 | +# License text for the above reference.) |
| 14 | + |
| 15 | +# Do not include this module directly from code outside CMake! |
| 16 | +set(_JAVA_HOME "") |
| 17 | +if(JAVA_HOME AND IS_DIRECTORY "${JAVA_HOME}") |
| 18 | + set(_JAVA_HOME "${JAVA_HOME}") |
| 19 | + set(_JAVA_HOME_EXPLICIT 1) |
| 20 | +else() |
| 21 | + set(_ENV_JAVA_HOME "") |
| 22 | + if(DEFINED ENV{JAVA_HOME}) |
| 23 | + file(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _ENV_JAVA_HOME) |
| 24 | + endif() |
| 25 | + if(_ENV_JAVA_HOME AND IS_DIRECTORY "${_ENV_JAVA_HOME}") |
| 26 | + set(_JAVA_HOME "${_ENV_JAVA_HOME}") |
| 27 | + set(_JAVA_HOME_EXPLICIT 1) |
| 28 | + else() |
| 29 | + set(_CMD_JAVA_HOME "") |
| 30 | + if(APPLE AND EXISTS /usr/libexec/java_home) |
| 31 | + execute_process(COMMAND /usr/libexec/java_home |
| 32 | + OUTPUT_VARIABLE _CMD_JAVA_HOME OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 33 | + endif() |
| 34 | + if(_CMD_JAVA_HOME AND IS_DIRECTORY "${_CMD_JAVA_HOME}") |
| 35 | + set(_JAVA_HOME "${_CMD_JAVA_HOME}") |
| 36 | + set(_JAVA_HOME_EXPLICIT 0) |
| 37 | + endif() |
| 38 | + unset(_CMD_JAVA_HOME) |
| 39 | + endif() |
| 40 | + unset(_ENV_JAVA_HOME) |
| 41 | +endif() |
0 commit comments