@@ -22,51 +22,46 @@ include(FetchContent)
2222# https://github.com/PhotonVision/photonvision/blob/main/build.gradle
2323set (OPENCV_YEAR "frc2025" )
2424set (OPENCV_VERSION "4.10.0-3" )
25+ set (WPIMATH_VERSION "2026.2.1" )
2526
2627# type can be "", "debug", "static", or "staticdebug"
2728set (OPENCV_TYPE "" )
2829
29- # Check if OPENCV_ARCH is set to determine OpenCV source
30- if (DEFINED OPENCV_ARCH AND NOT OPENCV_ARCH STREQUAL "" )
31- # Download opencv from FRC maven repository
32- message (STATUS "Using FRC OpenCV for architecture: ${OPENCV_ARCH} " )
30+ message (STATUS "Using FRC OpenCV for architecture: ${OPENCV_ARCH} " )
3331
34- FetchContent_Declare (
35- opencv_lib
36- URL
37- https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/thirdparty/${OPENCV_YEAR} /opencv/opencv-cpp/${OPENCV_VERSION} /opencv-cpp-${OPENCV_VERSION} -${OPENCV_ARCH}${OPENCV_TYPE} .zip
38- )
39- FetchContent_MakeAvailable (opencv_lib)
32+ FetchContent_Declare (
33+ opencv_lib
34+ URL
35+ https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/thirdparty/${OPENCV_YEAR} /opencv/opencv-cpp/${OPENCV_VERSION} /opencv-cpp-${OPENCV_VERSION} -${OPENCV_ARCH}${OPENCV_TYPE} .zip
36+ )
37+ FetchContent_MakeAvailable (opencv_lib)
4038
41- # download OpenCV headers
42- FetchContent_Declare (
43- opencv_header
44- URL
45- https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/thirdparty/${OPENCV_YEAR} /opencv/opencv-cpp/${OPENCV_VERSION} /opencv-cpp-${OPENCV_VERSION} -headers.zip
46- )
47- FetchContent_MakeAvailable (opencv_header)
48-
49- # This probably doesn't work great with shared libraries, but I don't care about those right now
50- file (
51- GLOB_RECURSE OPENCV_LIB_PATH
52- "${opencv_lib_SOURCE_DIR} /**/*.lib"
53- "${opencv_lib_SOURCE_DIR} /**/*.so*"
54- "${opencv_lib_SOURCE_DIR} /**/*.*.dylib"
55- )
56- set (OPENCV_INCLUDE_PATH ${opencv_header_SOURCE_DIR} )
57- set (OPENCV_LIBRARIES ${OPENCV_LIB_PATH} )
58- message (STATUS "Using FRC OpenCV libraries: ${OPENCV_LIB_PATH} " )
59- else ()
60- # Use system OpenCV
61- message (STATUS "OPENCV_ARCH not set, using system OpenCV" )
62- find_package (OpenCV REQUIRED )
63-
64- set (OPENCV_INCLUDE_PATH ${OpenCV_INCLUDE_DIRS} )
65- set (OPENCV_LIBRARIES ${OpenCV_LIBS} )
66- message (STATUS "Found system OpenCV version: ${OpenCV_VERSION} " )
67- message (STATUS "OpenCV include dirs: ${OpenCV_INCLUDE_DIRS} " )
68- message (STATUS "OpenCV libraries: ${OpenCV_LIBS} " )
69- endif ()
39+ # download OpenCV headers
40+ FetchContent_Declare (
41+ opencv_header
42+ URL
43+ https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/thirdparty/${OPENCV_YEAR} /opencv/opencv-cpp/${OPENCV_VERSION} /opencv-cpp-${OPENCV_VERSION} -headers.zip
44+ )
45+ FetchContent_MakeAvailable (opencv_header)
46+
47+ file (
48+ GLOB_RECURSE OPENCV_LIB_PATH
49+ "${opencv_lib_SOURCE_DIR} /**/*.lib"
50+ "${opencv_lib_SOURCE_DIR} /**/*.so*"
51+ "${opencv_lib_SOURCE_DIR} /**/*.*.dylib"
52+ )
53+ set (OPENCV_INCLUDE_PATH ${opencv_header_SOURCE_DIR} )
54+ set (OPENCV_LIBRARIES ${OPENCV_LIB_PATH} )
55+ message (STATUS "Using FRC OpenCV libraries: ${OPENCV_LIB_PATH} " )
56+
57+ # Also download wpimath
58+ FetchContent_Declare (
59+ wpimath_header
60+ URL
61+ https://frcmaven.wpi.edu/artifactory/release/edu/wpi/first/wpimath/wpimath-cpp/${WPIMATH_VERSION} /wpimath-cpp-${WPIMATH_VERSION} -headers.zip
62+ )
63+ FetchContent_MakeAvailable (wpimath_header)
64+ set (WPIMATH_INCLUDE_PATH ${wpimath_header_SOURCE_DIR} )
7065
7166# Openblas/suitesparse/friends
7267# From https://github.com/wpilibsuite/thirdparty-ceres/blob/main/CMakeLists.txt
@@ -193,7 +188,7 @@ add_library(mrcal_jni SHARED ${INCLUDE_HPP} ${SRC_HPP} ${SRC_CPP})
193188target_include_directories (
194189 mrcal_jni
195190 SYSTEM
196- PUBLIC ${JNI_INCLUDE_DIRS} ${OPENCV_INCLUDE_PATH} mrcal libdogleg
191+ PUBLIC ${JNI_INCLUDE_DIRS} ${OPENCV_INCLUDE_PATH} mrcal libdogleg ${WPIMATH_INCLUDE_PATH}
197192)
198193add_dependencies (mrcal_jni generate_minimath )
199194
@@ -206,7 +201,6 @@ target_link_libraries(
206201 ${OPENBLAS_TARGET}
207202 lapack
208203 fmt
209- Eigen3::Eigen # TODO link against wpilib or hide these symbols
210204)
211205
212206# vnlog for the test script
@@ -216,11 +210,9 @@ target_include_directories(vnlog SYSTEM PUBLIC ${PROJECT_SOURCE_DIR}/vnlog)
216210
217211# Test script for checking our linker
218212
219- find_package (Eigen3 REQUIRED NO_MODULE )
220-
221213add_executable (mrcal_jni_test src/mrcal_test.cpp )
222214
223- target_link_libraries (mrcal_jni_test PUBLIC mrcal_jni Eigen3::Eigen )
215+ target_link_libraries (mrcal_jni_test PUBLIC mrcal_jni )
224216
225217target_include_directories (
226218 mrcal_jni_test
0 commit comments