Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -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.
Expand Down
78 changes: 45 additions & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion mrcal
Submodule mrcal updated 1 files
+1 −1 mrcal-image.c
2 changes: 1 addition & 1 deletion src/mrcal_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <malloc.h>
#include <stdlib.h>
#include <stdint.h>

#include <algorithm>
Expand Down
2 changes: 1 addition & 1 deletion src/mrcal_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "mrcal_wrapper.h"

#include <malloc.h>
#include <stdlib.h>
#include <stdint.h>

#include <algorithm>
Expand Down