[cmake-developers] [CMake 0014689]: Leaverage /usr/libexec/java_home to help FindJava and FindJNI modules on Mac 10.6-10.9

Mantis Bug Tracker mantis at public.kitware.com
Wed Jan 8 22:52:32 EST 2014


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=14689 
====================================================================== 
Reported By:                Larry Shaffer
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14689
Category:                   CMake
Reproducibility:            always
Severity:                   major
Priority:                   high
Status:                     new
====================================================================== 
Date Submitted:             2014-01-08 22:52 EST
Last Modified:              2014-01-08 22:52 EST
====================================================================== 
Summary:                    Leaverage /usr/libexec/java_home to help FindJava
and FindJNI modules on Mac 10.6-10.9
Description: 
Mac has a utility, /usr/libexec/java_home, which returns the currently defined
home for the system, similar to setting JAVA_HOME environment variable. Most
users have always used the JavaVM.framework provided by Apple, but with Mac OS X
10.9 Apple no longer readily provides one (though a user may have a previous
install lingering), but instead prompts users to download and install the latest
from Oracle. 

To get FindJava and FindJNI modules to work on Mac, you usually have to set
JAVA_HOME in the environment first, if you want to use a non-Apple Java install,
e.g. Oracle's, even though /usr/libexec/java_home now correctly points to the
non-Apple install. Also, if a user installs the Oracle Java, but still has a
lingering previous Apple install, FindJNI returns mixed results unless
CMAKE_FIND_FRAMEWORK = LAST (FIRST by default).

It is not difficult to determine an Apple Java.framework install, when returned
by /usr/libexec/java_home, since they all have a 'bundle' symlink in their root
directory, while non-Apple installs do not.

Steps to Reproduce: 
Test project attached. Run on a Mac with a non-Apple Java install, without
setting JAVA_HOME environment variable.

If you have a lingering Apple Java install, it overrides and the non-Apple Java
is ignored.

If you have both an Apple JavaVM.framework and a non-Apple Java install, setting
JAVA_HOME environment variable still does not fully work with Find modules,
since CMAKE_FIND_FRAMEWORK defaults to FIRST and Apple's framework components
are often found instead.

Additional Information: 
Will be setting up a github.com pull request with changes that fix these issues.
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2014-01-08 22:52 Larry Shaffer  New Issue                                    
2014-01-08 22:52 Larry Shaffer  File Added: CMakeLists.txt                    
======================================================================




More information about the cmake-developers mailing list