R package with CMake build
C++ part
- C++ function for exporting from shared library:
foo_cpp_function
(filesrc/foo.cpp
) - C++ shared library
foocpp
(fileCMakeLists.txt
) - Empty makefile to avoid R standard build (file
src/Makefile
) - Custom configure script to trigger CMake build (file
configure
)
R Integration
- Load
foocpp
library into R package (useDynLib(foocpp)
fileNAMESPACE
) - R wrapper function
foo_r_function
to call C++foo_cpp_function
(fileR/foo.R
) - Export R function
foo_r_function
(export('foo_r_function')
fileNAMESPACE
)
R package
- Library name
foopack
(fileDESCRIPTION
) - Version
0.0.1
(fileDESCRIPTION
) - Result package name
foopack_0.0.1.tar.gz
R example
- Load R library
foopack
(library('foopack')
filemytest.R
) - Call
foo_r_function
(filemytest.R
)
Testing scripts
- Clean directory (
clean.py
) - Run
R CMD build
,R CMD check
,R CMD INSTALL
(to local directory) and testmytest.R
(run.py
)