Skip to content

Commit

Permalink
Merge pull request #111 from astamm/older-r-versions
Browse files Browse the repository at this point in the history
Set AR and RANLIB only when R >= 4.0. Closes #105.
  • Loading branch information
astamm authored Mar 9, 2022
2 parents 99afdcd + 59d6e66 commit 927fe59
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 7 additions & 4 deletions src/scripts/r_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 9 additions & 3 deletions tools/cmake_call.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
Expand Down

0 comments on commit 927fe59

Please sign in to comment.