diff --git a/NEWS.md b/NEWS.md index 8869d3a7..bbb64a54 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,7 +5,8 @@ * Ensure system-wide installation of `cmake` in the list of suggestions to install it when missing. * Update GHA scripts to latest versions. * Configure git to always use LF line endings for configure.ac file. -* Temporarily remove CI on windows devel. +* Add CI for R-devel on Windows with Rtools42. +* Fix for compatibility with versions of R anterior to `4.0` (#111). # nloptr 2.0.0 diff --git a/src/scripts/r_config.sh b/src/scripts/r_config.sh index 158c0a0a..5f2118a9 100755 --- a/src/scripts/r_config.sh +++ b/src/scripts/r_config.sh @@ -34,8 +34,11 @@ if test -z "$CXX"; then echo >&2 "Could not detect C++ compiler with R CMD config." fi -AR=`"${R_HOME}/bin${R_ARCH_BIN}/R" CMD config AR` -AR=`which $AR` +${R_HOME}/bin${R_ARCH_BIN}/Rscript --vanilla -e 'getRversion() > "4.0.0"' | grep TRUE > /dev/null +if [ $? -eq 0 ]; then + AR=`"${R_HOME}/bin${R_ARCH_BIN}/R" CMD config AR` + AR=`which $AR` -RANLIB=`"${R_HOME}/bin${R_ARCH_BIN}/R" CMD config RANLIB` -RANLIB=`which $RANLIB` + RANLIB=`"${R_HOME}/bin${R_ARCH_BIN}/R" CMD config RANLIB` + RANLIB=`which $RANLIB` +fi diff --git a/tools/cmake_call.sh b/tools/cmake_call.sh index 80e7245f..e19191cd 100755 --- a/tools/cmake_call.sh +++ b/tools/cmake_call.sh @@ -13,12 +13,18 @@ cd src sh ./scripts/nlopt_download.sh ${RSCRIPT_BIN} dot() { file=$1; shift; . "$file"; } dot ./scripts/r_config.sh "" +${RSCRIPT_BIN} --vanilla -e 'getRversion() > "4.0.0"' | grep TRUE > /dev/null +if [ $? -eq 0 ]; then + CMAKE_ADD_AR="-D CMAKE_AR=${AR}" + CMAKE_ADD_RANLIB="-D CMAKE_RANLIB=${RANLIB}" +else + CMAKE_ADD_AR="" + CMAKE_ADD_RANLIB="" +fi ${CMAKE_BIN} \ -D BUILD_SHARED_LIBS=OFF \ -D CMAKE_BUILD_TYPE=Release \ -D INSTALL_LIB_DIR=nlopt/lib \ - -D CMAKE_AR=${AR} \ - -D CMAKE_RANLIB=${RANLIB} \ -D NLOPT_CXX=ON \ -D NLOPT_GUILE=OFF \ -D NLOPT_MATLAB=OFF \ @@ -27,7 +33,7 @@ ${CMAKE_BIN} \ -D NLOPT_SWIG=OFF \ -D NLOPT_TESTS=OFF \ -S nlopt-src \ - -B nlopt-build + -B nlopt-build ${CMAKE_ADD_AR} ${CMAKE_ADD_RANLIB} sh ./scripts/nlopt_install.sh ${CMAKE_BIN} ${NCORES} "" # Cleanup