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

[R-package] use C++17 in the CRAN package #5690

Merged
merged 14 commits into from
Mar 7, 2023
Prev Previous commit
Next Next commit
fix Windows R 3.6 support
  • Loading branch information
jameslamb committed Jan 28, 2023
commit 1d18a2e440de3120fd5efea366890a41e3911883
24 changes: 24 additions & 0 deletions R-package/configure.win
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,31 @@
###########################

R_EXE="${R_HOME}/bin${R_ARCH_BIN}/R"

# As described in "Using C++ code" in "Writing R Extensions",
# Rtools35 shipped with g++ 4.9, which didn't support C++17.
#
# Testing here for C++17 support, to account for that possibility
# and to continue supporting R 3.6.
#
CXX17=`"${R_EXE}" CMD config CXX17`
CXX17STD=`"${R_EXE}" CMD config CXX17STD`
CXX="${CXX17} ${CXX17STD}"
CXXFLAGS=`"${R_EXE}" CMD config CXX17FLAGS`
CXX_STD="CXX17"

cpp17_supported="yes"
if test "${CXX17}" = "";
then
cpp17_supported="no"
CXX14=`"${R_EXE}" CMD config CXX14`
CXX14STD=`"${R_EXE}" CMD config CXX14STD`
CXX="${CXX14} ${CXX14STD}"
CXXFLAGS=`"${R_EXE}" CMD config CXX14FLAGS`
CXX_STD="CXX14"
fi
echo "checking whether C++17 is supported...${cpp17_supported}"

CPPFLAGS=`"${R_EXE}" CMD config CPPFLAGS`

# LightGBM-specific flags
Expand Down Expand Up @@ -96,6 +117,9 @@ then
fi

# Generate Makevars.win from Makevars.win.in
sed -e \
"s/@CXX_STD@/$CXX_STD/" \
< src/Makevars.win.in > src/Makevars.win
sed -e \
"s/@LGB_CPPFLAGS@/$LGB_CPPFLAGS/" \
< src/Makevars.win.in > src/Makevars.win
2 changes: 1 addition & 1 deletion R-package/src/Makevars.win.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CXX_STD = CXX17
CXX_STD = @CXX_STD@

PKGROOT=.

Expand Down