[cmake-developers] [CMake 0014508]: FindJNI.cmake fails to set JAVA_INCLUDE_PATH2 for darwin

Mantis Bug Tracker mantis at public.kitware.com
Thu Oct 24 11:00:11 EDT 2013


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=14508 
====================================================================== 
Reported By:                Joe Abbey
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14508
Category:                   Modules
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2013-10-24 11:00 EDT
Last Modified:              2013-10-24 11:00 EDT
====================================================================== 
Summary:                    FindJNI.cmake fails to set JAVA_INCLUDE_PATH2 for
darwin
Description: 
When using find_package(JNI) on Mavericks JAVA_INCLUDE_PATH2 fails to be set.

As far as I can tell, /System/Library/Frameworks/JavaVM.Framework/Headers no
longer exists.

The JAVA_INCLUDE_PATH2 needs to also look for the "darwin" subdirectory.

Steps to Reproduce: 
On a Machine running Mac OS X Mavericks:

Create a CMakeLists.txt with the following contents:

find_package(JNI)

if(JNI_FOUND)
    message (STATUS "JAVA_INCLUDE_PATH2=${JAVA_INCLUDE_PATH2}")
else

endif()

END OF CMAKELISTS.TXT

export
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_XX.jdk/Contents/Home/

mkdir build/
cd build/

cmake ..

If JAVA_HOME isn't set of course JNI isn't found at all:

-- The C compiler identification is Clang 5.0.0
-- The CXX compiler identification is Clang 5.0.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Could NOT find JNI (missing:  JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2
JAVA_AWT_INCLUDE_PATH) 
CMake Error at CMakeLists.txt:7 (message):
  I really need JNI like it's 1999.

After I set JAVA_HOME, I'm seeing the following in CMake 2.8.11.2:

-- The C compiler identification is Clang 5.0.0
-- The CXX compiler identification is Clang 5.0.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Could NOT find JNI (missing:  JAVA_INCLUDE_PATH2) 
CMake Error at CMakeLists.txt:7 (message):
  I really need JNI like it's 1999.

With my patch (against cmake git) I get the following:

--
JAVA_INCLUDE_PATH2=/Library/Java/JavaVirtualMachines/jdk1.7.0_XX.jdk/Contents/Home/include/darwin
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/jabbey/src/cmakebugs/build


Additional Information: 
The following patch addresses this issue.

diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake
index 1780a8e..22823e5 100644
--- a/Modules/FindJNI.cmake
+++ b/Modules/FindJNI.cmake
@@ -238,6 +238,7 @@ find_path(JAVA_INCLUDE_PATH jni.h
 
 find_path(JAVA_INCLUDE_PATH2 jni_md.h
   ${JAVA_INCLUDE_PATH}
+  ${JAVA_INCLUDE_PATH}/darwin
   ${JAVA_INCLUDE_PATH}/win32
   ${JAVA_INCLUDE_PATH}/linux
   ${JAVA_INCLUDE_PATH}/freebsd
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2013-10-24 11:00 Joe Abbey      New Issue                                    
======================================================================




More information about the cmake-developers mailing list