Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set AR and RANLIB only when R >= 4.0. #111

Merged
merged 1 commit into from
Mar 9, 2022
Merged
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
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