diff --git a/.circleci/config.yml b/.circleci/config.yml index abfb41e..c50734d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -92,8 +92,27 @@ jobs: no_output_timeout: 30m command: | set -x - R -e "Sys.setenv(MAKEJ=3); remotes::install_git(c('.'), lib=c('${R_LIBS}'))" + R -e "Sys.setenv(MAKEJ=3); remotes::install_git(c('.'), lib=c('${R_LIBS}'), upgrade='never', INSTALL_opts='--build')" R -e "library(SimpleITK); Version()" + - run: + name: Rename package + command: | + # package naming is SimpleITK_${PKG_VERSION}_R${R_VERSION_SHORT}_${OS_ARCHIVE_EXT} + R_VERSION_SHORT=$(echo "<< parameters.r-version >>" | cut -d'.' -f1,2) + PKG_VERSION=$(Rscript -e "cat(read.dcf('DESCRIPTION', 'Version')[1])") + + # canonical approach to collecting build artifacts in a directory for upload + mkdir -p artifacts + + # Find the built package and rename according to the naming convention + BUILT_PKG=$(ls SimpleITK_*.tgz | head -1) + PKG_NAME="SimpleITK_${PKG_VERSION}_R${R_VERSION_SHORT}_macos-arm64.tgz" + mv "$BUILT_PKG" "artifacts/$PKG_NAME" + + ls -lh artifacts/ + - store_artifacts: + path: artifacts + destination: . workflows: r-build-test: # Runs on: push to main, pull requests to main, manual trigger, and scheduled runs diff --git a/configure b/configure index 7afdfb9..5896792 100755 --- a/configure +++ b/configure @@ -37,6 +37,25 @@ if [ -z "${MAKEJ}" ] ; then export MAKEJ fi +## For MacOS, set CMAKE_OSX_DEPLOYMENT_TARGET based on architecture +## Following https://mac.r-project.org/ guidelines: +## "sonoma-arm64 build supports arm64 Macs (M1+) from macOS 14 (Sonoma) and higher (since R 4.6.0)" +## "big-sur-x86_64 build supports legacy Intel Macs from macOS 11 (Big Sur) and higher (since R 4.3.0)" +CMAKE_OSX_ARGS="" +if [ "$(uname -s)" == "Darwin" ]; then + OS_ARCH=$(uname -m) + if [ "$OS_ARCH" == "arm64" ] || [ "$OS_ARCH" == "aarch64" ]; then + # For Apple Silicon, target macOS 14 (Sonoma) + export CMAKE_OSX_DEPLOYMENT_TARGET="14.0" + elif [ "$OS_ARCH" == "x86_64" ]; then + # For Intel Macs, target macOS 11 (Big Sur) + export CMAKE_OSX_DEPLOYMENT_TARGET="11.0" + fi + if [ -n "${CMAKE_OSX_DEPLOYMENT_TARGET}" ]; then + CMAKE_OSX_ARGS="-D CMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET}" + fi +fi + ## All the building is going to happen in an SITK folder mkdir -p SITK ( @@ -56,6 +75,7 @@ mkdir -p SITK cmake \ -D "CMAKE_CXX_FLAGS:STRING=-fvisibility=hidden -fvisibility-inlines-hidden ${CFLAGS}" \ -D "CMAKE_C_FLAGS:STRING=-fvisibility=hidden ${CFLAGS}" \ + ${CMAKE_OSX_ARGS} \ -DITK_C_OPTIMIZATION_FLAGS:STRING="" \ -DITK_CXX_OPTIMIZATION_FLAGS:STRING="" \ -DWRAP_DEFAULT=OFF\