@@ -14,16 +14,21 @@ if(WITH_ASAN)
1414 add_compile_options (-fsanitize=address -g -Wall -fsanitize=undefined)
1515endif ()
1616
17+ # Include FetchContent module for downloading dependencies
18+ include (FetchContent)
19+
20+ # OpenCV configuration
1721# Keep this in sync with build.gradle and with
1822# https://github.com/PhotonVision/photonvision/blob/main/build.gradle
1923set (OPENCV_YEAR "frc2025" )
2024set (OPENCV_VERSION "4.10.0-3" )
25+ set (WPIMATH_VERSION "2026.2.1" )
2126
2227# type can be "", "debug", "static", or "staticdebug"
2328set (OPENCV_TYPE "" )
2429
25- # Download opencv, and save the path
26- include (FetchContent)
30+ message ( STATUS "Using FRC OpenCV for architecture: ${OPENCV_ARCH} " )
31+
2732FetchContent_Declare(
2833 opencv_lib
2934 URL
@@ -39,15 +44,24 @@ FetchContent_Declare(
3944)
4045FetchContent_MakeAvailable(opencv_header)
4146
42- # This probably doesn't work great with shared libraries, but I don't care about those right now
4347file (
4448 GLOB_RECURSE OPENCV_LIB_PATH
4549 "${opencv_lib_SOURCE_DIR} /**/*.lib"
4650 "${opencv_lib_SOURCE_DIR} /**/*.so*"
4751 "${opencv_lib_SOURCE_DIR} /**/*.*.dylib"
4852)
4953set (OPENCV_INCLUDE_PATH ${opencv_header_SOURCE_DIR} )
50- message ("Depending on opencv ${OPENCV_LIB_PATH} " )
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} )
5165
5266# Openblas/suitesparse/friends
5367# From https://github.com/wpilibsuite/thirdparty-ceres/blob/main/CMakeLists.txt
@@ -136,6 +150,7 @@ set(SRC_HPP)
136150set (SRC_CPP
137151 src/mrcal_jni.h
138152 src/mrcal_wrapper.cpp
153+ src/mrcal-uncertainty.cpp
139154 src/mrcal_jni.cpp
140155 libdogleg/dogleg.c
141156 mrcal/mrcal.c
@@ -173,17 +188,23 @@ add_library(mrcal_jni SHARED ${INCLUDE_HPP} ${SRC_HPP} ${SRC_CPP})
173188target_include_directories (
174189 mrcal_jni
175190 SYSTEM
176- PUBLIC ${JNI_INCLUDE_DIRS} ${OPENCV_INCLUDE_PATH} mrcal libdogleg
191+ PUBLIC
192+ ${JNI_INCLUDE_DIRS}
193+ ${OPENCV_INCLUDE_PATH}
194+ mrcal
195+ libdogleg
196+ ${WPIMATH_INCLUDE_PATH}
177197)
178198add_dependencies (mrcal_jni generate_minimath)
179199
180200target_link_libraries (
181201 mrcal_jni
182- ${OPENCV_LIB_PATH}
183- SuiteSparse::CHOLMOD_static
184- SuiteSparse::SuiteSparseConfig_static
185- ${OPENBLAS_TARGET}
186- lapack
202+ PUBLIC
203+ ${OPENCV_LIBRARIES}
204+ SuiteSparse::CHOLMOD_static
205+ SuiteSparse::SuiteSparseConfig_static
206+ ${OPENBLAS_TARGET}
207+ lapack
187208)
188209
189210# vnlog for the test script
@@ -192,15 +213,18 @@ add_library(vnlog STATIC ${VNLOG_SRC_CPP})
192213target_include_directories (vnlog SYSTEM PUBLIC ${PROJECT_SOURCE_DIR} /vnlog)
193214
194215# Test script for checking our linker
216+
195217add_executable (mrcal_jni_test src/mrcal_test.cpp)
218+
196219target_link_libraries (mrcal_jni_test PUBLIC mrcal_jni)
220+
197221target_include_directories (
198222 mrcal_jni_test
199223 SYSTEM
200224 PRIVATE ${PROJECT_SOURCE_DIR} /vnlog
201225)
202226add_dependencies (mrcal_jni_test mrcal_jni vnlog)
203- target_link_libraries (mrcal_jni_test PRIVATE ${OpenCV_LIBS } vnlog)
227+ target_link_libraries (mrcal_jni_test PRIVATE ${OPENCV_LIBRARIES } vnlog)
204228
205229if (WITH_ASAN)
206230 target_link_libraries (
0 commit comments