[Bug 266086] devel/cmake: cmake fails to find specific Java version when several Java versions are installed

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sun Nov 13 21:16:38 GMT 2022


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=266086

Adriaan de Groot <adridg at freebsd.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |Works As Intended
             Status|New                         |Closed

--- Comment #14 from Adriaan de Groot <adridg at freebsd.org> ---
CMake-time arguments -- how to get ports to do this is left as an exercise for
the reader -- work. With a modified (to produce less output) CMakeLists.txt,
with jdk 11, 17 and 8 installed, in that order, the following happens:

```
$ rm -rf build/ ; cmake -B build -S .
CMake Error at
/usr/local/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230
(message):
  Could NOT find Java: Found unsuitable version "1.8.0.352", but required is
  at least "11" (found /usr/local/bin/java, found components: Runtime)
```

but I can set a version:

```
$ rm -rf build/ ; cmake -B build -S . -DJAVA_HOME=/usr/local/openjdk11/
-- Found Java: /usr/local/openjdk11/bin/java (found suitable version "11.0.17",
minimum required is "11") found components: Runtime 
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/derp/build
```

or even a newer version:

```
$ rm -rf build/ ; cmake -B build -S . -DJAVA_HOME=/usr/local/openjdk17/
-- Found Java: /usr/local/openjdk17/bin/java (found suitable version "17.0.5",
minimum required is "11") found components: Runtime 
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/derp/build
```

**do** ensure that that command-line argument gets to the CMake invocation.

Note that the executable /usr/local/bin/java is a symlink to a shellscript that
does all *kinds* of stuff, which eventually runs one of the registered java
executables. It doesn't offer an easy (except for the environment variable
JAVA_HOME) way to select a particular Java VM.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the kde-freebsd mailing list