summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-04-30 13:20:37 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-04-30 13:20:42 (GMT)
commit27279fa2db6fc7cce88d15b50ed2e736b208bb72 (patch)
tree1cee4f68fd983ff095cf6f307eec6915e52cf9b9 /Modules
parent36d7f8ca106b69fbd02a361a156a31d2be7aae22 (diff)
parent1013560a6a7c34d7f268eacf12ffdb4874a70c8b (diff)
downloadCMake-27279fa2db6fc7cce88d15b50ed2e736b208bb72.zip
CMake-27279fa2db6fc7cce88d15b50ed2e736b208bb72.tar.gz
CMake-27279fa2db6fc7cce88d15b50ed2e736b208bb72.tar.bz2
Merge topic 'java-new-packaging-version-sort'
1013560a6a FindJava, FindJNI: Ensure most recent version is searched first Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2016
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindJNI.cmake18
-rw-r--r--Modules/FindJava.cmake20
2 files changed, 31 insertions, 7 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)
diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake
index f8e3d98..95e551f 100644
--- a/Modules/FindJava.cmake
+++ b/Modules/FindJava.cmake
@@ -84,10 +84,22 @@ if (WIN32)
OUTPUT_VARIABLE _JAVA_VERSIONS
ERROR_QUIET)
if (NOT _JAVA_RESULT)
- string (REGEX MATCHALL "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\JavaSoft\\\\${_KIND}\\\\[0-9\.]+" _JAVA_VERSIONS "${_JAVA_VERSIONS}")
- foreach (_JAVA_HINT IN LISTS _JAVA_VERSIONS)
- list(APPEND _JAVA_HINTS "[${_JAVA_HINT}\\MSI;INSTALLDIR]/bin")
- endforeach()
+ 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)
+ list(APPEND _JAVA_HINTS "[${_JAVA_HINT}\\MSI;INSTALLDIR]/bin")
+ endforeach()
+ endif()
endif()
endmacro()