[R-pkg-devel] SystemRequirements and .R/Makevars
Dirk Eddelbuettel
edd at debian.org
Fri Jun 19 15:04:36 CEST 2015
Hi Ramon,
On 19 June 2015 at 12:01, Ramon Diaz-Uriarte wrote:
| Some of my packages use
|
| SystemRequirements: C++11
|
| in the DESCRIPTION. But then .R/Makevars seems to be ignored (e.g., flags
| such as -Wall or using clang) in all that concerns C++ (only CXX and
| CXXFLAGS are ignored, not CC or CFLAGS). So I keep commenting that line for
| normal development and uncommenting it for final checking before release.
|
|
| I vaguely remember reading somewhere this is the way things work, but this
| is not what I understand from reading again
| http://cran.r-project.org/doc/manuals/r-devel/R-exts.html#Using-C_002b_002b11-code.
|
| After googling I have not been able to locate anything, and since I guess
| it is probably common to use both C++11 and a custom .R/Makevars I think
| something is wrong somewhere in my setup. But I have no idea what. I am
| using Debian (a mix of testing and unstable), both with stock Debian R and
| with custom built Rs.
I settled pretty early on declaring this in src/Makevars only, partly for
historical reason (as it is where we always set compiler flags) and partly
because I found it to be consistent and reliabel. Writing R Extensions
offers an alternate, I forget the details.
One tricky bit is that we now have several CXX* variables. And because "code
is documentation" I often do the following to remind myself of CXX1X:
edd at max:~$ grep ^CXX /etc/R/Makeconf
CXX = g++
CXXCPP = $(CXX) -E
CXXFLAGS = -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g $(LTO)
CXXPICFLAGS = -fpic
CXX1X = g++
CXX1XFLAGS = -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g
CXX1XPICFLAGS = -fpic
CXX1XSTD = -std=c++11
edd at max:~$
I my most recent C++11-only package I did
edd at max:~$ cat git/rcpptoml/src/Makevars
## This is a C++11 package
CXX_STD = CXX11
## We need the header in inst/include, and a define
PKG_CPPFLAGS = -I../inst/include/ -DCPPTOML_USE_MAP
edd at max:~$
which regroups both the the compiler choice, an include directive and a
#define in one place.
Hope this helps, Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
More information about the R-package-devel
mailing list