diff options
author | Marc Chevrier <marc.chevrier@sap.com> | 2018-04-25 13:00:12 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-04-25 13:18:53 (GMT) |
commit | 5482f485b8c3114d258c4cd1a379a6cd12921cb1 (patch) | |
tree | 426acb5e272f1d96f13e23e13817826113731fc8 /Modules/FindJNI.cmake | |
parent | fbe6cd1596bf280edd49aeb8f981f99d7cd8beb3 (diff) | |
download | CMake-5482f485b8c3114d258c4cd1a379a6cd12921cb1.zip CMake-5482f485b8c3114d258c4cd1a379a6cd12921cb1.tar.gz CMake-5482f485b8c3114d258c4cd1a379a6cd12921cb1.tar.bz2 |
FindJava, FindJNI, UseJava: update for version 10 support
* new version format
* new registry layout on Windows
Fixes: #17938
Diffstat (limited to 'Modules/FindJNI.cmake')
-rw-r--r-- | Modules/FindJNI.cmake | 60 |
1 files changed, 47 insertions, 13 deletions
diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index e31c19e..4a56a1c 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -120,14 +120,39 @@ if(_JAVA_HOME) ${_JAVA_HOME} ) endif() -get_filename_component(java_install_version - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME) -list(APPEND JAVA_AWT_LIBRARY_DIRECTORIES - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib" - ) +if (WIN32) + set (_JNI_HINTS) + execute_process(COMMAND REG QUERY HKLM\\SOFTWARE\\JavaSoft\\JDK /f "." /k + RESULT_VARIABLE _JNI_RESULT + OUTPUT_VARIABLE _JNI_VERSIONS + ERROR_QUIET) + if (NOT _JNI_RESULT) + string (REGEX MATCHALL "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\JavaSoft\\\\JDK\\\\[0-9\.]+" _JNI_VERSIONS "${_JNI_VERSIONS}") + foreach (_JNI_HINT IN LISTS _JNI_VERSIONS) + list(APPEND _JNI_HINTS "[${_JNI_HINT}\\MSI;INSTALLDIR]") + endforeach() + endif() + + foreach (_JNI_HINT IN LISTS _JNI_HINTS) + list(APPEND JAVA_AWT_LIBRARY_DIRECTORIES "${_JNI_HINT}/lib") + endforeach() + + get_filename_component(java_install_version + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME) + + list(APPEND JAVA_AWT_LIBRARY_DIRECTORIES + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.9;JavaHome]/lib" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.8;JavaHome]/lib" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.7;JavaHome]/lib" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.6;JavaHome]/lib" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.5;JavaHome]/lib" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib" + ) +endif() + JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES /usr/lib/jvm/java/lib /usr/lib/java/jre/lib/{libarch} @@ -179,11 +204,21 @@ set(JAVA_AWT_INCLUDE_DIRECTORIES) if(_JAVA_HOME) list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES ${_JAVA_HOME}/include) endif() -list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include" - "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include" -) +if (WIN32) + foreach (_JNI_HINT IN LISTS _JNI_HINTS) + list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES "${_JNI_HINT}/include") + endforeach() + list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.9;JavaHome]/include" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.8;JavaHome]/include" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.7;JavaHome]/include" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.6;JavaHome]/include" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.5;JavaHome]/include" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include" + ) +endif() JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_INCLUDE_DIRECTORIES /usr/lib/java/include @@ -330,4 +365,3 @@ set(JNI_INCLUDE_DIRS ${JAVA_INCLUDE_PATH2} ${JAVA_AWT_INCLUDE_PATH} ) - |