[cmake-developers] FindJava, FindJNI on Mac

Brad King brad.king at kitware.com
Mon Feb 3 15:21:53 EST 2014


On 02/03/2014 03:01 PM, Larry Shaffer wrote:
> After the commits noted here [2], I have found several issues:

I've put as much time into this problem as I can spare now.
Are you interested in becoming the maintainer for these modules?

 http://www.cmake.org/Wiki/CMake:Module_Maintainers#New_Maintainer

> * FindJava.cmake *
> 
> CMAKE_FIND_FRAMEWORK=FIRST|ONLY is ignored; only finds framework's
> executable if JAVA_HOME is defined.

This is because find_program does not consider CMAKE_FIND_FRAMEWORK
at all because frameworks are headers+libraries and not executables.
It is a special case that JavaVM provides executables.  Solving this
would require special handling in FindJava.

> * FindJNI.cmake *
> 
> Defining a framework path for JAVA_HOME fails to find anything
>   patch: https://gist.github.com/dakcarto/8789774
> 
> That patch just sniffs whether the defined framework is an Apple
> install, i.e. has a 'bundle' symlink. I added a pattern match for
> '.framework', but don't know if that is a proper solution for other
> platforms that utilize frameworks, though.

I think matching just "\\.framework/?$" would be sufficient.  Also,
when it does match we should set CMAKE_FIND_FRAMEWORK to ONLY,
hard-code the JAVA_*_LIBRARY results to the JAVA_HOME value, and
set up the find_path arguments to find headers only in the named
framework.

> When framework is preferred or defined, module now returns:
> 
>     JNI_LIBRARIES= /System/Library/Frameworks/JavaVM.framework;/System/Library/Frameworks/JavaVM.framework
>     JAVA_AWT_LIBRARY= /System/Library/Frameworks/JavaVM.framework
>     JAVA_JVM_LIBRARY= /System/Library/Frameworks/JavaVM.framework
> 
> previously this was:
> 
>     JNI_LIBRARIES= -framework JavaVM;-framework JavaVM
>     JAVA_AWT_LIBRARY= -framework JavaVM
>     JAVA_JVM_LIBRARY= -framework JavaVM
> 
> Does this matter for frameworks?

The hard-coded "-framework JavaVM" options that used to be in the
if(APPLE) branch of FindJNI pre-dated CMake's handling of frameworks.
CMake will convert "/path/to/JavaVM.framework" to "-framework JavaVM"
when generating link lines.

-Brad




More information about the cmake-developers mailing list