From 68fee2759e9864d14ca8c359dec8f20ca1d95fc4 Mon Sep 17 00:00:00 2001 From: Gold856 <117957790+Gold856@users.noreply.github.com> Date: Fri, 16 Aug 2024 00:47:45 -0400 Subject: [PATCH] [build] CMake: disable Java components by default --- .github/workflows/cmake.yml | 2 +- CMakeLists.txt | 11 +++++++++-- README-CMAKE.md | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 782e5a485e3..8eb0e0ec65d 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -15,7 +15,7 @@ jobs: - os: ubuntu-22.04 name: Linux container: wpilib/roborio-cross-ubuntu:2024-22.04 - flags: "-DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON" + flags: "-DCMAKE_BUILD_TYPE=Release -DWITH_JAVA=ON -DWITH_EXAMPLES=ON" - os: macOS-14 name: macOS container: "" diff --git a/CMakeLists.txt b/CMakeLists.txt index 56da021f8c7..c82795fd6a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,7 @@ endif() set(WPILIB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) +include(CMakeDependentOption) include(CPack) include(OptionValidation) @@ -55,12 +56,18 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # 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(WITH_JAVA "Include Java and JNI in the build" ON) +option(WITH_JAVA "Include Java and JNI in the build" OFF) option(WITH_JAVA_SOURCE "Build Java source jars" ${WITH_JAVA}) option(WITH_CSCORE "Build cscore (needs OpenCV)" ON) option(WITH_NTCORE "Build ntcore" ON) option(WITH_WPIMATH "Build wpimath" ON) -option(WITH_WPIUNITS "Build wpiunits" 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_EXAMPLES "Build examples" OFF) option(WITH_TESTS "Build unit tests (requires internet connection)" ON) diff --git a/README-CMAKE.md b/README-CMAKE.md index 33602cded93..d7096283cd9 100644 --- a/README-CMAKE.md +++ b/README-CMAKE.md @@ -52,7 +52,7 @@ The following build options are available: * This option will build C++ examples. * `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. -* `WITH_JAVA` (ON Default) +* `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. @@ -66,7 +66,7 @@ The following build options are available: * 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 the roboRIO. * `WITH_WPIMATH` (ON Default) * This option will build the wpimath library. This option must be on to build wpilib. -* `WITH_WPIUNITS` (ON Default) +* `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!