[build] Remove cmake Java support (#8952)

This is increasingly difficult to maintain, and has very limited
benefit. Modern coprocessors with enough horsepower to run Java
applications can use the Gradle or Bazel build systems instead.
This commit is contained in:
Peter Johnson
2026-06-05 15:05:09 -07:00
committed by GitHub
parent d941be905e
commit 96fb033deb
42 changed files with 13 additions and 1238 deletions

View File

@@ -33,11 +33,6 @@ jobs:
ndk-version: r27d ndk-version: r27d
add-to-path: false add-to-path: false
- uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: 25
- name: Install sccache - name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.9 uses: mozilla-actions/sccache-action@v0.0.9
@@ -45,7 +40,7 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y ninja-build run: sudo apt-get update && sudo apt-get install -y ninja-build
- name: configure - name: configure
run: cmake --preset with-sccache -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_WPILIB=OFF -DWITH_GUI=OFF -DWITH_CSCORE=OFF -DWITH_TESTS=OFF -DWITH_SIMULATION_MODULES=OFF -DWITH_JAVA=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=${{ steps.setup-ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake -DANDROID_ABI="${{ matrix.abi }}" -DANDROID_PLATFORM=android-24 run: cmake --preset with-sccache -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_WPILIB=OFF -DWITH_GUI=OFF -DWITH_CSCORE=OFF -DWITH_TESTS=OFF -DWITH_SIMULATION_MODULES=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=${{ steps.setup-ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake -DANDROID_ABI="${{ matrix.abi }}" -DANDROID_PLATFORM=android-24
env: env:
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

View File

@@ -19,7 +19,7 @@ jobs:
- os: ubuntu-24.04 - os: ubuntu-24.04
name: Linux name: Linux
container: wpilib/systemcore-cross-ubuntu:2027-24.04 container: wpilib/systemcore-cross-ubuntu:2027-24.04
flags: "--preset with-java-and-sccache -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON" flags: "--preset with-sccache -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON"
- os: macOS-15 - os: macOS-15
name: macOS name: macOS
container: "" container: ""
@@ -35,7 +35,7 @@ jobs:
steps: steps:
- name: Install dependencies (Linux) - name: Install dependencies (Linux)
if: runner.os == 'Linux' if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv-java ninja-build run: sudo apt-get update && sudo apt-get install -y libopencv-dev ninja-build
- name: Setup avahi-daemon - name: Setup avahi-daemon
if: runner.os == 'Linux' if: runner.os == 'Linux'

View File

@@ -33,7 +33,7 @@ jobs:
container: wpilib/roborio-cross-ubuntu:2025-24.04 container: wpilib/roborio-cross-ubuntu:2025-24.04
steps: steps:
- name: Install Dependencies - name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv-java clang-18 ninja-build avahi-daemon run: sudo apt-get update && sudo apt-get install -y libopencv-dev clang-18 ninja-build avahi-daemon
- name: Install sccache - name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.10 uses: mozilla-actions/sccache-action@v0.0.10
@@ -41,7 +41,7 @@ jobs:
- uses: actions/checkout@v6 - uses: actions/checkout@v6
- name: configure - name: configure
run: mkdir build && cd build && cmake -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-18 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-18 -DWITH_JAVA=OFF ${{ matrix.cmake-flags }} .. run: mkdir build && cd build && cmake -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-18 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-18 ${{ matrix.cmake-flags }} ..
env: env:
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}

View File

@@ -63,9 +63,7 @@ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Options for building certain parts of the repo. Everything is built by default. # Options for building certain parts of the repo. Everything is built by default.
option(BUILD_SHARED_LIBS "Build with shared libs (needed for JNI)" ON) option(BUILD_SHARED_LIBS "Build with shared libs" ON)
option(WITH_JAVA "Include Java and JNI in the build" OFF)
option(WITH_JAVA_SOURCE "Build Java source jars" ${WITH_JAVA})
option(WITH_DOCS "Build Doxygen docs (needs Git for versioning)" OFF) option(WITH_DOCS "Build Doxygen docs (needs Git for versioning)" OFF)
cmake_dependent_option( cmake_dependent_option(
DOCS_WARNINGS_AS_ERRORS DOCS_WARNINGS_AS_ERRORS
@@ -78,13 +76,6 @@ option(WITH_CSCORE "Build cscore (needs OpenCV)" ON)
option(WITH_NTCORE "Build ntcore" ON) option(WITH_NTCORE "Build ntcore" ON)
option(WITH_WPICAL "Build wpical" OFF) option(WITH_WPICAL "Build wpical" OFF)
option(WITH_WPIMATH "Build wpimath" ON) option(WITH_WPIMATH "Build wpimath" ON)
cmake_dependent_option(
WITH_WPIUNITS
"Build wpiunits"
ON
WITH_JAVA
OFF
)
option(WITH_WPILIB "Build hal, wpilibc/j, and developerRobot (needs OpenCV)" ON) option(WITH_WPILIB "Build hal, wpilibc/j, and developerRobot (needs OpenCV)" ON)
option(WITH_EXAMPLES "Build examples" OFF) option(WITH_EXAMPLES "Build examples" OFF)
option(WITH_TESTS "Build unit tests (requires internet connection)" ON) option(WITH_TESTS "Build unit tests (requires internet connection)" ON)
@@ -98,26 +89,9 @@ option(USE_SYSTEM_LIBUV "Use system libuv" OFF)
option(USE_SYSTEM_EIGEN "Use system eigen" OFF) option(USE_SYSTEM_EIGEN "Use system eigen" OFF)
option(USE_LINKED_AVAHI "Use directly linked Avahi instead of loading at runtime" OFF) option(USE_LINKED_AVAHI "Use directly linked Avahi instead of loading at runtime" OFF)
# Options for location of OpenCV Java.
set(OPENCV_JAVA_INSTALL_DIR "" CACHE PATH "Location to search for the OpenCV jar file")
# Options for compilation flags. # Options for compilation flags.
option(NO_WERROR "Disable -Werror flag during compilation" OFF) option(NO_WERROR "Disable -Werror flag during compilation" OFF)
if(NOT WITH_JAVA OR NOT WITH_CSCORE)
if(NOT "${OPENCV_JAVA_INSTALL_DIR}" STREQUAL "")
message(
WARNING
"
WARNING: OpenCV Java dir set but java is not enabled!
It will be ignored.
"
)
endif()
endif()
wpilib_config(OPTIONS WITH_JAVA REQUIRES BUILD_SHARED_LIBS)
wpilib_config(OPTIONS WITH_SIMULATION_MODULES REQUIRES BUILD_SHARED_LIBS WITH_WPILIB WITH_NTCORE) wpilib_config(OPTIONS WITH_SIMULATION_MODULES REQUIRES BUILD_SHARED_LIBS WITH_WPILIB WITH_NTCORE)
wpilib_config(OPTIONS WITH_CSCORE REQUIRES WITH_NTCORE) wpilib_config(OPTIONS WITH_CSCORE REQUIRES WITH_NTCORE)
@@ -126,17 +100,7 @@ wpilib_config(OPTIONS WITH_GUI REQUIRES WITH_NTCORE WITH_WPIMATH)
wpilib_config(OPTIONS WITH_WPILIB REQUIRES WITH_NTCORE WITH_WPIMATH) wpilib_config(OPTIONS WITH_WPILIB REQUIRES WITH_NTCORE WITH_WPIMATH)
wpilib_config(OPTIONS WITH_WPIMATH WITH_JAVA REQUIRES WITH_WPIUNITS)
set(include_dest include) set(include_dest include)
set(java_lib_dest java)
if(WITH_JAVA OR WITH_JAVA_SOURCE)
set(CMAKE_JAVA_COMPILE_FLAGS "-encoding" "UTF8" "-Xlint:unchecked" "-proc:full")
find_package(Java REQUIRED COMPONENTS Development)
if(NOT ANDROID)
find_package(JNI REQUIRED COMPONENTS JVM)
endif()
endif()
if(WITH_DOCS) if(WITH_DOCS)
find_package(Doxygen REQUIRED) find_package(Doxygen REQUIRED)
@@ -283,13 +247,8 @@ endif()
set(FILENAME_DEP_REPLACE "get_filename_component(SELF_DIR \"$\{CMAKE_CURRENT_LIST_FILE\}\" PATH)") set(FILENAME_DEP_REPLACE "get_filename_component(SELF_DIR \"$\{CMAKE_CURRENT_LIST_FILE\}\" PATH)")
set(SELF_DIR "$\{SELF_DIR\}") set(SELF_DIR "$\{SELF_DIR\}")
set(WPIUNITS_DEP_REPLACE_IMPL "find_dependency(wpiunits)")
set(WPIANNOTATIONS_DEP_REPLACE_IMPL "find_dependency(wpiannotations)")
set(WPIUTIL_DEP_REPLACE "find_dependency(wpiutil)") set(WPIUTIL_DEP_REPLACE "find_dependency(wpiutil)")
set(DATALOG_DEP_REPLACE "find_dependency(datalog)") set(DATALOG_DEP_REPLACE "find_dependency(datalog)")
if(WITH_JAVA)
add_subdirectory(wpiannotations)
endif()
add_subdirectory(wpiutil) add_subdirectory(wpiutil)
@@ -303,20 +262,10 @@ if(WITH_NTCORE)
endif() endif()
if(WITH_WPIMATH) if(WITH_WPIMATH)
if(WITH_JAVA)
set(WPIUNITS_DEP_REPLACE ${WPIUNITS_DEP_REPLACE_IMPL})
add_subdirectory(wpiunits)
endif()
set(WPIMATH_DEP_REPLACE "find_dependency(wpimath)") set(WPIMATH_DEP_REPLACE "find_dependency(wpimath)")
add_subdirectory(wpimath) add_subdirectory(wpimath)
endif() endif()
if(WITH_WPIUNITS AND NOT WITH_WPIMATH)
# In case of building wpiunits standalone
set(WPIUNITS_DEP_REPLACE ${WPIUNITS_DEP_REPLACE_IMPL})
add_subdirectory(wpiunits)
endif()
if(WITH_GUI) if(WITH_GUI)
add_subdirectory(fields) add_subdirectory(fields)
add_subdirectory(thirdparty/imgui_suite) add_subdirectory(thirdparty/imgui_suite)
@@ -347,16 +296,10 @@ endif()
if(WITH_WPILIB) if(WITH_WPILIB)
set(APRILTAG_DEP_REPLACE "find_dependency(apriltag)") set(APRILTAG_DEP_REPLACE "find_dependency(apriltag)")
set(COMMANDSV3_DEP_REPLACE "find_dependency(commandsv3)")
set(WPILIBC_DEP_REPLACE "find_dependency(wpilibc)") set(WPILIBC_DEP_REPLACE "find_dependency(wpilibc)")
if(WITH_JAVA)
set(WPILIBJ_DEP_REPLACE "find_dependency(wpilibj)")
endif()
set(COMMAND_DEP_REPLACE "find_dependency(commandsv2)") set(COMMAND_DEP_REPLACE "find_dependency(commandsv2)")
add_subdirectory(apriltag) add_subdirectory(apriltag)
add_subdirectory(wpilibj)
add_subdirectory(wpilibc) add_subdirectory(wpilibc)
add_subdirectory(commandsv3) # must be after wpilibj
add_subdirectory(commandsv2) add_subdirectory(commandsv2)
add_subdirectory(romiVendordep) add_subdirectory(romiVendordep)
add_subdirectory(xrpVendordep) add_subdirectory(xrpVendordep)

View File

@@ -24,27 +24,6 @@
"CMAKE_C_COMPILER_LAUNCHER": "sccache", "CMAKE_C_COMPILER_LAUNCHER": "sccache",
"CMAKE_CXX_COMPILER_LAUNCHER": "sccache" "CMAKE_CXX_COMPILER_LAUNCHER": "sccache"
} }
},
{
"name": "with-java",
"displayName": "",
"description": "Ninja config with Java",
"generator": "Ninja",
"binaryDir": "build-cmake",
"cacheVariables": {
"WITH_JAVA": "ON"
}
},
{
"name": "with-java-and-sccache",
"displayName": "",
"description": "Ninja config with Java and sccache",
"generator": "Ninja",
"inherits": "with-sccache",
"binaryDir": "build-cmake",
"cacheVariables": {
"WITH_JAVA": "ON"
}
} }
] ]
} }

View File

@@ -1,12 +1,11 @@
# WPILib CMake Support # WPILib CMake Support
WPILib is normally built with Gradle, however for some systems, such as Linux based coprocessors, Gradle doesn't work correctly, especially if cscore is needed, which requires OpenCV. Furthermore, the CMake build can be used for C++ development because it provides better build caching compared to Gradle. We provide the CMake build for these cases. Although macOS is supported, these docs will only go over Linux and Windows builds, but should mostly work for macOS as well. If you are stuck, you can look at the GitHub workflows for any OS to see how it works. WPILib is normally built with Gradle, however for some systems, such as Linux based coprocessors, Gradle doesn't work correctly, especially if cscore is needed, which requires OpenCV. Furthermore, the CMake build can be used for C++ development because it provides better build caching compared to Gradle. We provide the CMake build for these cases. Although macOS is supported, these docs will only go over Linux and Windows builds, but should mostly work for macOS as well. If you are stuck, you can look at the GitHub workflows for any OS to see how it works. The CMake build does not build Java or Python, only C++.
## Libraries that get built ## Libraries that get built
* apriltag * apriltag
* cameraserver * cameraserver
* commandsv2 * commandsv2
* commandsv3
* cscore * cscore
* datalog * datalog
* fields * fields
@@ -18,7 +17,6 @@ WPILib is normally built with Gradle, however for some systems, such as Linux ba
* wpilib (wpilibc, wpilibj, and developerRobot) * wpilib (wpilibc, wpilibj, and developerRobot)
* wpimath * wpimath
* wpinet * wpinet
* wpiunits
* wpiutil * wpiutil
* xrpVendordep * xrpVendordep
@@ -30,30 +28,24 @@ WPILib is normally built with Gradle, however for some systems, such as Linux ba
* wpical * wpical
* halsim_gui (if simulation extensions are enabled) * halsim_gui (if simulation extensions are enabled)
By default, all libraries get built with a default CMake setup. The libraries are built as shared libraries, and include the JNI libraries as well as building the Java JARs. Data Log Tool is only built if libssh is available. By default, all libraries get built with a default CMake setup. The libraries are built as shared libraries. Data Log Tool is only built if libssh is available.
## Prerequisites ## Prerequisites
OpenCV needs to be findable by CMake. On systems like the Jetson, this is installed by default. Otherwise, you will need to build OpenCV from source and install it. OpenCV needs to be findable by CMake. On systems like the Jetson, this is installed by default. Otherwise, you will need to build OpenCV from source and install it.
If you want JNI and Java, you will need a JDK of at least version 25 installed. In addition, you need a `JAVA_HOME` environment variable set properly and set to the JDK directory.
## Build Options ## Build Options
The following build options are available: The following build options are available:
* `BUILD_SHARED_LIBS` (ON Default) * `BUILD_SHARED_LIBS` (ON Default)
* This option will cause CMake to build static libraries instead of shared libraries. If this is off, `WITH_JAVA` must be off. Otherwise CMake will error. * This option will cause CMake to build static libraries instead of shared libraries.
* `WITH_CSCORE` (ON Default) * `WITH_CSCORE` (ON Default)
* This option will cause cscore to be built. Turning this off will implicitly disable cameraserver. If this is off, the OpenCV build requirement is removed. * This option will cause cscore to be built. Turning this off will implicitly disable cameraserver. If this is off, the OpenCV build requirement is removed.
* `WITH_EXAMPLES` (OFF Default) * `WITH_EXAMPLES` (OFF Default)
* This option will build C++ examples. * This option will build C++ examples.
* `WITH_GUI` (ON Default) * `WITH_GUI` (ON Default)
* This option will build GUI items. If this is off, and `WITH_SIMULATION_MODULES` is on, the simulation GUI will not be built. * This option will build GUI items. If this is off, and `WITH_SIMULATION_MODULES` is on, the simulation GUI will not be built.
* `WITH_JAVA` (OFF Default)
* This option will enable Java and JNI builds. If this is on, `BUILD_SHARED_LIBS` must be on. Otherwise CMake will error.
* `WITH_JAVA_SOURCE` (`WITH_JAVA` Default)
* This option will build Java source JARs for each enabled Java library. This does not require `WITH_JAVA` to be on, allowing source JARs to be built without the compiled JARs if desired.
* `WITH_NTCORE` (ON Default) * `WITH_NTCORE` (ON Default)
* This option will cause ntcore to be built. Turning this off will implicitly disable wpinet, and will cause an error if `WITH_WPILIB` is enabled. * This option will cause ntcore to be built. Turning this off will implicitly disable wpinet, and will cause an error if `WITH_WPILIB` is enabled.
* `WITH_SIMULATION_MODULES` (ON Default) * `WITH_SIMULATION_MODULES` (ON Default)
@@ -61,13 +53,9 @@ The following build options are available:
* `WITH_TESTS` (ON Default) * `WITH_TESTS` (ON Default)
* This option will build C++ unit tests. These can be run via `ctest -C <config>`, where `<config>` is the build configuration, e.g. `Debug` or `Release`. * This option will build C++ unit tests. These can be run via `ctest -C <config>`, where `<config>` is the build configuration, e.g. `Debug` or `Release`.
* `WITH_WPILIB` (ON Default) * `WITH_WPILIB` (ON Default)
* This option will build the HAL and wpilibc/j during the build. The HAL is the simulation HAL, unless the external HAL options are used. The CMake build has no capability to build for Systemcore. * This option will build the HAL and wpilibc during the build. The HAL is the simulation HAL, unless the external HAL options are used. The CMake build has no capability to build for Systemcore.
* `WITH_WPIMATH` (ON Default) * `WITH_WPIMATH` (ON Default)
* This option will build the wpimath library. This option must be on to build wpilib. * This option will build the wpimath library. This option must be on to build wpilib.
* `WITH_WPIUNITS` (`WITH_JAVA` Default)
* This option will build the wpiunits library. This option must be on to build the Java wpimath library and requires `WITH_JAVA` to also be on.
* `OPENCV_JAVA_INSTALL_DIR`
* Set this option to the location of the archive of the OpenCV Java bindings (it should be called opencv-xxx.jar, with the x'es being version numbers). NOTE: set it to the LOCATION of the file, not the file itself!
* `NO_WERROR` (OFF Default) * `NO_WERROR` (OFF Default)
* This option will disable the `-Werror` compilation flag for non-MSVC builds. * This option will disable the `-Werror` compilation flag for non-MSVC builds.
* `WPILIB_TARGET_WARNINGS` * `WPILIB_TARGET_WARNINGS`
@@ -89,7 +77,7 @@ If you want, you can also use `ccmake` in order to visually set these properties
## Presets ## Presets
The WPILib CMake setup has a variety of presets for common configurations and options used. The default sets the generator to Ninja and build directory to `build-cmake`. The other presets are `with-java` (sets `WITH_JAVA=ON`), `sccache` (sets the C/C++ compiler launcher to sccache), and `with-java-sccache` (a combination of `with-java` and `sccache`). The WPILib CMake setup has a variety of presets for common configurations and options used. The default sets the generator to Ninja and build directory to `build-cmake`. The other preset is `sccache` (sets the C/C++ compiler launcher to sccache).
## Building ## Building
@@ -115,7 +103,7 @@ sudo cmake --build . --target install
On Windows, make sure the directories for the libraries you built are on PATH. For wpilib, the default install location is `C:\Program Files (x86)\allwpilib`. If you built other libraries like OpenCV from source, install them, and add the install directories to PATH. This ensures CMake can locate the libraries. On Windows, make sure the directories for the libraries you built are on PATH. For wpilib, the default install location is `C:\Program Files (x86)\allwpilib`. If you built other libraries like OpenCV from source, install them, and add the install directories to PATH. This ensures CMake can locate the libraries.
You will also want to add the directories where the DLLs are located (usually the `bin` subdirectory of the install directory) to PATH so they can be loaded by your program. If you are using OpenCV and Java, the `opencv_java` DLL is located in either the `lib` subdirectory if you built but didn't install OpenCV, or the `java` subdirectory if you did install OpenCV. You will also want to add the directories where the DLLs are located (usually the `bin` subdirectory of the install directory) to PATH so they can be loaded by your program.
## Using the installed libraries for C++. ## Using the installed libraries for C++.
@@ -143,40 +131,9 @@ cmake /path/to/folder/containing/CMakeLists
After that, run `cmake --build .`. That will create your executable. Then you should be able to run `./my_vision_app` to run your application. After that, run `cmake --build .`. That will create your executable. Then you should be able to run `./my_vision_app` to run your application.
## Using the installed libraries for Java
Using the built JARs is more involved than using the C++ libraries, but the additional work involves providing the paths to various libraries and JARs when needed.
Create a new folder to contain your project. Add the following code below to a `CMakeLists.txt` file in that directory.
```cmake
cmake_minimum_required(VERSION 3.11)
project(robot)
find_package(Java REQUIRED COMPONENTS Development)
include(UseJava)
find_package(wpilib REQUIRED)
find_jar(opencvJar opencv-xxx PATHS ENV PATH) # Change to OpenCV version
file(GLOB_RECURSE JAVA_SOURCES *.java)
# If you want Gradle compatibility or you are using one of the templates/examples, comment out the above line and uncomment this line instead:
# file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
add_jar(robot ${JAVA_SOURCES}
INCLUDE_JARS apriltag_jar cscore_jar hal_jar ntcore_jar commandsv2_jar wpimath_jar wpinet_jar wpiutil_jar wpiunits_jar wpilibj_jar ${opencvJar})
export_jars(TARGETS robot FILE robot.jar)
```
This includes all the built JARs except for the vendordeps. If you are not using a JAR/library, you may remove it.
Add a `Main.java` file to contain your code, and create a build folder. Move into the build folder, and run
```
cmake /path/to/folder/containing/CMakeLists
```
After that, run `cmake --build .` to create your JAR file. To execute the JAR file, you need to include the wpilib JARs and your JAR in the classpath, and execute your Java program's entry point. If you are using cscore or cameraserver, you also need to include the path to the OpenCV JAR. If you built it from source, it will be in your OpenCV build directory. If it's installed on the system, CMake may find it from PATH, but you will likely need to locate the JAR and manually give CMake the JAR directory. If you are on Linux, you will also need to add the path of the libraries to `LD_LIBRARY_PATH`. This can be done by prepending `LD_LIBRARY_PATH=/path/to/libraries` to the Java command. If you need to add more paths, separate them with colons. The final command should look like `java -cp "robot.jar:/path/to/library_jars/*" main.package.Main`, using a semicolon to separate paths instead of a colon if you are on Windows. If you are on Linux, the final command should look more like `LD_LIBRARY_PATH=/path/to/libraries java -cp robot.jar:/path/to/library_jars/* main.package.Main`.
## Using vendordeps ## Using vendordeps
Vendordeps are not included as part of the `wpilib` CMake package. However, if you want to use a vendordep, you need to use `find_package(VENDORDEP)`, where `VENDORDEP` is the name of the vendordep (case-sensitive), like `xrpVendordep` or `romiVendordep`. Note that commandsv2, while a vendordep in normal robot projects, is not built as a vendordep in CMake, and is instead included as part of the `wpilib` CMake package. After you used `find_package`, you can reference the vendordep library like normal, either by using `target_link_libraries` for C++ or `add_jar` for Java. Vendordeps are not included as part of the `wpilib` CMake package. However, if you want to use a vendordep, you need to use `find_package(VENDORDEP)`, where `VENDORDEP` is the name of the vendordep (case-sensitive), like `xrpVendordep` or `romiVendordep`. Note that commandsv2, while a vendordep in normal robot projects, is not built as a vendordep in CMake, and is instead included as part of the `wpilib` CMake package. After you used `find_package`, you can reference the vendordep library like normal (using `target_link_libraries`).
## Troubleshooting ## Troubleshooting
Below are some common issues that are run into when building. Below are some common issues that are run into when building.
@@ -204,32 +161,3 @@ CMake Error at cscore/CMakeLists.txt:3 (find_package):
``` ```
If you get that, you need make sure OpenCV was installed, and then reattempt to configure. If that doesn't work, set the `OpenCV_DIR` variable to the directory where you built OpenCV. If you get that, you need make sure OpenCV was installed, and then reattempt to configure. If that doesn't work, set the `OpenCV_DIR` variable to the directory where you built OpenCV.
#### Missing Java
If you are missing Java, you will get a message like the following.
```
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE
Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE
Development)
```
If this happens, make sure you have a JDK of at least version 25 installed, and that your JAVA_HOME variable is set properly to point to the JDK.
In addition, if you do not need Java, you can disable it with `-DWITH_JAVA=OFF`.
#### Java: Can't find dependent libraries
If one of the libraries can't be found, you will get an error similar to this one:
```
java.io.IOException: wpiHaljni could not be loaded from path or an embedded resource.
attempted to load for platform windows-x86_64
Last Load Error:
C:\Program Files (x86)\allwpilib\bin\wpiHaljni.dll: Can't find dependent libraries
```
If you get this error, that's usually an indication that not all your libraries are in your PATH. If the error is coming from cscore specifically, it's likely you're missing OpenCV. Otherwise, it's likely the wpilib libraries are not in a directory on PATH.
Note that Linux will not have this specific type of error, as it will usually tell you the dependent library you are missing. In that case, you most likely need to add the library to `LD_LIBRARY_PATH`.

View File

@@ -31,81 +31,6 @@ else()
) )
endif() endif()
file(GLOB apriltag_jni_src src/main/native/cpp/jni/AprilTagJNI.cpp)
if(WITH_JAVA)
include(UseJava)
set(CMAKE_JNI_TARGET true)
file(GLOB EJML_JARS "${WPILIB_BINARY_DIR}/wpimath/thirdparty/ejml/*.jar")
file(GLOB AVAJE_JARS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/avaje/*.jar")
find_file(
OPENCV_JAR_FILE
NAMES opencv-${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.jar
PATHS
${OPENCV_JAVA_INSTALL_DIR}
${OpenCV_INSTALL_PATH}/bin
${OpenCV_INSTALL_PATH}/share/java
${OpenCV_INSTALL_PATH}/share/java/opencv4
${OpenCV_INSTALL_PATH}/share/OpenCV/java
NO_DEFAULT_PATH
)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
file(
GLOB_RECURSE JAVA_RESOURCES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
src/main/native/resources/*.json
)
add_jar(
apriltag_jar
SOURCES ${JAVA_SOURCES}
RESOURCES
NAMESPACE "org/wpilib/vision/apriltag" ${JAVA_RESOURCES}
INCLUDE_JARS
wpimath_jar
wpiunits_jar
wpiutil_jar
${EJML_JARS}
${OPENCV_JAR_FILE}
${AVAJE_JARS}
OUTPUT_NAME apriltag
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
GENERATE_NATIVE_HEADERS apriltag_jni_headers
)
set_property(TARGET apriltag_jar PROPERTY FOLDER "java")
install_jar(apriltag_jar DESTINATION ${java_lib_dest})
install_jar_exports(TARGETS apriltag_jar FILE apriltag_jar.cmake DESTINATION share/apriltag)
add_library(apriltagjni ${apriltag_jni_src} ${apriltaglib_src})
wpilib_target_warnings(apriltagjni)
target_link_libraries(apriltagjni PUBLIC apriltag)
set_property(TARGET apriltagjni PROPERTY FOLDER "libraries")
target_link_libraries(apriltagjni PRIVATE apriltag_jni_headers)
add_dependencies(apriltagjni apriltag_jar)
install(TARGETS apriltagjni EXPORT apriltagjni)
export(TARGETS apriltagjni FILE apriltagjni.cmake NAMESPACE apriltagjni::)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
apriltag_src_jar
BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
OUTPUT_NAME apriltag-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET apriltag_src_jar PROPERTY FOLDER "java")
install_jar(apriltag_src_jar DESTINATION ${java_lib_dest})
endif()
generate_resources( generate_resources(
src/main/native/resources/org/wpilib/vision/apriltag src/main/native/resources/org/wpilib/vision/apriltag
generated/main/cpp generated/main/cpp

View File

@@ -5,6 +5,3 @@ include(CMakeFindDependencyMacro)
@FILENAME_DEP_REPLACE@ @FILENAME_DEP_REPLACE@
include(${SELF_DIR}/apriltag.cmake) include(${SELF_DIR}/apriltag.cmake)
if(@WITH_JAVA@)
include(${SELF_DIR}/apriltag_jar.cmake)
endif()

View File

@@ -3,57 +3,6 @@ project(cameraserver)
include(CompileWarnings) include(CompileWarnings)
include(AddTest) include(AddTest)
# Java bindings
if(WITH_JAVA)
include(UseJava)
#find JAR file, copy it locally
set(OPENCV_JAVA_INSTALL_DIR ${OpenCV_INSTALL_PATH}/share/java/opencv4)
find_file(
OPENCV_JAR_FILE
NAMES opencv-${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.jar
PATHS
${OPENCV_JAVA_INSTALL_DIR}
${OpenCV_INSTALL_PATH}/bin
${OpenCV_INSTALL_PATH}/share/java
${OpenCV_INSTALL_PATH}/share/OpenCV/java
NO_DEFAULT_PATH
)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
add_jar(
cameraserver_jar
${JAVA_SOURCES}
INCLUDE_JARS wpiutil_jar cscore_jar ntcore_jar ${OPENCV_JAR_FILE}
OUTPUT_NAME cameraserver
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET cameraserver_jar PROPERTY FOLDER "java")
install_jar(cameraserver_jar DESTINATION ${java_lib_dest})
install_jar_exports(
TARGETS cameraserver_jar
FILE cameraserver_jar.cmake
DESTINATION share/cameraserver
)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
cameraserver_src_jar
BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
OUTPUT_NAME cameraserver-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET cameraserver_src_jar PROPERTY FOLDER "java")
install_jar(cameraserver_src_jar DESTINATION ${java_lib_dest})
endif()
file(GLOB_RECURSE cameraserver_native_src src/main/native/cpp/*.cpp) file(GLOB_RECURSE cameraserver_native_src src/main/native/cpp/*.cpp)
add_library(cameraserver ${cameraserver_native_src}) add_library(cameraserver ${cameraserver_native_src})
set_target_properties(cameraserver PROPERTIES DEBUG_POSTFIX "d") set_target_properties(cameraserver PROPERTIES DEBUG_POSTFIX "d")

View File

@@ -8,6 +8,3 @@ find_dependency(OpenCV)
@FILENAME_DEP_REPLACE@ @FILENAME_DEP_REPLACE@
include(${SELF_DIR}/cameraserver.cmake) include(${SELF_DIR}/cameraserver.cmake)
if(@WITH_JAVA@)
include(${SELF_DIR}/cameraserver_jar.cmake)
endif()

View File

@@ -1,33 +0,0 @@
macro(add_source_jar target)
set(oneValueArgs OUTPUT_NAME OUTPUT_DIR)
cmake_parse_arguments(SOURCE_JAR "" "${oneValueArgs}" "BASE_DIRECTORIES" ${ARGN})
foreach(base_package_dir ${SOURCE_JAR_BASE_DIRECTORIES})
file(GLOB_RECURSE directories LIST_DIRECTORIES true ${base_package_dir}/*.directoriesonly)
# Find all packages
foreach(directory ${directories})
cmake_path(
RELATIVE_PATH directory
BASE_DIRECTORY ${base_package_dir}
OUTPUT_VARIABLE package_name
)
file(GLOB package_sources ${directory}/*.java)
if(package_sources STREQUAL "")
continue()
endif()
# If package sources are scattered across different places, consolidate them under one package
list(FIND packages ${package_name} index)
if(index EQUAL -1)
list(APPEND packages ${package_name})
endif()
list(APPEND ${package_name} ${package_sources})
endforeach()
endforeach()
set(resources "")
foreach(package ${packages})
string(APPEND resources "NAMESPACE \"${package}\" ${${package}} ")
endforeach()
cmake_language(
EVAL CODE
"add_jar(${target} RESOURCES ${resources} OUTPUT_NAME ${SOURCE_JAR_OUTPUT_NAME} OUTPUT_DIR ${SOURCE_JAR_OUTPUT_DIR})"
)
endmacro()

View File

@@ -4,55 +4,6 @@ include(SubDirList)
include(CompileWarnings) include(CompileWarnings)
include(AddTest) include(AddTest)
if(WITH_JAVA)
include(UseJava)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java src/generated/main/java/*.java)
file(GLOB AVAJE_JARS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/avaje/*.jar")
add_jar(
commandsv2_jar
${JAVA_SOURCES}
INCLUDE_JARS
hal_jar
ntcore_jar
${AVAJE_JARS}
cscore_jar
cameraserver_jar
wpimath_jar
wpiunits_jar
wpiutil_jar
wpilibj_jar
datalog_jar
wpiannotations_jar
OUTPUT_NAME commandsv2
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET commandsv2_jar PROPERTY FOLDER "java")
install_jar(commandsv2_jar DESTINATION ${java_lib_dest})
install_jar_exports(
TARGETS commandsv2_jar
FILE commandsv2_jar.cmake
DESTINATION share/commandsv2
)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
commandsv2_src_jar
BASE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
${CMAKE_CURRENT_SOURCE_DIR}/src/generated/main/java
OUTPUT_NAME commandsv2-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET commandsv2_src_jar PROPERTY FOLDER "java")
install_jar(commandsv2_src_jar DESTINATION ${java_lib_dest})
endif()
file( file(
GLOB_RECURSE commandsv2_native_src GLOB_RECURSE commandsv2_native_src
src/main/native/cpp/*.cpp src/main/native/cpp/*.cpp

View File

@@ -10,6 +10,3 @@ include(CMakeFindDependencyMacro)
@FILENAME_DEP_REPLACE@ @FILENAME_DEP_REPLACE@
include(${SELF_DIR}/commandsv2.cmake) include(${SELF_DIR}/commandsv2.cmake)
if(@WITH_JAVA@)
include(${SELF_DIR}/commandsv2_jar.cmake)
endif()

View File

@@ -1,53 +0,0 @@
project(commandsv3)
include(SubDirList)
include(CompileWarnings)
include(AddTest)
if(WITH_JAVA)
include(UseJava)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java src/generated/main/java/*.java)
file(GLOB QUICKBUF_JAR ${WPILIB_BINARY_DIR}/wpiutil/thirdparty/quickbuf/*.jar)
add_jar(
commandsv3_jar
${JAVA_SOURCES}
INCLUDE_JARS
datalog_jar
hal_jar
ntcore_jar
cscore_jar
cameraserver_jar
wpiannotations_jar
wpimath_jar
wpiunits_jar
wpiutil_jar
wpilibj_jar
${QUICKBUF_JAR}
OUTPUT_NAME commandsv3
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
install_jar(commandsv3_jar DESTINATION ${java_lib_dest})
install_jar_exports(
TARGETS commandsv3_jar
FILE commandsv3_jar.cmake
DESTINATION share/commandsv3
)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
commandsv3_src_jar
BASE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
${CMAKE_CURRENT_SOURCE_DIR}/src/generated/main/java
OUTPUT_NAME commandsv3-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET commandsv3_src_jar PROPERTY FOLDER "java")
install_jar(commandsv3_src_jar DESTINATION ${java_lib_dest})
endif()

View File

@@ -1,15 +0,0 @@
include(CMakeFindDependencyMacro)
@WPIUTIL_DEP_REPLACE@
@DATALOG_DEP_REPLACE@
@NTCORE_DEP_REPLACE@
@CSCORE_DEP_REPLACE@
@CAMERASERVER_DEP_REPLACE@
@HAL_DEP_REPLACE@
@WPILIBC_DEP_REPLACE@
@WPIMATH_DEP_REPLACE@
@FILENAME_DEP_REPLACE@
include(${SELF_DIR}/commandsv3.cmake)
if(@WITH_JAVA@)
include(${SELF_DIR}/commandsv3_jar.cmake)
endif()

View File

@@ -75,72 +75,6 @@ foreach(example ${cscore_examples})
endif() endif()
endforeach() endforeach()
# Java bindings
if(WITH_JAVA)
include(UseJava)
#find JAR file, copy it locally
if("${OPENCV_JAVA_INSTALL_DIR}" STREQUAL "")
set(OPENCV_JAVA_INSTALL_DIR ${OpenCV_INSTALL_PATH}/share/java/opencv4)
endif()
find_file(
OPENCV_JAR_FILE
NAMES opencv-${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.jar
PATHS
${OPENCV_JAVA_INSTALL_DIR}
${OpenCV_INSTALL_PATH}/bin
${OpenCV_INSTALL_PATH}/share/java
${OpenCV_INSTALL_PATH}/share/OpenCV/java
NO_DEFAULT_PATH
)
file(GLOB cscore_jni_src src/main/native/cpp/jni/CameraServerJNI.cpp)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
set(CMAKE_JNI_TARGET true)
add_jar(
cscore_jar
${JAVA_SOURCES}
INCLUDE_JARS wpiutil_jar ${OPENCV_JAR_FILE}
OUTPUT_NAME cscore
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
GENERATE_NATIVE_HEADERS cscore_jni_headers
)
set_property(TARGET cscore_jar PROPERTY FOLDER "java")
install_jar(cscore_jar DESTINATION ${java_lib_dest})
install_jar_exports(TARGETS cscore_jar FILE cscore_jar.cmake DESTINATION share/cscore)
install(FILES ${OPENCV_JAR_FILE} DESTINATION "${java_lib_dest}")
add_library(cscorejni ${cscore_jni_src})
wpilib_target_warnings(cscorejni)
target_link_libraries(cscorejni PUBLIC cscore wpiutil ${OpenCV_LIBS})
set_property(TARGET cscorejni PROPERTY FOLDER "libraries")
target_link_libraries(cscorejni PRIVATE cscore_jni_headers)
add_dependencies(cscorejni cscore_jar)
install(TARGETS cscorejni EXPORT cscorejni)
export(TARGETS cscorejni FILE cscorejni.cmake NAMESPACE cscorejni::)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
cscore_src_jar
BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
OUTPUT_NAME cscore-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET cscore_src_jar PROPERTY FOLDER "java")
install_jar(cscore_src_jar DESTINATION ${java_lib_dest})
endif()
if(WITH_TESTS) if(WITH_TESTS)
wpilib_add_test(cscore src/test/native/cpp) wpilib_add_test(cscore src/test/native/cpp)
target_link_libraries(cscore_test cscore googletest) target_link_libraries(cscore_test cscore googletest)

View File

@@ -6,6 +6,3 @@ find_dependency(OpenCV)
@FILENAME_DEP_REPLACE@ @FILENAME_DEP_REPLACE@
include(${SELF_DIR}/cscore.cmake) include(${SELF_DIR}/cscore.cmake)
if(@WITH_JAVA@)
include(${SELF_DIR}/cscore_jar.cmake)
endif()

View File

@@ -4,9 +4,6 @@ include(CompileWarnings)
file(GLOB datalog_native_src src/main/native/cpp/*.cpp) file(GLOB datalog_native_src src/main/native/cpp/*.cpp)
file(GLOB datalog_jni_src src/main/native/cpp/jni/DataLogJNI.cpp)
list(REMOVE_ITEM datalog_native_src ${datalog_jni_src})
add_library(datalog ${datalog_native_src}) add_library(datalog ${datalog_native_src})
set_target_properties(datalog PROPERTIES DEBUG_POSTFIX "d") set_target_properties(datalog PROPERTIES DEBUG_POSTFIX "d")
@@ -31,55 +28,6 @@ foreach(example ${datalog_examples})
endif() endif()
endforeach() endforeach()
# Java bindings
if(WITH_JAVA)
include(UseJava)
set(CMAKE_JNI_TARGET true)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
file(GLOB QUICKBUF_JAR ${WPILIB_BINARY_DIR}/wpiutil/thirdparty/quickbuf/*.jar)
add_jar(
datalog_jar
${JAVA_SOURCES}
INCLUDE_JARS wpiutil_jar ${QUICKBUF_JAR}
OUTPUT_NAME datalog
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
GENERATE_NATIVE_HEADERS datalog_jni_headers
)
set_property(TARGET datalog_jar PROPERTY FOLDER "java")
install_jar(datalog_jar DESTINATION ${java_lib_dest})
install_jar_exports(TARGETS datalog_jar FILE datalog_jar.cmake DESTINATION share/datalog)
add_library(datalogjni ${datalog_jni_src})
wpilib_target_warnings(datalogjni)
target_link_libraries(datalogjni PUBLIC datalog wpiutil)
set_property(TARGET datalogjni PROPERTY FOLDER "libraries")
target_link_libraries(datalogjni PRIVATE datalog_jni_headers)
add_dependencies(datalogjni datalog_jar)
install(TARGETS datalogjni EXPORT datalogjni)
export(TARGETS datalogjni FILE datalogjni.cmake NAMESPACE datalogjni::)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
datalog_src_jar
BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
OUTPUT_NAME datalog-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET datalog_src_jar PROPERTY FOLDER "java")
install_jar(datalog_src_jar DESTINATION ${java_lib_dest})
endif()
install(TARGETS datalog EXPORT datalog) install(TARGETS datalog EXPORT datalog)
export(TARGETS datalog FILE datalog.cmake NAMESPACE datalog::) export(TARGETS datalog FILE datalog.cmake NAMESPACE datalog::)

View File

@@ -3,6 +3,3 @@ include(CMakeFindDependencyMacro)
@WPIUTIL_DEP_REPLACE@ @WPIUTIL_DEP_REPLACE@
@FILENAME_DEP_REPLACE@ @FILENAME_DEP_REPLACE@
include(${SELF_DIR}/datalog.cmake) include(${SELF_DIR}/datalog.cmake)
if(@WITH_JAVA@)
include(${SELF_DIR}/datalog_jar.cmake)
endif()

View File

@@ -3,43 +3,6 @@ project(fields)
include(CompileWarnings) include(CompileWarnings)
include(GenResources) include(GenResources)
if(WITH_JAVA)
include(UseJava)
file(GLOB AVAJE_JARS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/avaje/*.jar")
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
file(
GLOB_RECURSE JAVA_FRC_RESOURCES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
src/main/native/resources/frc/*.json
src/main/native/resources/frc/*.png
src/main/native/resources/frc/*.jpg
)
file(
GLOB_RECURSE JAVA_FTC_RESOURCES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
src/main/native/resources/ftc/*.json
src/main/native/resources/ftc/*.png
src/main/native/resources/ftc/*.jpg
)
add_jar(
field_images_jar
SOURCES ${JAVA_SOURCES}
RESOURCES
NAMESPACE "org/wpilib/fields/frc" ${JAVA_FRC_RESOURCES}
NAMESPACE "org/wpilib/fields/ftc" ${JAVA_FTC_RESOURCES}
INCLUDE_JARS ${AVAJE_JARS}
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
OUTPUT_NAME fields
)
set_property(TARGET field_images_jar PROPERTY FOLDER "java")
install_jar(field_images_jar DESTINATION ${java_lib_dest})
install_jar_exports(TARGETS field_images_jar FILE fields_jar.cmake DESTINATION share/fields)
endif()
generate_resources( generate_resources(
src/main/native/resources/org/wpilib/fields/* src/main/native/resources/org/wpilib/fields/*
${CMAKE_CURRENT_BINARY_DIR}/generated/main/cpp ${CMAKE_CURRENT_BINARY_DIR}/generated/main/cpp

View File

@@ -1,5 +1,2 @@
@FILENAME_DEP_REPLACE@ @FILENAME_DEP_REPLACE@
include(${SELF_DIR}/fields.cmake) include(${SELF_DIR}/fields.cmake)
if(@WITH_JAVA@)
include(${SELF_DIR}/fields_jar.cmake)
endif()

View File

@@ -33,57 +33,6 @@ configure_file(hal-config.cmake.in ${WPILIB_BINARY_DIR}/hal-config.cmake)
install(FILES ${WPILIB_BINARY_DIR}/hal-config.cmake DESTINATION share/hal) install(FILES ${WPILIB_BINARY_DIR}/hal-config.cmake DESTINATION share/hal)
install(EXPORT hal DESTINATION share/hal) install(EXPORT hal DESTINATION share/hal)
# Java bindings
if(WITH_JAVA)
include(UseJava)
file(GLOB_RECURSE hal_shared_jni_src src/main/native/cpp/jni/*.cpp)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
set(CMAKE_JNI_TARGET true)
add_jar(
hal_jar
${JAVA_SOURCES}
INCLUDE_JARS wpiutil_jar
OUTPUT_NAME wpiHal
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
GENERATE_NATIVE_HEADERS hal_jni_headers
)
set_property(TARGET hal_jar PROPERTY FOLDER "java")
install_jar(hal_jar DESTINATION ${java_lib_dest})
install_jar_exports(TARGETS hal_jar FILE hal_jar.cmake DESTINATION share/hal)
add_library(haljni ${hal_shared_jni_src})
set_target_properties(haljni PROPERTIES OUTPUT_NAME "wpiHaljni")
wpilib_target_warnings(haljni)
target_link_libraries(haljni PUBLIC hal wpiutil)
set_property(TARGET haljni PROPERTY FOLDER "libraries")
target_link_libraries(haljni PRIVATE hal_jni_headers)
add_dependencies(haljni hal_jar)
install(TARGETS haljni EXPORT haljni)
export(TARGETS haljni FILE haljni.cmake NAMESPACE haljni::)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
hal_src_jar
BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
OUTPUT_NAME wpiHal-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET hal_src_jar PROPERTY FOLDER "java")
install_jar(hal_src_jar DESTINATION ${java_lib_dest})
endif()
if(WITH_TESTS) if(WITH_TESTS)
wpilib_add_test(hal src/test/native/cpp) wpilib_add_test(hal src/test/native/cpp)
target_link_libraries(hal_test hal googletest) target_link_libraries(hal_test hal googletest)

View File

@@ -4,6 +4,3 @@ include(CMakeFindDependencyMacro)
@FILENAME_DEP_REPLACE@ @FILENAME_DEP_REPLACE@
include(${SELF_DIR}/hal.cmake) include(${SELF_DIR}/hal.cmake)
if(@WITH_JAVA@)
include(${SELF_DIR}/hal_jar.cmake)
endif()

View File

@@ -39,59 +39,6 @@ configure_file(ntcore-config.cmake.in ${WPILIB_BINARY_DIR}/ntcore-config.cmake)
install(FILES ${WPILIB_BINARY_DIR}/ntcore-config.cmake DESTINATION share/ntcore) install(FILES ${WPILIB_BINARY_DIR}/ntcore-config.cmake DESTINATION share/ntcore)
install(EXPORT ntcore DESTINATION share/ntcore) install(EXPORT ntcore DESTINATION share/ntcore)
# Java bindings
if(WITH_JAVA)
include(UseJava)
file(GLOB QUICKBUF_JAR ${WPILIB_BINARY_DIR}/wpiutil/thirdparty/quickbuf/*.jar)
file(GLOB ntcore_jni_src src/main/native/cpp/jni/*.cpp src/generated/main/native/cpp/jni/*.cpp)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java src/generated/main/java/*.java)
set(CMAKE_JNI_TARGET true)
add_jar(
ntcore_jar
${JAVA_SOURCES}
INCLUDE_JARS wpiutil_jar ${QUICKBUF_JAR} datalog_jar
OUTPUT_NAME ntcore
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
GENERATE_NATIVE_HEADERS ntcore_jni_headers
)
set_property(TARGET ntcore_jar PROPERTY FOLDER "java")
install_jar(ntcore_jar DESTINATION ${java_lib_dest})
install_jar_exports(TARGETS ntcore_jar FILE ntcore_jar.cmake DESTINATION share/ntcore)
add_library(ntcorejni ${ntcore_jni_src})
wpilib_target_warnings(ntcorejni)
target_link_libraries(ntcorejni PUBLIC ntcore wpiutil)
set_property(TARGET ntcorejni PROPERTY FOLDER "libraries")
target_link_libraries(ntcorejni PRIVATE ntcore_jni_headers)
add_dependencies(ntcorejni ntcore_jar)
install(TARGETS ntcorejni EXPORT ntcorejni)
export(TARGETS ntcorejni FILE ntcorejni.cmake NAMESPACE ntcorejni::)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
ntcore_src_jar
BASE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
${CMAKE_CURRENT_SOURCE_DIR}/src/generated/main/java
OUTPUT_NAME ntcore-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET ntcore_src_jar PROPERTY FOLDER "java")
install_jar(ntcore_src_jar DESTINATION ${java_lib_dest})
endif()
add_executable(ntcoredev src/dev/native/cpp/main.cpp) add_executable(ntcoredev src/dev/native/cpp/main.cpp)
wpilib_target_warnings(ntcoredev) wpilib_target_warnings(ntcoredev)
target_link_libraries(ntcoredev ntcore) target_link_libraries(ntcoredev ntcore)

View File

@@ -6,6 +6,3 @@ include(CMakeFindDependencyMacro)
@FILENAME_DEP_REPLACE@ @FILENAME_DEP_REPLACE@
include(${SELF_DIR}/ntcore.cmake) include(${SELF_DIR}/ntcore.cmake)
if(@WITH_JAVA@)
include(${SELF_DIR}/ntcore_jar.cmake)
endif()

View File

@@ -4,49 +4,6 @@ include(SubDirList)
include(CompileWarnings) include(CompileWarnings)
include(AddTest) include(AddTest)
if(WITH_JAVA)
include(UseJava)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
add_jar(
romiVendordep_jar
${JAVA_SOURCES}
INCLUDE_JARS
hal_jar
ntcore_jar
cscore_jar
cameraserver_jar
wpimath_jar
wpiunits_jar
wpiutil_jar
wpilibj_jar
OUTPUT_NAME romiVendordep
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET romiVendordep_jar PROPERTY FOLDER "java")
install_jar(romiVendordep_jar DESTINATION ${java_lib_dest})
install_jar_exports(
TARGETS romiVendordep_jar
FILE romiVendordep_jar.cmake
DESTINATION share/romiVendordep
)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
romiVendordep_src_jar
BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
OUTPUT_NAME romiVendordep-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET romiVendordep_src_jar PROPERTY FOLDER "java")
install_jar(romiVendordep_src_jar DESTINATION ${java_lib_dest})
endif()
file(GLOB_RECURSE romiVendordep_native_src src/main/native/cpp/*.cpp) file(GLOB_RECURSE romiVendordep_native_src src/main/native/cpp/*.cpp)
add_library(romiVendordep ${romiVendordep_native_src}) add_library(romiVendordep ${romiVendordep_native_src})
set_target_properties(romiVendordep PROPERTIES DEBUG_POSTFIX "d") set_target_properties(romiVendordep PROPERTIES DEBUG_POSTFIX "d")

View File

@@ -10,6 +10,3 @@ include(CMakeFindDependencyMacro)
@FILENAME_DEP_REPLACE@ @FILENAME_DEP_REPLACE@
include(${SELF_DIR}/romivendordep.cmake) include(${SELF_DIR}/romivendordep.cmake)
if(@WITH_JAVA@)
include(${SELF_DIR}/romiVendordep_jar.cmake)
endif()

View File

@@ -1,38 +0,0 @@
project(wpiannotations)
# Java bindings
if(WITH_JAVA)
include(UseJava)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
add_jar(
wpiannotations_jar
${JAVA_SOURCES}
OUTPUT_NAME wpiannotations
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET wpiannotations_jar PROPERTY FOLDER "java")
install_jar(wpiannotations_jar DESTINATION ${java_lib_dest})
install_jar_exports(
TARGETS wpiannotations_jar
FILE wpiannotations.cmake
DESTINATION share/wpiannotations
)
install(FILES wpiannotations-config.cmake DESTINATION share/wpiannotations)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
wpiannotations_src_jar
BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
OUTPUT_NAME wpiannotations-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET wpiannotations_src_jar PROPERTY FOLDER "java")
install_jar(wpiannotations_src_jar DESTINATION ${java_lib_dest})
endif()

View File

@@ -1,2 +0,0 @@
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(${SELF_DIR}/wpiannotations.cmake)

View File

@@ -8,14 +8,11 @@ find_dependency(Threads)
@APRILTAG_DEP_REPLACE@ @APRILTAG_DEP_REPLACE@
@CAMERASERVER_DEP_REPLACE@ @CAMERASERVER_DEP_REPLACE@
@CSCORE_DEP_REPLACE@ @CSCORE_DEP_REPLACE@
@COMMANDSV3_DEP_REPLACE@
@DATALOG_DEP_REPLACE@ @DATALOG_DEP_REPLACE@
@HAL_DEP_REPLACE@ @HAL_DEP_REPLACE@
@NTCORE_DEP_REPLACE@ @NTCORE_DEP_REPLACE@
@WPILIBC_DEP_REPLACE@ @WPILIBC_DEP_REPLACE@
@WPILIBNEWCOMMANDS_DEP_REPLACE@ @WPILIBNEWCOMMANDS_DEP_REPLACE@
@WPILIBJ_DEP_REPLACE@
@WPIMATH_DEP_REPLACE@ @WPIMATH_DEP_REPLACE@
@WPINET_DEP_REPLACE@ @WPINET_DEP_REPLACE@
@WPIUNITS_DEP_REPLACE@
@WPIUTIL_DEP_REPLACE@ @WPIUTIL_DEP_REPLACE@

View File

@@ -1,78 +0,0 @@
project(wpilibj)
# Java bindings
if(WITH_JAVA)
include(UseJava)
set(OPENCV_JAVA_INSTALL_DIR ${OpenCV_INSTALL_PATH}/share/java/opencv4)
find_file(
OPENCV_JAR_FILE
NAMES opencv-${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.jar
PATHS
${OPENCV_JAVA_INSTALL_DIR}
${OpenCV_INSTALL_PATH}/bin
${OpenCV_INSTALL_PATH}/share/java
${OpenCV_INSTALL_PATH}/share/OpenCV/java
NO_DEFAULT_PATH
)
configure_file(
src/generate/WPILibVersion.java.in
generated/main/java/org/wpilib/system/WPILibVersion.java
)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java src/generated/main/java/*.java)
file(GLOB EJML_JARS "${WPILIB_BINARY_DIR}/wpimath/thirdparty/ejml/*.jar")
file(GLOB AVAJE_JARS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/avaje/*.jar")
add_jar(
wpilibj_jar
${JAVA_SOURCES}
${CMAKE_CURRENT_BINARY_DIR}/generated/main/java/org/wpilib/system/WPILibVersion.java
INCLUDE_JARS
hal_jar
ntcore_jar
${EJML_JARS}
${AVAJE_JARS}
${OPENCV_JAR_FILE}
cscore_jar
cameraserver_jar
wpimath_jar
wpiunits_jar
wpiutil_jar
datalog_jar
OUTPUT_NAME wpilibj
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET wpilibj_jar PROPERTY FOLDER "java")
install_jar(wpilibj_jar DESTINATION ${java_lib_dest})
install_jar_exports(TARGETS wpilibj_jar FILE wpilibj.cmake DESTINATION share/wpilibj)
install(FILES wpilibj-config.cmake DESTINATION share/wpilibj)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
# Generate version file if it wasn't generated already
if(NOT WITH_JAVA)
configure_file(
src/generate/WPILibVersion.java.in
generated/main/java/org/wpilib/system/WPILibVersion.java
)
endif()
add_source_jar(
wpilibj_src_jar
BASE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
${CMAKE_CURRENT_SOURCE_DIR}/src/generated/main/java
${CMAKE_CURRENT_BINARY_DIR}/generated/main/java
OUTPUT_NAME wpilibj-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET wpilibj_src_jar PROPERTY FOLDER "java")
install_jar(wpilibj_src_jar DESTINATION ${java_lib_dest})
endif()

View File

@@ -1,2 +0,0 @@
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(${SELF_DIR}/wpilibj.cmake)

View File

@@ -3,7 +3,6 @@ project(wpimath)
include(SubDirList) include(SubDirList)
include(CompileWarnings) include(CompileWarnings)
include(AddTest) include(AddTest)
include(DownloadAndCheck)
file( file(
GLOB wpimath_jni_src GLOB wpimath_jni_src
@@ -21,104 +20,6 @@ file(
src/main/native/cpp/jni/optimization/ProblemJNI.cpp src/main/native/cpp/jni/optimization/ProblemJNI.cpp
) )
# Java bindings
if(WITH_JAVA)
include(UseJava)
if(NOT EXISTS "${WPILIB_BINARY_DIR}/wpimath/thirdparty/ejml/ejml-simple-0.44.0.jar")
set(BASE_URL "https://search.maven.org/remotecontent?filepath=")
set(JAR_ROOT "${WPILIB_BINARY_DIR}/wpimath/thirdparty/ejml")
message(STATUS "Downloading EJML jarfiles...")
download_and_check(
"${BASE_URL}org/ejml/ejml-cdense/0.44.0/ejml-cdense-0.44.0.jar"
"${JAR_ROOT}/ejml-cdense-0.44.0.jar"
)
download_and_check(
"${BASE_URL}org/ejml/ejml-core/0.44.0/ejml-core-0.44.0.jar"
"${JAR_ROOT}/ejml-core-0.44.0.jar"
)
download_and_check(
"${BASE_URL}org/ejml/ejml-ddense/0.44.0/ejml-ddense-0.44.0.jar"
"${JAR_ROOT}/ejml-ddense-0.44.0.jar"
)
download_and_check(
"${BASE_URL}org/ejml/ejml-dsparse/0.44.0/ejml-dsparse-0.44.0.jar"
"${JAR_ROOT}/ejml-dsparse-0.44.0.jar"
)
download_and_check(
"${BASE_URL}org/ejml/ejml-fdense/0.44.0/ejml-fdense-0.44.0.jar"
"${JAR_ROOT}/ejml-fdense-0.44.0.jar"
)
download_and_check(
"${BASE_URL}org/ejml/ejml-simple/0.44.0/ejml-simple-0.44.0.jar"
"${JAR_ROOT}/ejml-simple-0.44.0.jar"
)
download_and_check(
"${BASE_URL}org/ejml/ejml-zdense/0.44.0/ejml-zdense-0.44.0.jar"
"${JAR_ROOT}/ejml-zdense-0.44.0.jar"
)
message(STATUS "All files downloaded.")
endif()
file(GLOB EJML_JARS "${WPILIB_BINARY_DIR}/wpimath/thirdparty/ejml/*.jar")
file(GLOB AVAJE_JARS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/avaje/*.jar")
file(GLOB QUICKBUF_JAR ${WPILIB_BINARY_DIR}/wpiutil/thirdparty/quickbuf/*.jar)
set(CMAKE_JNI_TARGET true)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java src/generated/main/java/*.java)
add_jar(
wpimath_jar
${JAVA_SOURCES}
INCLUDE_JARS
wpiutil_jar
wpiunits_jar
wpiannotations_jar
${EJML_JARS}
${AVAJE_JARS}
${QUICKBUF_JAR}
OUTPUT_NAME wpimath
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
GENERATE_NATIVE_HEADERS wpimath_jni_headers
)
set_property(TARGET wpimath_jar PROPERTY FOLDER "java")
install_jar(wpimath_jar DESTINATION ${java_lib_dest})
install_jar_exports(TARGETS wpimath_jar FILE wpimath_jar.cmake DESTINATION share/wpimath)
add_library(wpimathjni ${wpimath_jni_src})
wpilib_target_warnings(wpimathjni)
target_link_libraries(wpimathjni PUBLIC wpimath)
set_property(TARGET wpimathjni PROPERTY FOLDER "libraries")
target_link_libraries(wpimathjni PRIVATE wpimath_jni_headers)
add_dependencies(wpimathjni wpimath_jar)
install(TARGETS wpimathjni EXPORT wpimathjni)
export(TARGETS wpimathjni FILE wpimathjni.cmake NAMESPACE wpimathjni::)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
wpimath_src_jar
BASE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
${CMAKE_CURRENT_SOURCE_DIR}/src/generated/main/java
OUTPUT_NAME wpimath-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET wpimath_src_jar PROPERTY FOLDER "java")
install_jar(wpimath_src_jar DESTINATION ${java_lib_dest})
endif()
file( file(
GLOB_RECURSE wpimath_native_src GLOB_RECURSE wpimath_native_src
src/main/native/cpp/*.cpp src/main/native/cpp/*.cpp

View File

@@ -8,8 +8,3 @@ endif()
@FILENAME_DEP_REPLACE@ @FILENAME_DEP_REPLACE@
include(${SELF_DIR}/wpimath.cmake) include(${SELF_DIR}/wpimath.cmake)
if(@WITH_JAVA@)
@WPIUNITS_DEP_REPLACE@
@FILENAME_DEP_REPLACE@
include(${SELF_DIR}/wpimath_jar.cmake)
endif()

View File

@@ -7,54 +7,6 @@ include(AddTest)
file(GLOB wpinet_jni_src src/main/native/cpp/jni/WPINetJNI.cpp) file(GLOB wpinet_jni_src src/main/native/cpp/jni/WPINetJNI.cpp)
# Java bindings
if(WITH_JAVA)
include(UseJava)
set(CMAKE_JNI_TARGET true)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
add_jar(
wpinet_jar
${JAVA_SOURCES}
INCLUDE_JARS wpiutil_jar
OUTPUT_NAME wpinet
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
GENERATE_NATIVE_HEADERS wpinet_jni_headers
)
set_property(TARGET wpinet_jar PROPERTY FOLDER "java")
install_jar(wpinet_jar DESTINATION ${java_lib_dest})
install_jar_exports(TARGETS wpinet_jar FILE wpinet_jar.cmake DESTINATION share/wpinet)
add_library(wpinetjni ${wpinet_jni_src})
wpilib_target_warnings(wpinetjni)
target_link_libraries(wpinetjni PUBLIC wpinet)
set_property(TARGET wpinetjni PROPERTY FOLDER "libraries")
target_link_libraries(wpinetjni PRIVATE wpinet_jni_headers)
add_dependencies(wpinetjni wpinet_jar)
install(TARGETS wpinetjni EXPORT wpinetjni)
export(TARGETS wpinetjni FILE wpinetjni.cmake NAMESPACE wpinetjni::)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
wpinet_src_jar
BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
OUTPUT_NAME wpinet-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET wpinet_src_jar PROPERTY FOLDER "java")
install_jar(wpinet_src_jar DESTINATION ${java_lib_dest})
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)

View File

@@ -5,6 +5,3 @@ include(CMakeFindDependencyMacro)
@FILENAME_DEP_REPLACE@ @FILENAME_DEP_REPLACE@
include(${SELF_DIR}/wpinet.cmake) include(${SELF_DIR}/wpinet.cmake)
if(@WITH_JAVA@)
include(${SELF_DIR}/wpinet_jar.cmake)
endif()

View File

@@ -1,36 +0,0 @@
project(wpiunits)
# Java bindings
if(WITH_JAVA)
include(UseJava)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java src/generated/main/java/*.java)
add_jar(
wpiunits_jar
${JAVA_SOURCES}
OUTPUT_NAME wpiunits
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET wpiunits_jar PROPERTY FOLDER "java")
install_jar(wpiunits_jar DESTINATION ${java_lib_dest})
install_jar_exports(TARGETS wpiunits_jar FILE wpiunits.cmake DESTINATION share/wpiunits)
install(FILES wpiunits-config.cmake DESTINATION share/wpiunits)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
wpiunits_src_jar
BASE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
${CMAKE_CURRENT_SOURCE_DIR}/src/generated/main/java
OUTPUT_NAME wpiunits-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET wpiunits_src_jar PROPERTY FOLDER "java")
install_jar(wpiunits_src_jar DESTINATION ${java_lib_dest})
endif()

View File

@@ -1,2 +0,0 @@
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(${SELF_DIR}/wpiunits.cmake)

View File

@@ -4,109 +4,9 @@ include(SubDirList)
include(GenResources) include(GenResources)
include(CompileWarnings) include(CompileWarnings)
include(AddTest) include(AddTest)
include(DownloadAndCheck)
file(GLOB wpiutil_jni_src src/main/native/cpp/jni/WPIUtilJNI.cpp) file(GLOB wpiutil_jni_src src/main/native/cpp/jni/WPIUtilJNI.cpp)
# Java bindings
if(WITH_JAVA)
include(UseJava)
if(NOT EXISTS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/avaje/avaje-jsonb-3.11.jar")
set(BASE_URL "https://search.maven.org/remotecontent?filepath=")
set(JAR_ROOT "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/avaje")
message(STATUS "Downloading Avaje jarfiles...")
download_and_check(
"${BASE_URL}io/avaje/avaje-jsonb/3.11/avaje-jsonb-3.11.jar"
"${JAR_ROOT}/avaje-jsonb-3.11.jar"
)
download_and_check(
"${BASE_URL}io/avaje/avaje-json-core/3.11/avaje-json-core-3.11.jar"
"${JAR_ROOT}/avaje-json-core-3.11.jar"
)
download_and_check(
"${BASE_URL}io/avaje/avaje-jsonb-inject-plugin/3.11/avaje-jsonb-inject-plugin-3.11.jar"
"${JAR_ROOT}/avaje-jsonb-inject-plugin-3.11.jar"
)
download_and_check(
"${BASE_URL}io/avaje/avaje-jsonb-generator/3.11/avaje-jsonb-generator-3.11.jar"
"${JAR_ROOT}/avaje-jsonb-generator-3.11.jar"
)
download_and_check(
"${BASE_URL}io/avaje/avaje-spi-service/2.16/avaje-spi-service-2.16.jar"
"${JAR_ROOT}/avaje-spi-service-2.16.jar"
)
download_and_check(
"${BASE_URL}io/avaje/avaje-spi-core/2.16/avaje-spi-core-2.16.jar"
"${JAR_ROOT}/avaje-spi-core-2.16.jar"
)
message(STATUS "All files downloaded.")
endif()
file(GLOB AVAJE_JARS ${WPILIB_BINARY_DIR}/wpiutil/thirdparty/avaje/*.jar)
if(NOT EXISTS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/quickbuf/quickbuf-runtime-1.4.jar")
set(BASE_URL "https://search.maven.org/remotecontent?filepath=")
set(JAR_ROOT "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/quickbuf")
message(STATUS "Downloading Quickbuf jarfile...")
download_and_check(
"${BASE_URL}us/hebi/quickbuf/quickbuf-runtime/1.4/quickbuf-runtime-1.4.jar"
"${JAR_ROOT}/quickbuf-runtime-1.4.jar"
)
message(STATUS "Downloaded.")
endif()
file(GLOB QUICKBUF_JAR ${WPILIB_BINARY_DIR}/wpiutil/thirdparty/quickbuf/*.jar)
set(CMAKE_JNI_TARGET true)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
add_jar(
wpiutil_jar
${JAVA_SOURCES}
INCLUDE_JARS ${AVAJE_JARS} ${QUICKBUF_JAR}
OUTPUT_NAME wpiutil
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
GENERATE_NATIVE_HEADERS wpiutil_jni_headers
)
set_property(TARGET wpiutil_jar PROPERTY FOLDER "java")
install_jar(wpiutil_jar DESTINATION ${java_lib_dest})
install_jar_exports(TARGETS wpiutil_jar FILE wpiutil_jar.cmake DESTINATION share/wpiutil)
add_library(wpiutiljni ${wpiutil_jni_src})
wpilib_target_warnings(wpiutiljni)
target_link_libraries(wpiutiljni PUBLIC wpiutil)
set_property(TARGET wpiutiljni PROPERTY FOLDER "libraries")
target_link_libraries(wpiutiljni PRIVATE wpiutil_jni_headers)
add_dependencies(wpiutiljni wpiutil_jar)
install(TARGETS wpiutiljni EXPORT wpiutiljni)
export(TARGETS wpiutiljni FILE wpiutiljni.cmake NAMESPACE wpiutiljni::)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
wpiutil_src_jar
BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
OUTPUT_NAME wpiutil-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET wpiutil_src_jar PROPERTY FOLDER "java")
install_jar(wpiutil_src_jar DESTINATION ${java_lib_dest})
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON) set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)

View File

@@ -10,6 +10,3 @@ endif()
@FILENAME_DEP_REPLACE@ @FILENAME_DEP_REPLACE@
include(${SELF_DIR}/wpiutil.cmake) include(${SELF_DIR}/wpiutil.cmake)
if(@WITH_JAVA@)
include(${SELF_DIR}/wpiutil_jar.cmake)
endif()

View File

@@ -4,49 +4,6 @@ include(SubDirList)
include(CompileWarnings) include(CompileWarnings)
include(AddTest) include(AddTest)
if(WITH_JAVA)
include(UseJava)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
add_jar(
xrpVendordep_jar
${JAVA_SOURCES}
INCLUDE_JARS
hal_jar
ntcore_jar
cscore_jar
cameraserver_jar
wpimath_jar
wpiunits_jar
wpiutil_jar
wpilibj_jar
OUTPUT_NAME xrpVendordep
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET xrpVendordep_jar PROPERTY FOLDER "java")
install_jar(xrpVendordep_jar DESTINATION ${java_lib_dest})
install_jar_exports(
TARGETS xrpVendordep_jar
FILE xrpVendordep_jar.cmake
DESTINATION share/xrpVendordep
)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
xrpVendordep_src_jar
BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
OUTPUT_NAME xrpVendordep-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET xrpVendordep_src_jar PROPERTY FOLDER "java")
install_jar(xrpVendordep_src_jar DESTINATION ${java_lib_dest})
endif()
file(GLOB_RECURSE xrpVendordep_native_src src/main/native/cpp/*.cpp) file(GLOB_RECURSE xrpVendordep_native_src src/main/native/cpp/*.cpp)
add_library(xrpVendordep ${xrpVendordep_native_src}) add_library(xrpVendordep ${xrpVendordep_native_src})
set_target_properties(xrpVendordep PROPERTIES DEBUG_POSTFIX "d") set_target_properties(xrpVendordep PROPERTIES DEBUG_POSTFIX "d")

View File

@@ -10,6 +10,3 @@ include(CMakeFindDependencyMacro)
@FILENAME_DEP_REPLACE@ @FILENAME_DEP_REPLACE@
include(${SELF_DIR}/xrpvendordep.cmake) include(${SELF_DIR}/xrpvendordep.cmake)
if(@WITH_JAVA@)
include(${SELF_DIR}/xrpVendordep_jar.cmake)
endif()