[Rcpp-devel] Using CMakeLists.txt
Dirk Eddelbuettel
edd at debian.org
Tue Mar 5 21:09:56 CET 2013
On 5 March 2013 at 12:21, Etienne B. Racine wrote:
| I'd like to use a PCL algorithm inside R and they provide a CMakeLists.txt for
| configuration. I haven't found how to directly use the CMakeLists.txt in
| building R package, however when I run `make .` form src, I can generate a
| Makefile that nearly works with `R CMD INSTALL --no-multiarch`.
Read up a little on CMake. It is at the end of the "just another" frontend /
make replacement. If you turn on verbose mode, you should be able to see all
g++ invocations.
Which is all you need to mimic in Makevars.
| It does compile correctly my .cpp, however I get
| `Error in library.dynam(lib, package, package.lib) : shared object
| ‘my_package.so’ not found`
|
| Here's the CMakeFileLists.txt :
| ```
| cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
|
| find_package(PCL 1.6 REQUIRED)
|
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
|
| include_directories(${PCL_INCLUDE_DIRS})
| link_directories(${PCL_LIBRARY_DIRS})
| add_definitions(${PCL_DEFINITIONS})
|
| add_executable (segmentation segmentation.cpp)
| target_link_libraries (segmentation ${PCL_LIBRARIES})
| ```
| I've seen that using a makefile wasn't the best practice [1] (I should move it
| to makevars). Since my CMakeFileLists is apparently simple (e.g. compared to
| RInside examples), I guess I could move it to makevars however I'm not familiar
| with cmake nor makevars, so I was wondering if there was documentation about
| translating from one to the other. However I'm absolutely not sure this is the
| real problem (using the CMakeLists.txt).
Writing Makefile code is yet another little skill one has to acquire on the
side once projects get larger. There is a lot of support though, as there
are plenty of examples.
Nothing really Rcpp-specific here.
Dirk
|
| (I'm using R version 2.15.2 (2012-10-26) on x86_64-pc-linux-gnu (64-bit),
| building from RStudio.)
|
| Etienne
|
| [1]: http://stackoverflow.com/questions/12976036/
| how-to-use-usedynlib-correctly-in-an-r-package-namespace-file
|
|
|
| ----------------------------------------------------------------------
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list