$OpenBSD: patch-Modules_FindJava_cmake,v 1.10 2012/12/05 11:32:04 dcoppa Exp $ --- Modules/FindJava.cmake.orig Tue Nov 27 14:26:32 2012 +++ Modules/FindJava.cmake Wed Dec 5 10:19:25 2012 @@ -56,6 +56,8 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +set(MODJAVA_VER $ENV{MODJAVA_VER}) + # The HINTS option should only be used for values computed from the system. set(_JAVA_HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\2.0;JavaHome]/bin" @@ -70,17 +72,32 @@ set(_JAVA_HINTS ) # Hard-coded guesses should still go in PATHS. This ensures that the user # environment can always override hard guesses. -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 - ) +if(MODJAVA_VER) + if(MODJAVA_VER MATCHES "^1\\.6$") + set(_JAVA_PATHS ${LOCALBASE}/jdk-1.6.0/bin) + elseif(MODJAVA_VER MATCHES "^1\\.6\\+$") + set(_JAVA_PATHS + ${LOCALBASE}/jdk-1.7.0/bin + ${LOCALBASE}/jdk-1.6.0/bin + ) + else(MODJAVA_VER MATCHES "^1\\.6$") + set(_JAVA_PATHS ${LOCALBASE}/jdk-1.7.0/bin) + endif(MODJAVA_VER MATCHES "^1\\.6$") +else(MODJAVA_VER) + 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 + ${LOCALBASE}/jdk-1.7.0/bin + ${LOCALBASE}/jdk-1.6.0/bin + ) +endif(MODJAVA_VER) find_program(Java_JAVA_EXECUTABLE NAMES java HINTS ${_JAVA_HINTS} @@ -107,6 +124,7 @@ if(Java_JAVA_EXECUTABLE) # 2. OpenJDK 1.6 # 3. GCJ 1.5 # 4. Kaffe 1.4.2 + # 5. OpenJDK 1.7.x on OpenBSD if(var MATCHES "java version \"[0-9]+\\.[0-9]+\\.[0-9_.]+.*\".*") # This is most likely Sun / OpenJDK, or maybe GCJ-java compat layer string( REGEX REPLACE ".* version \"([0-9]+\\.[0-9]+\\.[0-9_.]+.*)\".*" @@ -114,6 +132,10 @@ if(Java_JAVA_EXECUTABLE) elseif(var MATCHES "java full version \"kaffe-[0-9]+\\.[0-9]+\\.[0-9_]+\".*") # Kaffe style string( REGEX REPLACE "java full version \"kaffe-([0-9]+\\.[0-9]+\\.[0-9_]+).*" + "\\1" Java_VERSION_STRING "${var}" ) + elseif(var MATCHES "openjdk version \"[0-9]+\\.[0-9]+\\.[0-9_]+\".*") + # OpenJDK ver 1.7.x on OpenBSD + string( REGEX REPLACE "openjdk version \"([0-9]+\\.[0-9]+\\.[0-9_]+).*" "\\1" Java_VERSION_STRING "${var}" ) else() if(NOT Java_FIND_QUIETLY)