diff options
author | Marc Chevrier <marc.chevrier@sap.com> | 2018-04-27 11:38:32 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-04-27 12:52:22 (GMT) |
commit | 1013560a6a7c34d7f268eacf12ffdb4874a70c8b (patch) | |
tree | 9b98585a83fd7ea80e6a67c90037338f1137d46f /Modules/FindJNI.cmake | |
parent | 5482f485b8c3114d258c4cd1a379a6cd12921cb1 (diff) | |
download | CMake-1013560a6a7c34d7f268eacf12ffdb4874a70c8b.zip CMake-1013560a6a7c34d7f268eacf12ffdb4874a70c8b.tar.gz CMake-1013560a6a7c34d7f268eacf12ffdb4874a70c8b.tar.bz2 |
FindJava, FindJNI: Ensure most recent version is searched first
Diffstat (limited to 'Modules/FindJNI.cmake')
-rw-r--r-- | Modules/FindJNI.cmake | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index 4a56a1c..ff8d353 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -129,9 +129,21 @@ if (WIN32) 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() + if (_JNI_VERSIONS) + # sort versions. Most recent first + ## handle version 9 apart from other versions to get correct ordering + set (_JNI_V9 ${_JNI_VERSIONS}) + list (FILTER _JNI_VERSIONS EXCLUDE REGEX "JDK\\\\9") + list (SORT _JNI_VERSIONS) + list (REVERSE _JNI_VERSIONS) + list (FILTER _JNI_V9 INCLUDE REGEX "JDK\\\\9") + list (SORT _JNI_V9) + list (REVERSE _JNI_V9) + list (APPEND _JNI_VERSIONS ${_JNI_V9}) + foreach (_JNI_HINT IN LISTS _JNI_VERSIONS) + list(APPEND _JNI_HINTS "[${_JNI_HINT}\\MSI;INSTALLDIR]") + endforeach() + endif() endif() foreach (_JNI_HINT IN LISTS _JNI_HINTS) |