CMake/Modules/FindJNI.cmake

191 lines
6.5 KiB
CMake
Raw Normal View History

# - Find JNI java libraries.
2001-05-04 17:47:58 +04:00
# This module finds if Java is installed and determines where the
# include files and libraries are. It also determines what the name of
# the library is. This code sets the following variables:
#
# JNI_INCLUDE_DIRS = the include dirs to use
# JNI_LIBRARIES = the libraries to use
# JAVA_AWT_LIBRARY = the path to the jawt library
# JAVA_JVM_LIBRARY = the path to the jvm library
2005-12-15 18:41:19 +03:00
# JAVA_INCLUDE_PATH = the include path to jni.h
2007-04-04 21:43:12 +04:00
# JAVA_INCLUDE_PATH2 = the include path to jni_md.h
2005-12-15 18:41:19 +03:00
# JAVA_AWT_INCLUDE_PATH = the include path to jawt.h
#
GET_FILENAME_COMPONENT(java_install_version
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit;CurrentVersion]" NAME)
SET(JAVA_AWT_LIBRARY_DIRECTORIES
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/lib"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/lib"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/lib"
$ENV{JAVA_HOME}/jre/lib/alpha
2005-09-23 22:38:51 +04:00
$ENV{JAVA_HOME}/jre/lib/amd64
$ENV{JAVA_HOME}/jre/lib/arm
$ENV{JAVA_HOME}/jre/lib/i386
$ENV{JAVA_HOME}/jre/lib/ia64
$ENV{JAVA_HOME}/jre/lib/m68k
$ENV{JAVA_HOME}/jre/lib/mips
$ENV{JAVA_HOME}/jre/lib/mipsel
$ENV{JAVA_HOME}/jre/lib/parisc
$ENV{JAVA_HOME}/jre/lib/powerpc
$ENV{JAVA_HOME}/jre/lib/ppc
$ENV{JAVA_HOME}/jre/lib/s390
$ENV{JAVA_HOME}/jre/lib/sparc
$ENV{JAVA_HOME}/jre/lib/x86_64
$ENV{JAVA_HOME}/lib
/usr/lib
/usr/local/lib
/usr/lib/jvm/java/lib
/usr/lib/java/jre/lib/i386
/usr/local/lib/java/jre/lib/i386
2006-10-12 21:12:37 +04:00
/usr/local/share/java/jre/lib/i386
2005-02-10 06:46:33 +03:00
/usr/lib/j2sdk1.4-sun/jre/lib/i386
2005-09-08 18:03:51 +04:00
/usr/lib/j2sdk1.5-sun/jre/lib/i386
2005-09-23 22:38:51 +04:00
/opt/sun-jdk-1.5.0.04/jre/lib/amd64
/usr/lib/jvm/java-6-sun/jre/lib/i386
/usr/lib/jvm/java-6-sun/jre/lib/amd64
/usr/lib/jvm/java-1.5.0-sun/jre/lib/i386
/usr/lib/jvm/java-1.5.0-sun/jre/lib/amd64
/usr/lib/jvm/java-6-sun-1.6.0.00/jre/lib/amd64 # can this one be removed according to #8821 ? Alex
/usr/lib/java/jre/lib/amd64
2006-10-12 21:12:37 +04:00
/usr/local/lib/java/jre/lib/amd64
/usr/local/share/java/jre/lib/amd64
/usr/lib/j2sdk1.4-sun/jre/lib/amd64
/usr/lib/j2sdk1.5-sun/jre/lib/amd64
/usr/lib/java/jre/lib/ppc
/usr/local/lib/java/jre/lib/ppc
/usr/local/share/java/jre/lib/ppc
/usr/lib/j2sdk1.4-sun/jre/lib/ppc
/usr/lib/j2sdk1.5-sun/jre/lib/ppc
)
2006-10-28 01:29:05 +04:00
SET(JAVA_JVM_LIBRARY_DIRECTORIES)
FOREACH(dir ${JAVA_AWT_LIBRARY_DIRECTORIES})
SET(JAVA_JVM_LIBRARY_DIRECTORIES
${JAVA_JVM_LIBRARY_DIRECTORIES}
"${dir}"
"${dir}/client"
"${dir}/server"
)
ENDFOREACH(dir)
SET(JAVA_AWT_INCLUDE_DIRECTORIES
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.4;JavaHome]/include"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\1.3;JavaHome]/include"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\JavaSoft\\Java Development Kit\\${java_install_version};JavaHome]/include"
2005-09-23 22:38:51 +04:00
$ENV{JAVA_HOME}/include
2001-06-06 17:43:54 +04:00
/usr/include
/usr/local/include
2002-06-17 21:43:21 +04:00
/usr/lib/java/include
/usr/local/lib/java/include
/usr/lib/jvm/java/include
/usr/lib/jvm/java-6-sun/include
/usr/lib/jvm/java-1.5.0-sun/include
/usr/lib/jvm/java-6-sun-1.6.0.00/include # can this one be removed according to #8821 ? Alex
2006-10-12 21:12:37 +04:00
/usr/local/share/java/include
2005-02-10 06:46:33 +03:00
/usr/lib/j2sdk1.4-sun/include
2005-09-08 18:03:51 +04:00
/usr/lib/j2sdk1.5-sun/include
2005-09-23 22:38:51 +04:00
/opt/sun-jdk-1.5.0.04/include
)
2004-02-06 18:49:46 +03:00
FOREACH(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}")
GET_FILENAME_COMPONENT(jpath "${JAVA_PROG}" PATH)
FOREACH(JAVA_INC_PATH ../include ../java/include ../share/java/include)
IF(EXISTS ${jpath}/${JAVA_INC_PATH})
SET(JAVA_AWT_INCLUDE_DIRECTORIES ${JAVA_AWT_INCLUDE_DIRECTORIES} "${jpath}/${JAVA_INC_PATH}")
ENDIF(EXISTS ${jpath}/${JAVA_INC_PATH})
ENDFOREACH(JAVA_INC_PATH)
FOREACH(JAVA_LIB_PATH
../lib ../jre/lib ../jre/lib/i386
../java/lib ../java/jre/lib ../java/jre/lib/i386
../share/java/lib ../share/java/jre/lib ../share/java/jre/lib/i386)
IF(EXISTS ${jpath}/${JAVA_LIB_PATH})
SET(JAVA_AWT_LIBRARY_DIRECTORIES ${JAVA_AWT_LIBRARY_DIRECTORIES} "${jpath}/${JAVA_LIB_PATH}")
ENDIF(EXISTS ${jpath}/${JAVA_LIB_PATH})
ENDFOREACH(JAVA_LIB_PATH)
ENDFOREACH(JAVA_PROG)
IF(APPLE)
2006-10-27 23:59:40 +04:00
IF(EXISTS ~/Library/Frameworks/JavaVM.framework)
SET(JAVA_HAVE_FRAMEWORK 1)
2006-10-27 23:59:40 +04:00
ENDIF(EXISTS ~/Library/Frameworks/JavaVM.framework)
IF(EXISTS /Library/Frameworks/JavaVM.framework)
SET(JAVA_HAVE_FRAMEWORK 1)
2006-10-27 23:59:40 +04:00
ENDIF(EXISTS /Library/Frameworks/JavaVM.framework)
2007-04-04 21:43:12 +04:00
IF(EXISTS /System/Library/Frameworks/JavaVM.framework)
SET(JAVA_HAVE_FRAMEWORK 1)
ENDIF(EXISTS /System/Library/Frameworks/JavaVM.framework)
IF(JAVA_HAVE_FRAMEWORK)
2003-02-11 21:56:35 +03:00
IF(NOT JAVA_AWT_LIBRARY)
2006-10-24 18:03:39 +04:00
SET (JAVA_AWT_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE)
2003-02-11 21:56:35 +03:00
ENDIF(NOT JAVA_AWT_LIBRARY)
2007-04-04 21:43:12 +04:00
2006-10-28 01:29:05 +04:00
IF(NOT JAVA_JVM_LIBRARY)
SET (JAVA_JVM_LIBRARY "-framework JavaVM" CACHE FILEPATH "Java Frameworks" FORCE)
ENDIF(NOT JAVA_JVM_LIBRARY)
2007-04-04 21:43:12 +04:00
IF(NOT JAVA_AWT_INCLUDE_PATH)
IF(EXISTS /System/Library/Frameworks/JavaVM.framework/Headers/jawt.h)
SET (JAVA_AWT_INCLUDE_PATH "/System/Library/Frameworks/JavaVM.framework/Headers" CACHE FILEPATH "jawt.h location" FORCE)
ENDIF(EXISTS /System/Library/Frameworks/JavaVM.framework/Headers/jawt.h)
ENDIF(NOT JAVA_AWT_INCLUDE_PATH)
# If using "-framework JavaVM", prefer its headers *before* the others in
# JAVA_AWT_INCLUDE_DIRECTORIES... (*prepend* to the list here)
#
SET(JAVA_AWT_INCLUDE_DIRECTORIES
2003-02-11 22:49:11 +03:00
~/Library/Frameworks/JavaVM.framework/Headers
/Library/Frameworks/JavaVM.framework/Headers
/System/Library/Frameworks/JavaVM.framework/Headers
2007-04-04 21:43:12 +04:00
${JAVA_AWT_INCLUDE_DIRECTORIES}
2003-02-11 22:49:11 +03:00
)
ENDIF(JAVA_HAVE_FRAMEWORK)
2003-02-11 22:49:11 +03:00
ELSE(APPLE)
FIND_LIBRARY(JAVA_AWT_LIBRARY jawt
PATHS ${JAVA_AWT_LIBRARY_DIRECTORIES}
)
2006-12-26 16:47:15 +03:00
FIND_LIBRARY(JAVA_JVM_LIBRARY NAMES jvm JavaVM
2006-10-28 01:29:05 +04:00
PATHS ${JAVA_JVM_LIBRARY_DIRECTORIES}
)
ENDIF(APPLE)
# add in the include path
FIND_PATH(JAVA_INCLUDE_PATH jni.h
${JAVA_AWT_INCLUDE_DIRECTORIES}
2001-06-06 17:43:54 +04:00
)
2001-05-04 18:13:37 +04:00
FIND_PATH(JAVA_INCLUDE_PATH2 jni_md.h
${JAVA_AWT_INCLUDE_DIRECTORIES}
2001-05-04 18:13:37 +04:00
${JAVA_INCLUDE_PATH}/win32
${JAVA_INCLUDE_PATH}/linux
${JAVA_INCLUDE_PATH}/freebsd
2001-05-04 18:13:37 +04:00
)
2001-06-06 17:43:54 +04:00
2007-04-04 21:43:12 +04:00
FIND_PATH(JAVA_AWT_INCLUDE_PATH jawt.h
${JAVA_AWT_INCLUDE_DIRECTORIES}
${JAVA_INCLUDE_PATH}
)
2001-12-20 05:51:39 +03:00
MARK_AS_ADVANCED(
JAVA_AWT_LIBRARY
2006-10-28 01:30:26 +04:00
JAVA_JVM_LIBRARY
2001-12-20 05:51:39 +03:00
JAVA_AWT_INCLUDE_PATH
JAVA_INCLUDE_PATH
JAVA_INCLUDE_PATH2
)
SET(JNI_LIBRARIES
${JAVA_AWT_LIBRARY}
${JAVA_JVM_LIBRARY}
)
SET(JNI_INCLUDE_DIRS
${JAVA_INCLUDE_PATH}
${JAVA_INCLUDE_PATH2}
${JAVA_AWT_INCLUDE_PATH}
)