2016-09-27 19:01:08 +00:00
|
|
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
|
|
|
|
2018-10-22 14:31:08 +00:00
|
|
|
#[=======================================================================[.rst:
|
|
|
|
FindJava
|
|
|
|
--------
|
|
|
|
|
|
|
|
Find Java
|
|
|
|
|
|
|
|
This module finds if Java is installed and determines where the
|
|
|
|
include files and libraries are. The caller may set variable ``JAVA_HOME``
|
|
|
|
to specify a Java installation prefix explicitly.
|
|
|
|
|
|
|
|
See also the :module:`FindJNI` module to find Java Native Interface (JNI).
|
|
|
|
|
|
|
|
Specify one or more of the following components as you call this find module. See example below.
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
Runtime = Java Runtime Environment used to execute Java byte-compiled applications
|
|
|
|
Development = Development tools (java, javac, javah, jar and javadoc), includes Runtime component
|
|
|
|
IdlJ = Interface Description Language (IDL) to Java compiler
|
|
|
|
JarSigner = Signer and verifier tool for Java Archive (JAR) files
|
|
|
|
|
|
|
|
|
|
|
|
This module sets the following result variables:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
Java_JAVA_EXECUTABLE = the full path to the Java runtime
|
|
|
|
Java_JAVAC_EXECUTABLE = the full path to the Java compiler
|
|
|
|
Java_JAVAH_EXECUTABLE = the full path to the Java header generator
|
|
|
|
Java_JAVADOC_EXECUTABLE = the full path to the Java documentation generator
|
|
|
|
Java_IDLJ_EXECUTABLE = the full path to the Java idl compiler
|
|
|
|
Java_JAR_EXECUTABLE = the full path to the Java archiver
|
|
|
|
Java_JARSIGNER_EXECUTABLE = the full path to the Java jar signer
|
|
|
|
Java_VERSION_STRING = Version of java found, eg. 1.6.0_12
|
|
|
|
Java_VERSION_MAJOR = The major version of the package found.
|
|
|
|
Java_VERSION_MINOR = The minor version of the package found.
|
|
|
|
Java_VERSION_PATCH = The patch version of the package found.
|
|
|
|
Java_VERSION_TWEAK = The tweak version of the package found (after '_')
|
|
|
|
Java_VERSION = This is set to: $major[.$minor[.$patch[.$tweak]]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The minimum required version of Java can be specified using the
|
|
|
|
:command:`find_package` syntax, e.g.
|
|
|
|
|
|
|
|
.. code-block:: cmake
|
|
|
|
|
|
|
|
find_package(Java 1.8)
|
|
|
|
|
|
|
|
NOTE: ``${Java_VERSION}`` and ``${Java_VERSION_STRING}`` are not guaranteed to
|
|
|
|
be identical. For example some java version may return:
|
|
|
|
``Java_VERSION_STRING = 1.8.0_17`` and ``Java_VERSION = 1.8.0.17``
|
|
|
|
|
|
|
|
another example is the Java OEM, with: ``Java_VERSION_STRING = 1.8.0-oem``
|
|
|
|
and ``Java_VERSION = 1.8.0``
|
|
|
|
|
|
|
|
For these components the following variables are set:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
Java_FOUND - TRUE if all components are found.
|
|
|
|
Java_<component>_FOUND - TRUE if <component> is found.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example Usages:
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
find_package(Java)
|
|
|
|
find_package(Java 1.8 REQUIRED)
|
|
|
|
find_package(Java COMPONENTS Runtime)
|
|
|
|
find_package(Java COMPONENTS Development)
|
|
|
|
#]=======================================================================]
|
2009-09-28 15:45:50 +00:00
|
|
|
|
2014-01-29 18:47:51 +00:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindJavaCommon.cmake)
|
2014-01-29 18:28:43 +00:00
|
|
|
|
2009-11-02 16:37:16 +00:00
|
|
|
# The HINTS option should only be used for values computed from the system.
|
2014-01-29 18:28:43 +00:00
|
|
|
set(_JAVA_HINTS)
|
|
|
|
if(_JAVA_HOME)
|
|
|
|
list(APPEND _JAVA_HINTS ${_JAVA_HOME}/bin)
|
|
|
|
endif()
|
2018-04-25 13:00:12 +00:00
|
|
|
if (WIN32)
|
|
|
|
macro (_JAVA_GET_INSTALLED_VERSIONS _KIND)
|
2019-10-01 10:44:26 +00:00
|
|
|
execute_process(COMMAND REG QUERY HKLM\\SOFTWARE\\JavaSoft\\${_KIND}
|
2018-04-25 13:00:12 +00:00
|
|
|
RESULT_VARIABLE _JAVA_RESULT
|
|
|
|
OUTPUT_VARIABLE _JAVA_VERSIONS
|
|
|
|
ERROR_QUIET)
|
|
|
|
if (NOT _JAVA_RESULT)
|
2018-04-27 11:38:32 +00:00
|
|
|
string (REGEX MATCHALL "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\JavaSoft\\\\${_KIND}\\\\[0-9.]+" _JAVA_VERSIONS "${_JAVA_VERSIONS}")
|
|
|
|
if (_JAVA_VERSIONS)
|
|
|
|
# sort versions. Most recent first
|
|
|
|
## handle version 9 apart from other versions to get correct ordering
|
|
|
|
set (_JAVA_V9 ${_JAVA_VERSIONS})
|
|
|
|
list (FILTER _JAVA_VERSIONS EXCLUDE REGEX "${_KIND}\\\\9")
|
|
|
|
list (SORT _JAVA_VERSIONS)
|
|
|
|
list (REVERSE _JAVA_VERSIONS)
|
|
|
|
list (FILTER _JAVA_V9 INCLUDE REGEX "${_KIND}\\\\9")
|
|
|
|
list (SORT _JAVA_V9)
|
|
|
|
list (REVERSE _JAVA_V9)
|
|
|
|
list (APPEND _JAVA_VERSIONS ${_JAVA_V9})
|
|
|
|
foreach (_JAVA_HINT IN LISTS _JAVA_VERSIONS)
|
2018-05-05 13:45:57 +00:00
|
|
|
list(APPEND _JAVA_HINTS "[${_JAVA_HINT};JavaHome]/bin")
|
2018-04-27 11:38:32 +00:00
|
|
|
endforeach()
|
|
|
|
endif()
|
2018-04-25 13:00:12 +00:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# search for installed versions for version 9 and upper
|
|
|
|
_JAVA_GET_INSTALLED_VERSIONS("JDK")
|
|
|
|
_JAVA_GET_INSTALLED_VERSIONS("JRE")
|
|
|
|
|
|
|
|
list(APPEND _JAVA_HINTS
|
2009-11-02 16:37:16 +00:00
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.9;JavaHome]/bin"
|
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.8;JavaHome]/bin"
|
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.7;JavaHome]/bin"
|
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.6;JavaHome]/bin"
|
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.5;JavaHome]/bin"
|
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/bin"
|
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/bin"
|
2017-01-11 15:31:01 +00:00
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.9;JavaHome]/bin"
|
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.8;JavaHome]/bin"
|
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.7;JavaHome]/bin"
|
2017-07-24 10:11:24 +00:00
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.6;JavaHome]/bin"
|
2017-01-11 15:31:01 +00:00
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.5;JavaHome]/bin"
|
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.4;JavaHome]/bin"
|
|
|
|
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.3;JavaHome]/bin"
|
2009-11-02 16:37:16 +00:00
|
|
|
)
|
2018-04-25 13:00:12 +00:00
|
|
|
endif()
|
|
|
|
|
2009-11-02 16:37:16 +00:00
|
|
|
# Hard-coded guesses should still go in PATHS. This ensures that the user
|
|
|
|
# environment can always override hard guesses.
|
2012-08-13 17:47:32 +00:00
|
|
|
set(_JAVA_PATHS
|
2002-11-14 14:38:45 +00:00
|
|
|
/usr/lib/java/bin
|
|
|
|
/usr/share/java/bin
|
|
|
|
/usr/local/java/bin
|
2006-10-12 17:12:37 +00:00
|
|
|
/usr/local/java/share/bin
|
2004-08-23 15:33:35 +00:00
|
|
|
/usr/java/j2sdk1.4.2_04
|
2005-02-10 03:46:33 +00:00
|
|
|
/usr/lib/j2sdk1.4-sun/bin
|
2005-08-26 21:02:10 +00:00
|
|
|
/usr/java/j2sdk1.4.2_09/bin
|
2005-09-08 14:03:51 +00:00
|
|
|
/usr/lib/j2sdk1.5-sun/bin
|
2005-09-23 18:38:51 +00:00
|
|
|
/opt/sun-jdk-1.5.0.04/bin
|
2012-12-03 23:23:10 +00:00
|
|
|
/usr/local/jdk-1.7.0/bin
|
|
|
|
/usr/local/jdk-1.6.0/bin
|
2002-11-14 14:38:45 +00:00
|
|
|
)
|
2012-08-13 17:47:32 +00:00
|
|
|
find_program(Java_JAVA_EXECUTABLE
|
2002-07-08 13:30:02 +00:00
|
|
|
NAMES java
|
2009-11-02 16:37:16 +00:00
|
|
|
HINTS ${_JAVA_HINTS}
|
|
|
|
PATHS ${_JAVA_PATHS}
|
2002-07-08 13:30:02 +00:00
|
|
|
)
|
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
if(Java_JAVA_EXECUTABLE)
|
2019-10-01 10:44:26 +00:00
|
|
|
execute_process(COMMAND "${Java_JAVA_EXECUTABLE}" -version
|
2009-10-30 08:05:59 +00:00
|
|
|
RESULT_VARIABLE res
|
|
|
|
OUTPUT_VARIABLE var
|
|
|
|
ERROR_VARIABLE var # sun-java output to stderr
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
ERROR_STRIP_TRAILING_WHITESPACE)
|
2012-08-13 17:47:32 +00:00
|
|
|
if( res )
|
2014-10-24 18:42:46 +00:00
|
|
|
if(var MATCHES "No Java runtime present, requesting install")
|
|
|
|
set_property(CACHE Java_JAVA_EXECUTABLE
|
|
|
|
PROPERTY VALUE "Java_JAVA_EXECUTABLE-NOTFOUND")
|
|
|
|
elseif(${Java_FIND_REQUIRED})
|
2012-08-13 17:47:32 +00:00
|
|
|
message( FATAL_ERROR "Error executing java -version" )
|
|
|
|
else()
|
2013-10-22 18:51:32 +00:00
|
|
|
message( STATUS "Warning, could not run java -version")
|
2012-08-13 17:47:32 +00:00
|
|
|
endif()
|
|
|
|
else()
|
2017-10-05 17:59:43 +00:00
|
|
|
# Extract version components (up to 4 levels) from "java -version" output.
|
|
|
|
set(_java_version_regex [[(([0-9]+)(\.([0-9]+)(\.([0-9]+)(_([0-9]+))?)?)?.*)]])
|
|
|
|
if(var MATCHES "java version \"${_java_version_regex}\"")
|
|
|
|
# Sun, GCJ, older OpenJDK
|
2014-04-06 19:30:00 +00:00
|
|
|
set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
|
2017-10-05 17:59:43 +00:00
|
|
|
set(Java_VERSION_MAJOR "${CMAKE_MATCH_2}")
|
2018-04-25 13:00:12 +00:00
|
|
|
if (CMAKE_MATCH_4)
|
2017-10-05 17:59:43 +00:00
|
|
|
set(Java_VERSION_MINOR "${CMAKE_MATCH_4}")
|
2018-04-25 13:00:12 +00:00
|
|
|
else()
|
|
|
|
set(Java_VERSION_MINOR 0)
|
|
|
|
endif()
|
|
|
|
if (CMAKE_MATCH_6)
|
2017-10-05 17:59:43 +00:00
|
|
|
set(Java_VERSION_PATCH "${CMAKE_MATCH_6}")
|
2018-04-25 13:00:12 +00:00
|
|
|
else()
|
|
|
|
set(Java_VERSION_PATCH 0)
|
|
|
|
endif()
|
2017-10-05 17:59:43 +00:00
|
|
|
set(Java_VERSION_TWEAK "${CMAKE_MATCH_8}")
|
|
|
|
elseif(var MATCHES "openjdk version \"${_java_version_regex}\"")
|
|
|
|
# OpenJDK
|
|
|
|
set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
|
|
|
|
set(Java_VERSION_MAJOR "${CMAKE_MATCH_2}")
|
2018-04-25 13:00:12 +00:00
|
|
|
if (CMAKE_MATCH_4)
|
2017-10-05 17:59:43 +00:00
|
|
|
set(Java_VERSION_MINOR "${CMAKE_MATCH_4}")
|
2018-04-25 13:00:12 +00:00
|
|
|
else()
|
|
|
|
set(Java_VERSION_MINOR 0)
|
|
|
|
endif()
|
|
|
|
if (CMAKE_MATCH_6)
|
2017-10-05 17:59:43 +00:00
|
|
|
set(Java_VERSION_PATCH "${CMAKE_MATCH_6}")
|
2018-04-25 13:00:12 +00:00
|
|
|
else()
|
|
|
|
set(Java_VERSION_PATCH 0)
|
|
|
|
endif()
|
2017-10-05 17:59:43 +00:00
|
|
|
set(Java_VERSION_TWEAK "${CMAKE_MATCH_8}")
|
2017-07-25 12:23:55 +00:00
|
|
|
elseif(var MATCHES "openjdk version \"([0-9]+)-[A-Za-z]+\"")
|
2017-05-03 21:40:08 +00:00
|
|
|
# OpenJDK 9 early access builds or locally built
|
|
|
|
set(Java_VERSION_STRING "1.${CMAKE_MATCH_1}.0")
|
2017-10-05 17:59:43 +00:00
|
|
|
set(Java_VERSION_MAJOR "1")
|
|
|
|
set(Java_VERSION_MINOR "${CMAKE_MATCH_1}")
|
|
|
|
set(Java_VERSION_PATCH "0")
|
|
|
|
set(Java_VERSION_TWEAK "")
|
|
|
|
elseif(var MATCHES "java full version \"kaffe-${_java_version_regex}\"")
|
2009-10-30 14:49:12 +00:00
|
|
|
# Kaffe style
|
2014-04-06 19:30:00 +00:00
|
|
|
set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
|
2017-10-05 17:59:43 +00:00
|
|
|
set(Java_VERSION_MAJOR "${CMAKE_MATCH_2}")
|
|
|
|
set(Java_VERSION_MINOR "${CMAKE_MATCH_4}")
|
|
|
|
set(Java_VERSION_PATCH "${CMAKE_MATCH_6}")
|
|
|
|
set(Java_VERSION_TWEAK "${CMAKE_MATCH_8}")
|
2012-08-13 17:47:32 +00:00
|
|
|
else()
|
|
|
|
if(NOT Java_FIND_QUIETLY)
|
2017-10-05 17:59:43 +00:00
|
|
|
string(REPLACE "\n" "\n " ver_msg "\n${var}")
|
|
|
|
message(WARNING "Java version not recognized:${ver_msg}\nPlease report.")
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
2017-10-05 17:59:43 +00:00
|
|
|
set(Java_VERSION_STRING "")
|
|
|
|
set(Java_VERSION_MAJOR "")
|
|
|
|
set(Java_VERSION_MINOR "")
|
|
|
|
set(Java_VERSION_PATCH "")
|
|
|
|
set(Java_VERSION_TWEAK "")
|
2012-08-13 17:47:32 +00:00
|
|
|
endif()
|
2017-10-05 17:59:43 +00:00
|
|
|
set(Java_VERSION "${Java_VERSION_MAJOR}")
|
|
|
|
if(NOT "x${Java_VERSION}" STREQUAL "x")
|
|
|
|
foreach(c MINOR PATCH TWEAK)
|
|
|
|
if(NOT "x${Java_VERSION_${c}}" STREQUAL "x")
|
|
|
|
string(APPEND Java_VERSION ".${Java_VERSION_${c}}")
|
|
|
|
else()
|
|
|
|
break()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
2012-08-13 17:47:32 +00:00
|
|
|
endif()
|
2009-10-30 08:05:59 +00:00
|
|
|
|
2012-08-13 17:50:14 +00:00
|
|
|
endif()
|
2009-10-30 08:05:59 +00:00
|
|
|
|
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
find_program(Java_JAR_EXECUTABLE
|
2002-07-08 13:30:02 +00:00
|
|
|
NAMES jar
|
2009-11-02 16:37:16 +00:00
|
|
|
HINTS ${_JAVA_HINTS}
|
|
|
|
PATHS ${_JAVA_PATHS}
|
2002-07-08 13:30:02 +00:00
|
|
|
)
|
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
find_program(Java_JAVAC_EXECUTABLE
|
2002-07-08 13:30:02 +00:00
|
|
|
NAMES javac
|
2009-11-02 16:37:16 +00:00
|
|
|
HINTS ${_JAVA_HINTS}
|
|
|
|
PATHS ${_JAVA_PATHS}
|
2002-07-08 13:30:02 +00:00
|
|
|
)
|
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
find_program(Java_JAVAH_EXECUTABLE
|
2011-02-10 20:09:29 +00:00
|
|
|
NAMES javah
|
|
|
|
HINTS ${_JAVA_HINTS}
|
|
|
|
PATHS ${_JAVA_PATHS}
|
|
|
|
)
|
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
find_program(Java_JAVADOC_EXECUTABLE
|
2011-02-10 20:09:29 +00:00
|
|
|
NAMES javadoc
|
|
|
|
HINTS ${_JAVA_HINTS}
|
|
|
|
PATHS ${_JAVA_PATHS}
|
|
|
|
)
|
|
|
|
|
2015-07-31 08:00:43 +00:00
|
|
|
find_program(Java_IDLJ_EXECUTABLE
|
|
|
|
NAMES idlj
|
|
|
|
HINTS ${_JAVA_HINTS}
|
|
|
|
PATHS ${_JAVA_PATHS}
|
|
|
|
)
|
|
|
|
|
|
|
|
find_program(Java_JARSIGNER_EXECUTABLE
|
|
|
|
NAMES jarsigner
|
|
|
|
HINTS ${_JAVA_HINTS}
|
|
|
|
PATHS ${_JAVA_PATHS}
|
|
|
|
)
|
|
|
|
|
Modules: Include builtin FindPackageHandleStandardArgs directly
The FindPackageHandleStandardArgs module was originally created outside
of CMake. It was added for CMake 2.6.0 by commit e118a627 (add a macro
FIND_PACKAGE_HANDLE_STANDARD_ARGS..., 2007-07-18). However, it also
proliferated into a number of other projects that at the time required
only CMake 2.4 and thus could not depend on CMake to provide the module.
CMake's own find modules started using the module in commit b5f656e0
(use the new FIND_PACKAGE_HANDLE_STANDARD_ARGS in some of the FindXXX
modules..., 2007-07-18).
Then commit d358cf5c (add 2nd, more powerful mode to
find_package_handle_standard_args, 2010-07-29) added a new feature to
the interface of the module that was fully optional and backward
compatible with all existing users of the module. Later commit 5f183caa
(FindZLIB: use the FPHSA version mode, 2010-08-04) and others shortly
thereafter started using the new interface in CMake's own find modules.
This change was also backward compatible because it was only an
implementation detail within each module.
Unforutnately these changes introduced a problem for projects that still
have an old copy of FindPackageHandleStandardArgs in CMAKE_MODULE_PATH.
When any such project uses one of CMake's builtin find modules the line
include(FindPackageHandleStandardArgs)
loads the copy from the project which does not have the new interface!
Then the including find module tries to use the new interface with the
old module and fails.
Whether this breakage can be considered a backward incompatible change
in CMake is debatable. The situation is analagous to copying a standard
library header from one version of a compiler into a project and then
observing problems when the next version of the compiler reports errors
in its other headers that depend on its new version of the original
header. Nevertheless it is a change to CMake that causes problems for
projects that worked with previous versions.
This problem was discovered during the 2.8.3 release candidate cycle.
It is an instance of a more general problem with projects that provide
their own versions of CMake modules when other CMake modules depend on
them. At the time we resolved this instance of the problem with commit
b0118402 (Use absolute path to FindPackageHandleStandardArgs.cmake
everywhere, 2010-09-28) for the 2.8.3 release.
In order to address the more general problem we introduced policy
CMP0017 in commit db44848f (Prefer files from CMAKE_ROOT when including
from CMAKE_ROOT, 2010-11-17). That change was followed by commit
ce28737c (Remove usage of CMAKE_CURRENT_LIST_DIR now that we have
CMP0017, 2010-12-20) which reverted the original workaround in favor of
using the policy. However, existing project releases do not set the
policy behavior to NEW and therefore still exhibit the problem.
We introduced in commit a364daf1 (Allow users to specify defaults for
unset policies, 2011-01-03) an option for users to build existing
projects by adding -DCMAKE_POLICY_DEFAULT_CMP0017=NEW to the command
line. Unfortunately this solution still does not allow such projects to
build out of the box, and there is no good way to suggest the use of the
new option.
The only remaining solution to keep existing projects that exhibit this
problem building is to restore the change originally made in commit
b0118402 (Use absolute path to FindPackageHandleStandardArgs.cmake
everywhere, 2010-09-28). This also avoids policy CMP0017 warnings for
this particular instance of the problem the policy addresses.
2011-01-20 15:56:49 +00:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
2010-05-09 12:41:15 +00:00
|
|
|
if(Java_FIND_COMPONENTS)
|
2015-07-31 08:00:43 +00:00
|
|
|
set(_JAVA_REQUIRED_VARS)
|
2010-05-09 12:41:15 +00:00
|
|
|
foreach(component ${Java_FIND_COMPONENTS})
|
|
|
|
# User just want to execute some Java byte-compiled
|
2015-07-31 08:00:43 +00:00
|
|
|
If(component STREQUAL "Runtime")
|
|
|
|
list(APPEND _JAVA_REQUIRED_VARS Java_JAVA_EXECUTABLE)
|
|
|
|
if(Java_JAVA_EXECUTABLE)
|
|
|
|
set(Java_Runtime_FOUND TRUE)
|
|
|
|
endif()
|
2010-05-09 12:41:15 +00:00
|
|
|
elseif(component STREQUAL "Development")
|
2015-07-31 08:00:43 +00:00
|
|
|
list(APPEND _JAVA_REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAVAC_EXECUTABLE
|
2018-02-27 14:11:49 +00:00
|
|
|
Java_JAR_EXECUTABLE Java_JAVADOC_EXECUTABLE)
|
2018-04-25 13:00:12 +00:00
|
|
|
if(Java_VERSION VERSION_LESS "10")
|
2018-01-08 12:45:37 +00:00
|
|
|
list(APPEND _JAVA_REQUIRED_VARS Java_JAVAH_EXECUTABLE)
|
|
|
|
if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE
|
2018-02-27 14:11:49 +00:00
|
|
|
AND Java_JAVAH_EXECUTABLE AND Java_JAR_EXECUTABLE AND Java_JAVADOC_EXECUTABLE)
|
2018-01-08 12:45:37 +00:00
|
|
|
set(Java_Development_FOUND TRUE)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE
|
2018-02-27 14:11:49 +00:00
|
|
|
AND Java_JAR_EXECUTABLE AND Java_JAVADOC_EXECUTABLE)
|
2018-01-08 12:45:37 +00:00
|
|
|
set(Java_Development_FOUND TRUE)
|
|
|
|
endif()
|
2015-07-31 08:00:43 +00:00
|
|
|
endif()
|
|
|
|
elseif(component STREQUAL "IdlJ")
|
|
|
|
list(APPEND _JAVA_REQUIRED_VARS Java_IDLJ_EXECUTABLE)
|
2015-12-03 11:34:51 +00:00
|
|
|
if(Java_IDLJ_EXECUTABLE)
|
|
|
|
set(Java_IdlJ_FOUND TRUE)
|
2015-07-31 08:00:43 +00:00
|
|
|
endif()
|
|
|
|
elseif(component STREQUAL "JarSigner")
|
|
|
|
list(APPEND _JAVA_REQUIRED_VARS Java_JARSIGNER_EXECUTABLE)
|
2015-12-03 11:34:51 +00:00
|
|
|
if(Java_JARSIGNER_EXECUTABLE)
|
2015-07-31 08:00:43 +00:00
|
|
|
set(Java_JarSigner_FOUND TRUE)
|
|
|
|
endif()
|
2010-05-09 12:41:15 +00:00
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Comp: ${component} is not handled")
|
|
|
|
endif()
|
2012-08-13 17:50:14 +00:00
|
|
|
endforeach()
|
2015-07-31 08:00:43 +00:00
|
|
|
list (REMOVE_DUPLICATES _JAVA_REQUIRED_VARS)
|
|
|
|
find_package_handle_standard_args(Java
|
|
|
|
REQUIRED_VARS ${_JAVA_REQUIRED_VARS} HANDLE_COMPONENTS
|
|
|
|
VERSION_VAR Java_VERSION
|
|
|
|
)
|
|
|
|
if(Java_FOUND)
|
|
|
|
foreach(component ${Java_FIND_COMPONENTS})
|
|
|
|
set(Java_${component}_FOUND TRUE)
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2010-05-09 12:41:15 +00:00
|
|
|
else()
|
2015-07-31 08:00:43 +00:00
|
|
|
# Check for Development
|
2018-04-25 13:00:12 +00:00
|
|
|
if(Java_VERSION VERSION_LESS "10")
|
2018-01-08 12:45:37 +00:00
|
|
|
find_package_handle_standard_args(Java
|
|
|
|
REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE
|
|
|
|
Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE
|
|
|
|
VERSION_VAR Java_VERSION_STRING
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
find_package_handle_standard_args(Java
|
|
|
|
REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE
|
|
|
|
Java_JAVADOC_EXECUTABLE
|
|
|
|
VERSION_VAR Java_VERSION_STRING
|
|
|
|
)
|
|
|
|
endif()
|
2010-05-09 12:41:15 +00:00
|
|
|
endif()
|
|
|
|
|
2009-10-30 08:05:59 +00:00
|
|
|
|
2012-08-13 17:47:32 +00:00
|
|
|
mark_as_advanced(
|
2009-11-02 14:15:04 +00:00
|
|
|
Java_JAVA_EXECUTABLE
|
|
|
|
Java_JAR_EXECUTABLE
|
|
|
|
Java_JAVAC_EXECUTABLE
|
2011-02-10 20:09:29 +00:00
|
|
|
Java_JAVAH_EXECUTABLE
|
|
|
|
Java_JAVADOC_EXECUTABLE
|
2015-07-31 08:00:43 +00:00
|
|
|
Java_IDLJ_EXECUTABLE
|
|
|
|
Java_JARSIGNER_EXECUTABLE
|
2009-11-02 14:15:04 +00:00
|
|
|
)
|
2009-10-30 08:05:59 +00:00
|
|
|
|
|
|
|
# LEGACY
|
2012-08-13 17:47:32 +00:00
|
|
|
set(JAVA_RUNTIME ${Java_JAVA_EXECUTABLE})
|
|
|
|
set(JAVA_ARCHIVE ${Java_JAR_EXECUTABLE})
|
|
|
|
set(JAVA_COMPILE ${Java_JAVAC_EXECUTABLE})
|