Adding support for java 1.6.0-oem. Make sure to report failure when user ask for version but regex failed to parse version number

This commit is contained in:
Mathieu Malaterre 2009-11-04 05:17:46 -05:00
parent b1817590c1
commit b0960683b2
1 changed files with 6 additions and 5 deletions

View File

@ -60,6 +60,7 @@ FIND_PROGRAM(Java_JAVA_EXECUTABLE
) )
IF(Java_JAVA_EXECUTABLE) IF(Java_JAVA_EXECUTABLE)
set(_java_version_acceptable TRUE)
EXECUTE_PROCESS(COMMAND ${Java_JAVA_EXECUTABLE} -version EXECUTE_PROCESS(COMMAND ${Java_JAVA_EXECUTABLE} -version
RESULT_VARIABLE res RESULT_VARIABLE res
OUTPUT_VARIABLE var OUTPUT_VARIABLE var
@ -71,13 +72,13 @@ IF(Java_JAVA_EXECUTABLE)
ELSE() ELSE()
# extract major/minor version and patch level from "java -version" output # extract major/minor version and patch level from "java -version" output
# Tested on linux using # Tested on linux using
# 1. Sun # 1. Sun / Sun OEM
# 2. OpenJDK 1.6 # 2. OpenJDK 1.6
# 3. GCJ 1.5 # 3. GCJ 1.5
# 4. Kaffe 1.4.2 # 4. Kaffe 1.4.2
IF(var MATCHES "java version \"[0-9]+\\.[0-9]+\\.[0-9_]+\".*") IF(var MATCHES "java version \"[0-9]+\\.[0-9]+\\.[0-9_]+[oem-]*\".*")
# This is most likely Sun / OpenJDK, or maybe GCJ-java compat layer # This is most likely Sun / OpenJDK, or maybe GCJ-java compat layer
STRING( REGEX REPLACE ".* version \"([0-9]+\\.[0-9]+\\.[0-9_]+).*" STRING( REGEX REPLACE ".* version \"([0-9]+\\.[0-9]+\\.[0-9_]+)[oem-]*\".*"
"\\1" Java_VERSION_STRING "${var}" ) "\\1" Java_VERSION_STRING "${var}" )
ELSEIF(var MATCHES "java full version \"kaffe-[0-9]+\\.[0-9]+\\.[0-9_]+\".*") ELSEIF(var MATCHES "java full version \"kaffe-[0-9]+\\.[0-9]+\\.[0-9_]+\".*")
# Kaffe style # Kaffe style
@ -85,7 +86,8 @@ IF(Java_JAVA_EXECUTABLE)
"\\1" Java_VERSION_STRING "${var}" ) "\\1" Java_VERSION_STRING "${var}" )
ELSE() ELSE()
IF(NOT Java_FIND_QUIETLY) IF(NOT Java_FIND_QUIETLY)
message(STATUS "regex not supported: ${var}. Please report") message(WARNING "regex not supported: ${var}. Please report")
set(_java_version_acceptable FALSE)
ENDIF(NOT Java_FIND_QUIETLY) ENDIF(NOT Java_FIND_QUIETLY)
ENDIF() ENDIF()
STRING( REGEX REPLACE "([0-9]+).*" "\\1" Java_VERSION_MAJOR "${Java_VERSION_STRING}" ) STRING( REGEX REPLACE "([0-9]+).*" "\\1" Java_VERSION_MAJOR "${Java_VERSION_STRING}" )
@ -106,7 +108,6 @@ IF(Java_JAVA_EXECUTABLE)
ENDIF() ENDIF()
# check version if requested: # check version if requested:
set(_java_version_acceptable TRUE)
if( Java_FIND_VERSION ) if( Java_FIND_VERSION )
if("${Java_VERSION}" VERSION_LESS "${Java_FIND_VERSION}") if("${Java_VERSION}" VERSION_LESS "${Java_FIND_VERSION}")
set(_java_version_acceptable FALSE) set(_java_version_acceptable FALSE)