[Rcpp-devel] Rcpp::depends not picking up inst/include/

Thell Fowler tbfowler4 at gmail.com
Fri Nov 30 20:43:52 CET 2012

On Fri, Nov 30, 2012 at 12:28 PM, JJ Allaire <jj.allaire at gmail.com> wrote:
>> Looking through the source of ./pkg/Rcpp/R/Attributes.R contains it seems
>> that a depended upon package _must_ define a plugin if the inst/include is
>> to get appended to the sourced files build environment.
> We do indeed add inst/include to the compilation for all packages listed in
> Rcpp::depends (Attributes.R:371 adds the package name to the list then the
> call to .buildClinkCppFlags on line 419 does the work of locating the actual
> directory.

That section, if I'm reading correctly states that if the package (the
one from Rcpp::depends)  exports a plugin then it will add it to the
linkingtoPackages and if it doesn't then it won't and these are what
are processed by .buildClinkCppFlags.

>> My use case is that of a header only package providing
>> Rcpp::interface(cpp) only where my package DESCRIPTION already contains the
>> depends providing everything outside of the wrap and as forwarders. So while
>> building the package does require makevars(.win) info the sourceCPP source
>> code doesn't because sourceCPP does that for the user.
> A hint as to what might be happening is in your reference to as and wrap
> forwarders. Are there as and wrap forwarders that are sitting in another
> include file? If you want to automatically inject additional include files
> (e.g. for as and wrap) then you definitely need to define an inline plugin.
> If we can't get to the bottom of this by discussion perhaps you could send a
> link to either your source code or a representative example and I'll take a
> closer look.
> J.J.

I can definitely add the plugin to the package, so getting it resolved
isn't an issue.  What I'm questioning is the _need_ of adding the
plugin.  Imagine if you will;

myPackage -> DESCRIPTION -> depends R_ext_A, R_ext_B
myPackage -> inst/include/myForwarder.hpp
myPackage -> src/myForwarder.cpp

After build and install myForwarder.hpp is in r_library_path/myPackage/include.

mySourcedCpp has //[[Rcpp::depends(myPackage)]]
#include <myForwarder.hpp>

When .setupBuildEnvironment attempts populating linkingToPackages it
checks if myPackage exports a plugin (which it doesn't in this case),
so the main depended upon package is omitted from linkingToPackages,
and later when .buildCppFlags(linkingToPackages) is called
myPackage_path/include doesn't get added.

I'm thinking along the lines of:

if (!is.null(plugin)) {
} else if( file.exists( paste0( package, NULL, quiet=TRUE), "/include") ) {
  # capture any LinkingTo elements to ensure CppFlag inclusion with of
package with exported plugin.

But I am unsure of the ramifications at this point.

More information about the Rcpp-devel mailing list