[cmake-developers] [CMake 0013942]: FindJNI.cmake will not respect JAVA_HOME when setting JAVA_INCLUDE_PATH if jni.h exists in CMAKE_SYSTEM_PREFIX_PATH

Mantis Bug Tracker mantis at public.kitware.com
Thu Feb 21 17:50:04 EST 2013


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=13942 
====================================================================== 
Reported By:                Carlton Henderson
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   13942
Category:                   CCMake
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2013-02-21 17:50 EST
Last Modified:              2013-02-21 17:50 EST
====================================================================== 
Summary:                    FindJNI.cmake will not respect JAVA_HOME when
setting JAVA_INCLUDE_PATH if jni.h exists in CMAKE_SYSTEM_PREFIX_PATH
Description: 
I have multiple JDKs installed on my machine. Also, I have gcc and its java
support installed. So, to instruct CMake which java to use, I set the
environment variable JAVA_HOME=/opt/java6 before running cmake. CMake set most
of the java-related variables correctly except JAVA_INCLUDE_PATH which it set to
/usr/local/include.

Steps to Reproduce: 
- touch /usr/local/include/jni.h # or install libgcj using the SMCgcc package
from sunfreeware
- install java6 in /opt/java6
- JAVA_HOME=/opt/java6
- export JAVA_HOME
- construct a CMakeLists.txt file which uses 
- cmake /path/to/sources
- grep JAVA_INCLUDE_PATH: CMakeCache.txt 
=>actual> JAVA_INCLUDE_PATH:PATH=/usr/local/include
=>expected> JAVA_INCLUDE_PATH:PATH=/opt/java6/include
- We didn't notice it until we went to make something that builds against jni.h
=> "/usr/local/include/jni.h", line 81: Error: #error jni.h not ported to this
platform.
- The above error happens because the c++ compiler finds
/usr/local/include/jni.h instead of /opt/java6/include/jni.h

Additional Information: 
A minimalist fix might be to just add HINTS right after
"find_path(JAVA_INCLUDE_PATH jni.h" in FindJNI.cmake. That is, add HINTS right
before ${JAVA_AWT_INCLUDE_DIRECTORIES} so these directories are searched before
each path in CMAKE_SYSTEM_PREFIX_PATH. 

However, CMake users such as myself would love to see FindJNI.cmake test the
variables to make sure that all the JAVA and JNI-related variables point to the
same JVM (like how CMake smartly checks to make sure the C compiler works).

Thanks,

-Carl
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-02-21 17:50 Carlton HendersonNew Issue                                    
======================================================================




More information about the cmake-developers mailing list