Improved version checking for FindJava using the new FPHSA() mode
Alex
This commit is contained in:
parent
6bb0b6e915
commit
19b68b9fae
|
@ -13,6 +13,9 @@
|
||||||
# Java_VERSION_TWEAK = The tweak version of the package found (after '_')
|
# Java_VERSION_TWEAK = The tweak version of the package found (after '_')
|
||||||
# Java_VERSION = This is set to: $major.$minor.$patch(.$tweak)
|
# Java_VERSION = This is set to: $major.$minor.$patch(.$tweak)
|
||||||
#
|
#
|
||||||
|
# The minimum required version of Java can be specified using the
|
||||||
|
# standard CMake syntax, e.g. FIND_PACKAGE(Java 1.5)
|
||||||
|
#
|
||||||
# NOTE: ${Java_VERSION} and ${Java_VERSION_STRING} are not guaranteed to be
|
# NOTE: ${Java_VERSION} and ${Java_VERSION_STRING} are not guaranteed to be
|
||||||
# identical. For example some java version may return:
|
# identical. For example some java version may return:
|
||||||
# Java_VERSION_STRING = 1.5.0_17
|
# Java_VERSION_STRING = 1.5.0_17
|
||||||
|
@ -83,7 +86,6 @@ 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
|
||||||
|
@ -114,7 +116,6 @@ IF(Java_JAVA_EXECUTABLE)
|
||||||
ELSE()
|
ELSE()
|
||||||
IF(NOT Java_FIND_QUIETLY)
|
IF(NOT Java_FIND_QUIETLY)
|
||||||
message(WARNING "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}" )
|
||||||
|
@ -134,17 +135,6 @@ IF(Java_JAVA_EXECUTABLE)
|
||||||
ENDIF(NOT Java_FIND_QUIETLY)
|
ENDIF(NOT Java_FIND_QUIETLY)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# check version if requested:
|
|
||||||
if( Java_FIND_VERSION )
|
|
||||||
if("${Java_VERSION}" VERSION_LESS "${Java_FIND_VERSION}")
|
|
||||||
set(_java_version_acceptable FALSE)
|
|
||||||
endif("${Java_VERSION}" VERSION_LESS "${Java_FIND_VERSION}")
|
|
||||||
if( Java_FIND_VERSION_EXACT )
|
|
||||||
if("${Java_VERSION}" VERSION_GREATER "${Java_FIND_VERSION}")
|
|
||||||
set(_java_version_acceptable FALSE)
|
|
||||||
endif("${Java_VERSION}" VERSION_GREATER "${Java_FIND_VERSION}")
|
|
||||||
endif( Java_FIND_VERSION_EXACT )
|
|
||||||
endif( Java_FIND_VERSION )
|
|
||||||
ENDIF(Java_JAVA_EXECUTABLE)
|
ENDIF(Java_JAVA_EXECUTABLE)
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,16 +155,14 @@ if(Java_FIND_COMPONENTS)
|
||||||
foreach(component ${Java_FIND_COMPONENTS})
|
foreach(component ${Java_FIND_COMPONENTS})
|
||||||
# User just want to execute some Java byte-compiled
|
# User just want to execute some Java byte-compiled
|
||||||
if(component STREQUAL "Runtime")
|
if(component STREQUAL "Runtime")
|
||||||
find_package_handle_standard_args(Java DEFAULT_MSG
|
find_package_handle_standard_args(Java
|
||||||
Java_JAVA_EXECUTABLE
|
REQUIRED_VARS Java_JAVA_EXECUTABLE
|
||||||
_java_version_acceptable
|
VERSION_VAR Java_VERSION
|
||||||
)
|
)
|
||||||
elseif(component STREQUAL "Development")
|
elseif(component STREQUAL "Development")
|
||||||
find_package_handle_standard_args(Java DEFAULT_MSG
|
find_package_handle_standard_args(Java
|
||||||
Java_JAVA_EXECUTABLE
|
REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE
|
||||||
Java_JAR_EXECUTABLE
|
VERSION_VAR Java_VERSION
|
||||||
Java_JAVAC_EXECUTABLE
|
|
||||||
_java_version_acceptable
|
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Comp: ${component} is not handled")
|
message(FATAL_ERROR "Comp: ${component} is not handled")
|
||||||
|
@ -183,11 +171,9 @@ if(Java_FIND_COMPONENTS)
|
||||||
endforeach(component)
|
endforeach(component)
|
||||||
else()
|
else()
|
||||||
# Check for everything
|
# Check for everything
|
||||||
find_package_handle_standard_args(Java DEFAULT_MSG
|
find_package_handle_standard_args(Java
|
||||||
Java_JAVA_EXECUTABLE
|
REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE
|
||||||
Java_JAR_EXECUTABLE
|
VERSION_VAR Java_VERSION
|
||||||
Java_JAVAC_EXECUTABLE
|
|
||||||
_java_version_acceptable
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue