diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index f54f603..d069a77 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -24,6 +24,9 @@ jobs:
- os: windows-latest
arch-name: windowsx86-64
extra-flags: -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl
+ - os: macos-latest
+ arch-name: osxuniversal
+ extra-flags: -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
runs-on: ${{ matrix.os }}
name: "mrcal-jni - Build - ${{ matrix.arch-name }}"
@@ -45,10 +48,14 @@ jobs:
distribution: temurin
- name: Install deps
- if: runner.os == 'Linux'
+ if: runner.os == 'Linux' || runner.os == 'macOS'
run: |
- sudo apt update
- sudo apt-get install -y cmake ninja-build gcc g++ liblist-moreutils-perl
+ if [ $RUNNER_OS == "Linux" ]; then
+ sudo apt update
+ sudo apt-get install -y cmake ninja-build gcc g++ liblist-moreutils-perl
+ elif [ $RUNNER_OS == "macOS" ]; then
+ sudo cpan -i List::MoreUtils
+ fi
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d5bda09..a02ce96 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,6 +41,7 @@ FetchContent_MakeAvailable(opencv_header)
file(GLOB_RECURSE OPENCV_LIB_PATH
"${opencv_lib_SOURCE_DIR}/**/*.lib"
"${opencv_lib_SOURCE_DIR}/**/*.so*"
+ "${opencv_lib_SOURCE_DIR}/**/*.*.dylib"
)
SET(OPENCV_INCLUDE_PATH ${opencv_header_SOURCE_DIR})
message("Depending on opencv ${OPENCV_LIB_PATH}")
@@ -63,39 +64,46 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Silence OpenBLAS/LAPACK warnings
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
-set(BLA_VENDOR OpenBLAS)
-fetchcontent_declare(
- BLAS
- GIT_REPOSITORY https://github.com/OpenMathLib/OpenBLAS.git
- GIT_TAG v0.3.30
- OVERRIDE_FIND_PACKAGE
-)
-fetchcontent_makeavailable(BLAS)
-
-if(TARGET openblas)
- set(OPENBLAS_TARGET openblas)
- message(STATUS "Using openblas target")
-elseif(TARGET OpenBLAS)
- set(OPENBLAS_TARGET OpenBLAS)
- message(STATUS "Using OpenBLAS target")
-elseif(TARGET libopenblas)
- set(OPENBLAS_TARGET libopenblas)
- message(STATUS "Using libopenblas target")
-else()
- # Fallback: find the library file manually
- find_library(OPENBLAS_LIB
- NAMES openblas libopenblas
- PATHS
- ${openblas_external_BINARY_DIR}
- ${openblas_external_BINARY_DIR}/lib
- ${openblas_external_BINARY_DIR}/lib/Release
- NO_DEFAULT_PATH
- REQUIRED
+if(NOT APPLE)
+ set(BLA_VENDOR OpenBLAS)
+ fetchcontent_declare(
+ BLAS
+ GIT_REPOSITORY https://github.com/OpenMathLib/OpenBLAS.git
+ GIT_TAG v0.3.30
+ OVERRIDE_FIND_PACKAGE
)
- message(STATUS "Using OpenBLAS library file: ${OPENBLAS_LIB}")
- add_library(openblas_imported STATIC IMPORTED)
- set_target_properties(openblas_imported PROPERTIES IMPORTED_LOCATION ${OPENBLAS_LIB})
- set(OPENBLAS_TARGET openblas_imported)
+ fetchcontent_makeavailable(BLAS)
+
+ if(TARGET openblas)
+ set(OPENBLAS_TARGET openblas)
+ message(STATUS "Using openblas target")
+ elseif(TARGET OpenBLAS)
+ set(OPENBLAS_TARGET OpenBLAS)
+ message(STATUS "Using OpenBLAS target")
+ elseif(TARGET libopenblas)
+ set(OPENBLAS_TARGET libopenblas)
+ message(STATUS "Using libopenblas target")
+ else()
+ # Fallback: find the library file manually
+ find_library(OPENBLAS_LIB
+ NAMES openblas libopenblas
+ PATHS
+ ${openblas_external_BINARY_DIR}
+ ${openblas_external_BINARY_DIR}/lib
+ ${openblas_external_BINARY_DIR}/lib/Release
+ NO_DEFAULT_PATH
+ REQUIRED
+ )
+ message(STATUS "Using OpenBLAS library file: ${OPENBLAS_LIB}")
+ add_library(openblas_imported STATIC IMPORTED)
+ set_target_properties(openblas_imported PROPERTIES IMPORTED_LOCATION ${OPENBLAS_LIB})
+ set(OPENBLAS_TARGET openblas_imported)
+ endif()
+else()
+ set ( BLA_VENDOR Apple )
+ add_compile_definitions(ACCELERATE_NEW_LAPACK=1)
+ add_compile_definitions(ACCELERATE_LAPACK_ILP64=1)
+ find_package ( BLAS )
endif()
# Configure SuiteSparse to use BLAS
@@ -117,7 +125,11 @@ fetchcontent_makeavailable(SuiteSparse)
get_target_property(CHOLMOD_LIBS SuiteSparse::CHOLMOD_static INTERFACE_LINK_LIBRARIES)
message(STATUS "CHOLMOD links to: ${CHOLMOD_LIBS}")
-message(STATUS "BLAS is at: ${OPENBLAS_TARGET}")
+if(NOT APPLE)
+ message(STATUS "BLAS is at: ${OPENBLAS_TARGET}")
+else()
+ message(STATUS "BLAS is using Apple Accelerate")
+endif()
# And pull in JNI
find_package(JNI)
diff --git a/mrcal b/mrcal
index 0d5426b..a980307 160000
--- a/mrcal
+++ b/mrcal
@@ -1 +1 @@
-Subproject commit 0d5426b5851be80dd8e51470a0784a73565a3006
+Subproject commit a980307d7ad95a0595a3da149ea710aed588c163
diff --git a/src/mrcal_test.cpp b/src/mrcal_test.cpp
index 0c70686..9a63d68 100644
--- a/src/mrcal_test.cpp
+++ b/src/mrcal_test.cpp
@@ -15,7 +15,7 @@
* along with this program. If not, see .
*/
-#include
+#include
#include
#include
diff --git a/src/mrcal_wrapper.cpp b/src/mrcal_wrapper.cpp
index 2be5add..983d8cf 100644
--- a/src/mrcal_wrapper.cpp
+++ b/src/mrcal_wrapper.cpp
@@ -15,7 +15,7 @@
#include "mrcal_wrapper.h"
-#include
+#include
#include
#include