View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014508CMakeModulespublic2013-10-24 11:002014-06-02 08:37
ReporterJoe Abbey 
Assigned ToBrad King 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformMac OS X 10.9 MavericksOSDarwinOS Version10.9
Product VersionCMake 2.8.11.2 
Target VersionCMake 3.0Fixed in VersionCMake 3.0 
Summary0014508: FindJNI.cmake fails to set JAVA_INCLUDE_PATH2 for darwin
DescriptionWhen 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 ReproduceOn 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 InformationThe 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
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0034235)
Joe Abbey (reporter)
2013-10-24 11:01

Oops, I forgot to update the sample CMakesLists.txt. Here you go!

cmake_minimum_required(VERSION 2.8)
find_package(JNI)

if(JNI_FOUND)
    message (STATUS "JAVA_INCLUDE_PATH2=${JAVA_INCLUDE_PATH2}")
else()
    message (FATAL_ERROR "I really need JNI like it's 1999.")
endif()
(0034918)
Larry Shaffer (reporter)
2014-01-08 23:03
edited on: 2014-01-08 23:04

I have included this patch in a related github.com pull request:
https://github.com/Kitware/CMake/pull/80 [^]

as patch:
https://github.com/Kitware/CMake/pull/80.patch [^]

See issue 0014689.

(0034920)
Brad King (manager)
2014-01-09 10:02

Original patch applied as:

 FindJNI: Set JAVA_INCLUDE_PATH2 for darwin
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=519084cd [^]
(0036071)
Robert Maynard (manager)
2014-06-02 08:37

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2013-10-24 11:00 Joe Abbey New Issue
2013-10-24 11:01 Joe Abbey Note Added: 0034235
2013-10-29 05:55 Rolf Eike Beer Assigned To => Mathieu Malaterre
2013-10-29 05:55 Rolf Eike Beer Status new => assigned
2014-01-08 23:03 Larry Shaffer Note Added: 0034918
2014-01-08 23:04 Larry Shaffer Note Edited: 0034918
2014-01-09 10:02 Brad King Note Added: 0034920
2014-01-09 10:02 Brad King Assigned To Mathieu Malaterre => Brad King
2014-01-09 10:02 Brad King Status assigned => resolved
2014-01-09 10:02 Brad King Resolution open => fixed
2014-01-09 10:02 Brad King Fixed in Version => CMake 3.0
2014-01-09 10:02 Brad King Target Version => CMake 3.0
2014-06-02 08:37 Robert Maynard Note Added: 0036071
2014-06-02 08:37 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team