When find_package(Java) moved up before project() statement, cmake finds java correctly bc it sets CMAKE_PREFIX_PATH only after project(). This is because cmake prefixes search path for Java by a toolchain path even though toolchain has nothing to do with Java (r. I had to move find_package(Java) to be before project() to ensure Java is Found ok. So it must be some other variable that force search off JAVA_HOME. Message(STATUS "JAVA_HOME variable is defined or set as '$ prior to calling find_package. So what setting is needed to hint the location? Sample CMake project cmake_minimum_required(VERSION 3.17)
CMAKE LINUX NATIVE PACKAGE INSTALL
CMakes official website has two options to install CMake on Linux as of. This is unlike FindJAVA where the setting JAVA_HOME is specified. Getting Started: Assigning DiskSpace: Fetching and Installing Packages: Getting. This problems goes away after setting JAVA_AWT_LIBRARY, JAVA_JVM_LIBRARY, JAVA_INCLUDE_PATH, JAVA_INCLUDE_PATH2, JAVA_AWT_INCLUDE_PATH prior to calling find_package(JNI)īut such setting defeats the purpose of find_package(JNI) so I wonder if someone could suggest the fix.Īlso the description of FindJNI is too vague : “The caller may set variable JAVA_HOME to specify a Java installation prefix explicitly.”. The debug log for find_package(JNI) shows that instead of considering path set by JAVA_HOME it only considers /opt/myp, /opt/toolchains. the find_package(Java) called prior to find_package(JNI) successfully finds Java. I am getting error indicating failure to find JNI package while it is installed correctly in pretty standard location /opt/jdk/jdk8 (ubuntu 14.04, e.g /opt/jdk/jdk8/jre/lib/amd64/server/libjvm.so ) and JAVA_HOME variable is set appropriately before the call to find_package(JNI).