MantisBT - CMake
View Issue Details
0013942CMakeCCMakepublic2013-02-21 17:502016-06-10 14:31
Carlton Henderson 
Kitware Robot 
normalmajoralways
closedmoved 
sparcsolaris10
CMake 2.8.10.2 
 
0013942: FindJNI.cmake will not respect JAVA_HOME when setting JAVA_INCLUDE_PATH if jni.h exists in CMAKE_SYSTEM_PREFIX_PATH
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.
- 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
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
No tags attached.
Issue History
2013-02-21 17:50Carlton HendersonNew Issue
2013-02-25 12:25Carlton HendersonNote Added: 0032380
2016-06-10 14:28Kitware RobotNote Added: 0042232
2016-06-10 14:28Kitware RobotStatusnew => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:28Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0032380)
Carlton Henderson   
2013-02-25 12:25   
Category should not be 'CCMake'.
(I must have made a mistake setting that field when I first submitted this Issue.)
(0042232)
Kitware Robot   
2016-06-10 14:28   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.