FindJNI not working anymore after Java/CMake/XCode upgrades
After a combination of upgrades (Java/CMake/XCode/command line tools/OS) I found FindJNI
module not working anymore. I can test the issue with the following CMakeLists.txt
:
cmake_minimum_required(VERSION 3.16)
project(hello_world CXX)
find_package(Java REQUIRED COMPONENTS Development)
find_package(JNI REQUIRED)
add_executable(app app.cpp)
The error I get is the following:
CMake Error at /Applications/CMake.app/Contents/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find JNI (missing: JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2
JAVA_AWT_INCLUDE_PATH)
Call Stack (most recent call first):
/Applications/CMake.app/Contents/share/cmake-3.22/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
/Applications/CMake.app/Contents/share/cmake-3.22/Modules/FindJNI.cmake:382 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:11 (find_package
I attempted clean re-installs of Java/CMake/XCode/CTL to no avail. I installed Java 8u321 (download link), but other more recent Java versions don't work as well.
Versions:
- macOS: 12.3-x86_64
- Java: 8u321
- Cmake: 3.22.3 (Official package)
- Xcode: 13.3
- CLT: 13.3.0.0.1.1645755326
- Clang: 13.1.6 build 1316