123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindJavaCommon.cmake)
- set(_JAVA_HINTS)
- if(_JAVA_HOME)
- list(APPEND _JAVA_HINTS ${_JAVA_HOME}/bin)
- endif()
- list(APPEND _JAVA_HINTS
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\2.0;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.9;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.8;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.7;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.6;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.5;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\2.0;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.9;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.8;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.7;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.6;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.5;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.4;JavaHome]/bin"
- "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.3;JavaHome]/bin"
- )
- set(_JAVA_PATHS
- /usr/lib/java/bin
- /usr/share/java/bin
- /usr/local/java/bin
- /usr/local/java/share/bin
- /usr/java/j2sdk1.4.2_04
- /usr/lib/j2sdk1.4-sun/bin
- /usr/java/j2sdk1.4.2_09/bin
- /usr/lib/j2sdk1.5-sun/bin
- /opt/sun-jdk-1.5.0.04/bin
- /usr/local/jdk-1.7.0/bin
- /usr/local/jdk-1.6.0/bin
- )
- find_program(Java_JAVA_EXECUTABLE
- NAMES java
- HINTS ${_JAVA_HINTS}
- PATHS ${_JAVA_PATHS}
- )
- if(Java_JAVA_EXECUTABLE)
- execute_process(COMMAND ${Java_JAVA_EXECUTABLE} -version
- RESULT_VARIABLE res
- OUTPUT_VARIABLE var
- ERROR_VARIABLE var
- OUTPUT_STRIP_TRAILING_WHITESPACE
- ERROR_STRIP_TRAILING_WHITESPACE)
- if( res )
- if(var MATCHES "No Java runtime present, requesting install")
- set_property(CACHE Java_JAVA_EXECUTABLE
- PROPERTY VALUE "Java_JAVA_EXECUTABLE-NOTFOUND")
- elseif(${Java_FIND_REQUIRED})
- message( FATAL_ERROR "Error executing java -version" )
- else()
- message( STATUS "Warning, could not run java -version")
- endif()
- else()
-
- set(_java_version_regex [[(([0-9]+)(\.([0-9]+)(\.([0-9]+)(_([0-9]+))?)?)?.*)]])
- if(var MATCHES "java version \"${_java_version_regex}\"")
-
- set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
- set(Java_VERSION_MAJOR "${CMAKE_MATCH_2}")
- set(Java_VERSION_MINOR "${CMAKE_MATCH_4}")
- set(Java_VERSION_PATCH "${CMAKE_MATCH_6}")
- set(Java_VERSION_TWEAK "${CMAKE_MATCH_8}")
- elseif(var MATCHES "openjdk version \"${_java_version_regex}\"")
-
- set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
- set(Java_VERSION_MAJOR "${CMAKE_MATCH_2}")
- set(Java_VERSION_MINOR "${CMAKE_MATCH_4}")
- set(Java_VERSION_PATCH "${CMAKE_MATCH_6}")
- set(Java_VERSION_TWEAK "${CMAKE_MATCH_8}")
- elseif(var MATCHES "openjdk version \"([0-9]+)-[A-Za-z]+\"")
-
- set(Java_VERSION_STRING "1.${CMAKE_MATCH_1}.0")
- set(Java_VERSION_MAJOR "1")
- set(Java_VERSION_MINOR "${CMAKE_MATCH_1}")
- set(Java_VERSION_PATCH "0")
- set(Java_VERSION_TWEAK "")
- elseif(var MATCHES "java full version \"kaffe-${_java_version_regex}\"")
-
- set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
- set(Java_VERSION_MAJOR "${CMAKE_MATCH_2}")
- set(Java_VERSION_MINOR "${CMAKE_MATCH_4}")
- set(Java_VERSION_PATCH "${CMAKE_MATCH_6}")
- set(Java_VERSION_TWEAK "${CMAKE_MATCH_8}")
- else()
- if(NOT Java_FIND_QUIETLY)
- string(REPLACE "\n" "\n " ver_msg "\n${var}")
- message(WARNING "Java version not recognized:${ver_msg}\nPlease report.")
- endif()
- set(Java_VERSION_STRING "")
- set(Java_VERSION_MAJOR "")
- set(Java_VERSION_MINOR "")
- set(Java_VERSION_PATCH "")
- set(Java_VERSION_TWEAK "")
- endif()
- set(Java_VERSION "${Java_VERSION_MAJOR}")
- if(NOT "x${Java_VERSION}" STREQUAL "x")
- foreach(c MINOR PATCH TWEAK)
- if(NOT "x${Java_VERSION_${c}}" STREQUAL "x")
- string(APPEND Java_VERSION ".${Java_VERSION_${c}}")
- else()
- break()
- endif()
- endforeach()
- endif()
- endif()
- endif()
- find_program(Java_JAR_EXECUTABLE
- NAMES jar
- HINTS ${_JAVA_HINTS}
- PATHS ${_JAVA_PATHS}
- )
- find_program(Java_JAVAC_EXECUTABLE
- NAMES javac
- HINTS ${_JAVA_HINTS}
- PATHS ${_JAVA_PATHS}
- )
- find_program(Java_JAVAH_EXECUTABLE
- NAMES javah
- HINTS ${_JAVA_HINTS}
- PATHS ${_JAVA_PATHS}
- )
- find_program(Java_JAVADOC_EXECUTABLE
- NAMES javadoc
- HINTS ${_JAVA_HINTS}
- PATHS ${_JAVA_PATHS}
- )
- find_program(Java_IDLJ_EXECUTABLE
- NAMES idlj
- HINTS ${_JAVA_HINTS}
- PATHS ${_JAVA_PATHS}
- )
- find_program(Java_JARSIGNER_EXECUTABLE
- NAMES jarsigner
- HINTS ${_JAVA_HINTS}
- PATHS ${_JAVA_PATHS}
- )
- include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
- if(Java_FIND_COMPONENTS)
- set(_JAVA_REQUIRED_VARS)
- foreach(component ${Java_FIND_COMPONENTS})
-
- If(component STREQUAL "Runtime")
- list(APPEND _JAVA_REQUIRED_VARS Java_JAVA_EXECUTABLE)
- if(Java_JAVA_EXECUTABLE)
- set(Java_Runtime_FOUND TRUE)
- endif()
- elseif(component STREQUAL "Development")
- list(APPEND _JAVA_REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAVAC_EXECUTABLE
- Java_JAVADOC_EXECUTABLE)
- if(Java_VERSION VERSION_LESS "1.10")
- list(APPEND _JAVA_REQUIRED_VARS Java_JAVAH_EXECUTABLE)
- if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE
- AND Java_JAVAH_EXECUTABLE AND Java_JAVADOC_EXECUTABLE)
- set(Java_Development_FOUND TRUE)
- endif()
- else()
- if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE
- AND Java_JAVADOC_EXECUTABLE)
- set(Java_Development_FOUND TRUE)
- endif()
- endif()
- elseif(component STREQUAL "IdlJ")
- list(APPEND _JAVA_REQUIRED_VARS Java_IDLJ_EXECUTABLE)
- if(Java_IDLJ_EXECUTABLE)
- set(Java_IdlJ_FOUND TRUE)
- endif()
- elseif(component STREQUAL "JarSigner")
- list(APPEND _JAVA_REQUIRED_VARS Java_JARSIGNER_EXECUTABLE)
- if(Java_JARSIGNER_EXECUTABLE)
- set(Java_JarSigner_FOUND TRUE)
- endif()
- else()
- message(FATAL_ERROR "Comp: ${component} is not handled")
- endif()
- endforeach()
- list (REMOVE_DUPLICATES _JAVA_REQUIRED_VARS)
- find_package_handle_standard_args(Java
- REQUIRED_VARS ${_JAVA_REQUIRED_VARS} HANDLE_COMPONENTS
- VERSION_VAR Java_VERSION
- )
- if(Java_FOUND)
- foreach(component ${Java_FIND_COMPONENTS})
- set(Java_${component}_FOUND TRUE)
- endforeach()
- endif()
- else()
-
- if(Java_VERSION VERSION_LESS "1.10")
- find_package_handle_standard_args(Java
- REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE
- Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE
- VERSION_VAR Java_VERSION_STRING
- )
- else()
- find_package_handle_standard_args(Java
- REQUIRED_VARS Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE Java_JAVAC_EXECUTABLE
- Java_JAVADOC_EXECUTABLE
- VERSION_VAR Java_VERSION_STRING
- )
- endif()
- endif()
- mark_as_advanced(
- Java_JAVA_EXECUTABLE
- Java_JAR_EXECUTABLE
- Java_JAVAC_EXECUTABLE
- Java_JAVAH_EXECUTABLE
- Java_JAVADOC_EXECUTABLE
- Java_IDLJ_EXECUTABLE
- Java_JARSIGNER_EXECUTABLE
- )
- set(JAVA_RUNTIME ${Java_JAVA_EXECUTABLE})
- set(JAVA_ARCHIVE ${Java_JAR_EXECUTABLE})
- set(JAVA_COMPILE ${Java_JAVAC_EXECUTABLE})
|