STYLE: Nightly Version update
[cmake.git] / Modules / FindJNI.cmake
blob9a9f3ead5ad07dcf6702b4bf38a24f944e5b2306
2 # This module finds if Java is installed and determines where the
3 # include files and libraries are. It also determines what the name of
4 # the library is. This code sets the following variables:
6 #  JAVA_AWT_LIB_PATH     = the path to where the jawt library is
7 #  JAVA_INCLUDE_PATH     = the path to where jni.h can be found
8 #  JAVA_AWT_INCLUDE_PATH = the path to where jni.h can be found
9
11 SET(JAVA_AWT_LIBRARY_DIRECTORIES
12   "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib"
13   "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib"
14   /usr/lib
15   /usr/local/lib
16   /usr/lib/java/jre/lib/i386
17   /usr/local/lib/java/jre/lib/i386
18   /usr/lib/j2sdk1.4-sun/jre/lib/i386
19   )
21 SET(JAVA_AWT_INCLUDE_DIRECTORIES
22   "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
23   "[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
24   /usr/include 
25   /usr/local/include
26   /usr/lib/java/include
27   /usr/local/lib/java/include
28   /usr/lib/j2sdk1.4-sun/include
29   )
31 FOREACH(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}")
32   GET_FILENAME_COMPONENT(jpath "${JAVA_PROG}" PATH)
33   FOREACH(JAVA_INC_PATH ../include ../java/include ../share/java/include)
34     IF(EXISTS ${jpath}/${JAVA_INC_PATH})
35       SET(JAVA_AWT_INCLUDE_DIRECTORIES ${JAVA_AWT_INCLUDE_DIRECTORIES} "${jpath}/${JAVA_INC_PATH}")
36     ENDIF(EXISTS ${jpath}/${JAVA_INC_PATH})
37   ENDFOREACH(JAVA_INC_PATH)
38   FOREACH(JAVA_LIB_PATH 
39     ../lib ../jre/lib ../jre/lib/i386 
40     ../java/lib ../java/jre/lib ../java/jre/lib/i386 
41     ../share/java/lib ../share/java/jre/lib ../share/java/jre/lib/i386)
42     IF(EXISTS ${jpath}/${JAVA_LIB_PATH})
43       SET(JAVA_AWT_LIBRARY_DIRECTORIES ${JAVA_AWT_LIBRARY_DIRECTORIES} "${jpath}/${JAVA_LIB_PATH}")
44     ENDIF(EXISTS ${jpath}/${JAVA_LIB_PATH})
45   ENDFOREACH(JAVA_LIB_PATH)
46 ENDFOREACH(JAVA_PROG)
48 IF(APPLE)
49   IF(EXISTS ~/Library/Frameworks/JavaEmbedding.framework)
50     SET(JAVA_HAVE_FRAMEWORK 1)
51   ENDIF(EXISTS ~/Library/Frameworks/JavaEmbedding.framework)
52   IF(EXISTS /Library/Frameworks/JavaEmbedding.framework)
53     SET(JAVA_HAVE_FRAMEWORK 1)
54   ENDIF(EXISTS /Library/Frameworks/JavaEmbedding.framework)
55   IF(EXISTS /System/Library/Frameworks/JavaEmbedding.framework)
56     SET(JAVA_HAVE_FRAMEWORK 1)
57   ENDIF(EXISTS /System/Library/Frameworks/JavaEmbedding.framework)
58   IF(JAVA_HAVE_FRAMEWORK)
59     IF(NOT JAVA_AWT_LIBRARY)
60       SET (JAVA_AWT_LIBRARY "-framework JavaVM -framework JavaEmbedding" CACHE FILEPATH "Java Frameworks" FORCE)
61     ENDIF(NOT JAVA_AWT_LIBRARY)
62     SET(JAVA_AWT_INCLUDE_DIRECTORIES ${JAVA_AWT_INCLUDE_DIRECTORIES}
63       ~/Library/Frameworks/JavaVM.framework/Headers
64       /Library/Frameworks/JavaVM.framework/Headers
65       /System/Library/Frameworks/JavaVM.framework/Headers
66       ~/Library/Frameworks/JavaEmbedding.framework/Headers
67       /Library/Frameworks/JavaEmbedding.framework/Headers
68       /System/Library/Frameworks/JavaEmbedding.framework/Headers
69       )
70   ENDIF(JAVA_HAVE_FRAMEWORK)
71 ELSE(APPLE)
72   FIND_LIBRARY(JAVA_AWT_LIBRARY jawt 
73     PATHS ${JAVA_AWT_LIBRARY_DIRECTORIES}
74   )
75 ENDIF(APPLE)
77 # add in the include path    
78 FIND_PATH(JAVA_INCLUDE_PATH jni.h 
79   ${JAVA_AWT_INCLUDE_DIRECTORIES}
82 FIND_PATH(JAVA_INCLUDE_PATH2 jni_md.h 
83   ${JAVA_AWT_INCLUDE_DIRECTORIES}
84   ${JAVA_INCLUDE_PATH}/win32
85   ${JAVA_INCLUDE_PATH}/linux
88 FIND_PATH(JAVA_AWT_INCLUDE_PATH jawt.h 
89           ${JAVA_AWT_INCLUDE_DIRECTORIES} ${JAVA_INCLUDE_PATH} )
91 MARK_AS_ADVANCED(
92   JAVA_AWT_LIBRARY
93   JAVA_AWT_INCLUDE_PATH
94   JAVA_INCLUDE_PATH
95   JAVA_INCLUDE_PATH2