From 2107e19bbd8bbc796a253227096d23839bf56846 Mon Sep 17 00:00:00 2001 From: thatcomputerguy0101 Date: Sun, 23 Nov 2025 19:49:59 -0500 Subject: [PATCH 1/8] Add MacOS support --- CMakeLists.txt | 1 + mrcal | 2 +- src/mrcal_test.cpp | 2 +- src/mrcal_wrapper.cpp | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d5bda09..ba86b6b 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}") 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 From 72303af22dc2d3c6bdc5333910f689f8603af087 Mon Sep 17 00:00:00 2001 From: thatcomputerguy0101 Date: Wed, 26 Nov 2025 16:09:45 -0500 Subject: [PATCH 2/8] Add MacOS to build action --- .github/workflows/main.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f54f603..4e7b729 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,6 +24,11 @@ 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: osxarm64 + - os: macos-latest + arch-name: osxx86-64 + extra-flags: -DCMAKE_OSX_ARCHITECTURES=x86-64 runs-on: ${{ matrix.os }} name: "mrcal-jni - Build - ${{ matrix.arch-name }}" From 4ae387019273dea477d6085b572f4f5211a00be4 Mon Sep 17 00:00:00 2001 From: thatcomputerguy0101 Date: Wed, 26 Nov 2025 16:40:02 -0500 Subject: [PATCH 3/8] Use Intel Mac runner to build x86 library --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4e7b729..69cd9ab 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,9 +26,8 @@ jobs: extra-flags: -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl - os: macos-latest arch-name: osxarm64 - - os: macos-latest + - os: macos-15-intel arch-name: osxx86-64 - extra-flags: -DCMAKE_OSX_ARCHITECTURES=x86-64 runs-on: ${{ matrix.os }} name: "mrcal-jni - Build - ${{ matrix.arch-name }}" From 1eea251a37269068f0a7750fa4ba415f7e5f7909 Mon Sep 17 00:00:00 2001 From: thatcomputerguy0101 Date: Wed, 26 Nov 2025 16:56:50 -0500 Subject: [PATCH 4/8] Build universal MacOS library --- .github/workflows/main.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 69cd9ab..61aff65 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,9 +25,8 @@ jobs: arch-name: windowsx86-64 extra-flags: -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl - os: macos-latest - arch-name: osxarm64 - - os: macos-15-intel - arch-name: osxx86-64 + arch-name: osxuniversal + extra-flags: -DMAKE_OSX_ARCHITECTURES="arm64;x86_64" runs-on: ${{ matrix.os }} name: "mrcal-jni - Build - ${{ matrix.arch-name }}" From d262531908c01f968d57d974828219a11032bc97 Mon Sep 17 00:00:00 2001 From: thatcomputerguy0101 Date: Wed, 26 Nov 2025 23:37:59 -0500 Subject: [PATCH 5/8] Add List::MoreUtils install to macOS runner --- .github/workflows/main.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 61aff65..09e080f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -53,6 +53,11 @@ jobs: sudo apt update sudo apt-get install -y cmake ninja-build gcc g++ liblist-moreutils-perl + - name: Install deps + if: runner.os == 'macOS' + run: | + sudo cpan -i List::MoreUtils + - 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. # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type From 3515ed38eced2cf9c6ff3f791ef141de18e664cf Mon Sep 17 00:00:00 2001 From: thatcomputerguy0101 Date: Wed, 26 Nov 2025 23:46:01 -0500 Subject: [PATCH 6/8] Condense install deps action step --- .github/workflows/main.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 09e080f..5a365b0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,15 +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 - - - name: Install deps - if: runner.os == 'macOS' - run: | - sudo cpan -i List::MoreUtils + 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. From 1b7dc1b2b62827aec894ce3d09ec8d92068b4001 Mon Sep 17 00:00:00 2001 From: Alan Everett Date: Sat, 29 Nov 2025 05:08:44 -0500 Subject: [PATCH 7/8] Fix typo pt.2 Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com> --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5a365b0..d069a77 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,7 +26,7 @@ jobs: extra-flags: -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl - os: macos-latest arch-name: osxuniversal - extra-flags: -DMAKE_OSX_ARCHITECTURES="arm64;x86_64" + extra-flags: -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" runs-on: ${{ matrix.os }} name: "mrcal-jni - Build - ${{ matrix.arch-name }}" From d91d3691b7f616d491df81cc0c299f1016261f8d Mon Sep 17 00:00:00 2001 From: thatcomputerguy0101 Date: Sat, 29 Nov 2025 14:19:40 -0500 Subject: [PATCH 8/8] Use Apple Accelerate on macOS instead of OpenBLAS --- CMakeLists.txt | 77 ++++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba86b6b..a02ce96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,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 @@ -118,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)