[Rinside-commits] r247 - in pkg: . inst inst/examples/armadillo inst/examples/armadillo/cmake inst/examples/eigen inst/examples/eigen/cmake

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Aug 14 02:08:46 CEST 2012


Author: edd
Date: 2012-08-14 02:08:46 +0200 (Tue, 14 Aug 2012)
New Revision: 247

Added:
   pkg/inst/examples/armadillo/cmake/
   pkg/inst/examples/armadillo/cmake/CMakeLists.txt
   pkg/inst/examples/eigen/cmake/
   pkg/inst/examples/eigen/cmake/CMakeLists.txt
Modified:
   pkg/ChangeLog
   pkg/inst/NEWS.Rd
Log:
added patch by Peter with CMake support for new armadillo and eigen examples


Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog	2012-08-13 11:43:54 UTC (rev 246)
+++ pkg/ChangeLog	2012-08-14 00:08:46 UTC (rev 247)
@@ -1,3 +1,8 @@
+2012-08-13  Dirk Eddelbuettel  <edd at debian.org>
+
+	* inst/examples/eigen/cmake/CMakeLists.txt: Added Peter's patch
+	* inst/examples/armadillo/cmake/CMakeLists.txt: idem
+
 2012-08-12  Dirk Eddelbuettel  <edd at debian.org>
 
 	* DESCRIPTION: Release 0.2.7

Modified: pkg/inst/NEWS.Rd
===================================================================
--- pkg/inst/NEWS.Rd	2012-08-13 11:43:54 UTC (rev 246)
+++ pkg/inst/NEWS.Rd	2012-08-14 00:08:46 UTC (rev 247)
@@ -2,6 +2,12 @@
 \title{News for Package 'RInside'}
 \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}}
 
+\section{Changes in RInside version 0.2.8 (2012-xx-yy)}{
+  \itemize{
+    \item Added CMake build support for armadillo and eigen examples,
+    once again kindly contributed by Peter Aberline
+   }
+}
 \section{Changes in RInside version 0.2.7 (2012-08-12)}{
   \itemize{
     \item New fifth examples subdirectory 'armadillo' with two new

Added: pkg/inst/examples/armadillo/cmake/CMakeLists.txt
===================================================================
--- pkg/inst/examples/armadillo/cmake/CMakeLists.txt	                        (rev 0)
+++ pkg/inst/examples/armadillo/cmake/CMakeLists.txt	2012-08-14 00:08:46 UTC (rev 247)
@@ -0,0 +1,152 @@
+cmake_minimum_required(VERSION 2.8.4) 
+
+set (VERBOSE 1)
+set (SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
+
+execute_process(COMMAND R RHOME
+                OUTPUT_VARIABLE R_HOME)
+
+file(GLOB sources ${SRC_DIR}/*.cpp)
+
+set(NUM_TRUNC_CHARS 2)
+
+execute_process(COMMAND R CMD config --cppflags
+                OUTPUT_VARIABLE RCPPFLAGS)
+
+if (CMAKE_HOST_WIN32)
+    if (${RCPPFLAGS} MATCHES "[-][I]([^ ;])+")
+	set (RCPPFLAGS ${CMAKE_MATCH_0})
+    endif()
+endif()
+
+string(SUBSTRING ${RCPPFLAGS} ${NUM_TRUNC_CHARS} -1 RCPPFLAGS)
+include_directories(${RCPPFLAGS})
+
+execute_process(COMMAND R CMD config --ldflags
+                OUTPUT_VARIABLE RLDFLAGS)
+string(LENGTH ${RLDFLAGS} RLDFLAGS_LEN)
+
+if (${RLDFLAGS} MATCHES "[-][L]([^ ;])+")
+    string(SUBSTRING ${CMAKE_MATCH_0} ${NUM_TRUNC_CHARS} -1 RLDFLAGS_L)
+    string(STRIP ${RLDFLAGS_L} RLDFLAGS_L )
+    link_directories(${RLDFLAGS_L} )
+endif()
+
+if (${RLDFLAGS} MATCHES "[-][l]([^;])+")
+    string(SUBSTRING ${CMAKE_MATCH_0} ${NUM_TRUNC_CHARS} -1 RLDFLAGS_l)
+    string(STRIP ${RLDFLAGS_l} RLDFLAGS_l )
+endif()
+
+execute_process(COMMAND Rscript -e "Rcpp:::CxxFlags()"
+                OUTPUT_VARIABLE RCPPINCL)
+string(SUBSTRING ${RCPPINCL} ${NUM_TRUNC_CHARS} -1 RCPPINCL)
+include_directories(${RCPPINCL})
+
+execute_process(COMMAND Rscript -e "Rcpp:::LdFlags()"
+                OUTPUT_VARIABLE RCPPLIBS)
+
+execute_process(COMMAND Rscript -e "RInside:::CxxFlags()"
+                OUTPUT_VARIABLE RINSIDEINCL)
+string(SUBSTRING ${RINSIDEINCL} ${NUM_TRUNC_CHARS} -1 RINSIDEINCL)
+include_directories(${RINSIDEINCL})
+message(${RINSIDEINCL})
+
+execute_process(COMMAND Rscript -e "RInside:::LdFlags()"
+                OUTPUT_VARIABLE RINSIDELIBS)
+
+execute_process(COMMAND Rscript -e "RcppArmadillo:::CxxFlags()"
+                OUTPUT_VARIABLE RCPPARMADILLOINCL)
+
+string(LENGTH ${RCPPARMADILLOINCL} INCLLENGTH)
+math(EXPR INCLLENGTH "${INCLLENGTH}-4")
+
+string(SUBSTRING ${RCPPARMADILLOINCL} 3 ${INCLLENGTH} RCPPARMADILLOINCL)
+include_directories(${RCPPARMADILLOINCL})
+
+if (CMAKE_HOST_WIN32)
+    string(LENGTH "libRcpp.a" lenRcppName)
+    string(LENGTH ${RCPPLIBS} lenRcppFQName)
+	
+    math(EXPR RLibPathLen ${lenRcppFQName}-${lenRcppName}-1)
+    string(SUBSTRING ${RCPPLIBS} 0 ${RLibPathLen} RCPPLIBS_L)
+    link_directories(${RCPPLIBS_L})
+	
+    math(EXPR RLibPathLen ${RLibPathLen}+1)
+    string(SUBSTRING ${RCPPLIBS} ${RLibPathLen} -1 RCPPLIBS_l)
+	
+	#Remove the quotes
+    string(SUBSTRING ${RINSIDELIBS} 1 -1 RINSIDELIBS)
+    string(LENGTH ${RINSIDELIBS} lenRInsideFQNameLen)
+    math(EXPR lenRInsideFQNameLen ${lenRInsideFQNameLen}-1)
+    string(SUBSTRING ${RINSIDELIBS} 0 ${lenRInsideFQNameLen} RINSIDELIBS)
+
+    string(LENGTH "libRInside.a" lenRInsideName)
+    string(LENGTH ${RINSIDELIBS} lenRInsideFQName)
+
+    math(EXPR RLibPathLen ${lenRInsideFQName}-${lenRInsideName}-1)
+    string(SUBSTRING ${RINSIDELIBS} 0 ${RLibPathLen} RINSIDELIBS_L)
+
+    math(EXPR RLibPathLen ${RLibPathLen}+1)
+    string(SUBSTRING ${RINSIDELIBS} ${RLibPathLen} -1 RINSIDELIBS_l)
+
+    link_directories(${RINSIDELIBS_L})
+else()	
+    if (${RCPPLIBS} MATCHES "[-][L]([^ ;])+")
+        string(SUBSTRING ${CMAKE_MATCH_0} ${NUM_TRUNC_CHARS} -1 RCPPLIBS_L)
+        link_directories(${RCPPLIBS_L} )
+    endif()
+
+    if (${RCPPLIBS} MATCHES "[-][l][R]([^;])+")
+        string(SUBSTRING ${CMAKE_MATCH_0} ${NUM_TRUNC_CHARS} -1 RCPPLIBS_l)
+    endif()
+
+    if (${RINSIDELIBS} MATCHES "[-][L]([^ ;])+")
+        string(SUBSTRING ${CMAKE_MATCH_0} ${NUM_TRUNC_CHARS} -1 RINSIDELIBS_L)
+        link_directories(${RINSIDELIBS_L})
+    endif()
+
+    if (${RINSIDELIBS} MATCHES "[-][l][R]([^;])+")
+        string(SUBSTRING ${CMAKE_MATCH_0} ${NUM_TRUNC_CHARS} -1 RINSIDELIBS_l)
+    endif()
+
+    # If the faster 'gold' linker is used, to avoid complaints about undefined symbol
+    SET(CMAKE_FIND_LIBRARY_SUFFIXES_SAVED ${CMAKE_FIND_LIBRARY_SUFFIXES}) # Backup
+    LIST(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".so.3")
+    FIND_LIBRARY(BLAS_LIBRARY blas)
+    SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAVED}) # Restore
+    LIST(APPEND EXTRA_LIBRARIES ${BLAS_LIBRARY})
+endif()
+
+execute_process(COMMAND R CMD config CXXFLAGS
+                OUTPUT_VARIABLE RCXXFLAGS)
+
+execute_process(COMMAND R CMD config BLAS_LIBS
+                OUTPUT_VARIABLE RBLAS)
+
+execute_process(COMMAND R CMD config LAPACK_LIBS
+                OUTPUT_VARIABLE RLAPACK)
+
+
+FIND_LIBRARY(LAPACK_LIBRARY lapack)
+
+set(CMAKE_CXX_FLAGS "-W -Wall -pedantic -Wextra ${CMAKE_CXX_FLAGS}")
+
+if (CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR
+    CMAKE_BUILD_TYPE STREQUAL "RelWithDebugInfo" )
+    add_definitions("-DDEBUG")
+elseif ( CMAKE_BUILD_TYPE STREQUAL "RELEASE" )
+    add_definitions("-O3")
+endif()
+
+foreach (next_SOURCE ${sources})
+   get_filename_component(source_name ${next_SOURCE} NAME_WE)
+   add_executable( ${source_name} ${next_SOURCE} )
+   
+   target_link_libraries(${source_name} ${RLDFLAGS_l})
+   target_link_libraries(${source_name} ${BLAS_LIBS})
+   target_link_libraries(${source_name} ${LAPACK_LIBS})
+   target_link_libraries(${source_name} ${RINSIDELIBS_l})
+   target_link_libraries(${source_name} ${RCPPLIBS_l})
+   target_link_libraries(${source_name} ${EXTRA_LIBRARIES})
+   target_link_libraries(${source_name} ${LAPACK_LIBRARY})
+endforeach (next_SOURCE ${sources})

Added: pkg/inst/examples/eigen/cmake/CMakeLists.txt
===================================================================
--- pkg/inst/examples/eigen/cmake/CMakeLists.txt	                        (rev 0)
+++ pkg/inst/examples/eigen/cmake/CMakeLists.txt	2012-08-14 00:08:46 UTC (rev 247)
@@ -0,0 +1,147 @@
+cmake_minimum_required(VERSION 2.8.4) 
+
+set (VERBOSE 1)
+set (SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
+
+execute_process(COMMAND R RHOME
+                OUTPUT_VARIABLE R_HOME)
+
+file(GLOB sources ${SRC_DIR}/*.cpp)
+
+set(NUM_TRUNC_CHARS 2)
+
+execute_process(COMMAND R CMD config --cppflags
+                OUTPUT_VARIABLE RCPPFLAGS)
+
+if (CMAKE_HOST_WIN32)
+    if (${RCPPFLAGS} MATCHES "[-][I]([^ ;])+")
+	set (RCPPFLAGS ${CMAKE_MATCH_0})
+    endif()
+endif()
+
+string(SUBSTRING ${RCPPFLAGS} ${NUM_TRUNC_CHARS} -1 RCPPFLAGS)
+include_directories(${RCPPFLAGS})
+
+execute_process(COMMAND R CMD config --ldflags
+                OUTPUT_VARIABLE RLDFLAGS)
+string(LENGTH ${RLDFLAGS} RLDFLAGS_LEN)
+
+if (${RLDFLAGS} MATCHES "[-][L]([^ ;])+")
+    string(SUBSTRING ${CMAKE_MATCH_0} ${NUM_TRUNC_CHARS} -1 RLDFLAGS_L)
+    string(STRIP ${RLDFLAGS_L} RLDFLAGS_L )
+    link_directories(${RLDFLAGS_L} )
+endif()
+
+if (${RLDFLAGS} MATCHES "[-][l]([^;])+")
+    string(SUBSTRING ${CMAKE_MATCH_0} ${NUM_TRUNC_CHARS} -1 RLDFLAGS_l)
+    string(STRIP ${RLDFLAGS_l} RLDFLAGS_l )
+endif()
+
+execute_process(COMMAND Rscript -e "Rcpp:::CxxFlags()"
+                OUTPUT_VARIABLE RCPPINCL)
+string(SUBSTRING ${RCPPINCL} ${NUM_TRUNC_CHARS} -1 RCPPINCL)
+include_directories(${RCPPINCL})
+
+execute_process(COMMAND Rscript -e "Rcpp:::LdFlags()"
+                OUTPUT_VARIABLE RCPPLIBS)
+
+execute_process(COMMAND Rscript -e "RInside:::CxxFlags()"
+                OUTPUT_VARIABLE RINSIDEINCL)
+string(SUBSTRING ${RINSIDEINCL} ${NUM_TRUNC_CHARS} -1 RINSIDEINCL)
+include_directories(${RINSIDEINCL})
+
+execute_process(COMMAND Rscript -e "RInside:::LdFlags()"
+                OUTPUT_VARIABLE RINSIDELIBS)
+
+execute_process(COMMAND Rscript -e "cat(paste('-I', system.file('include', package = 'RcppEigen'), sep=''))" OUTPUT_VARIABLE RCPPEIGENINCL)
+
+string(SUBSTRING ${RCPPEIGENINCL} ${NUM_TRUNC_CHARS} -1 RCPPEIGENINCL)
+include_directories(${RCPPEIGENINCL})
+
+if (CMAKE_HOST_WIN32)
+    string(LENGTH "libRcpp.a" lenRcppName)
+    string(LENGTH ${RCPPLIBS} lenRcppFQName)
+	
+    math(EXPR RLibPathLen ${lenRcppFQName}-${lenRcppName}-1)
+    string(SUBSTRING ${RCPPLIBS} 0 ${RLibPathLen} RCPPLIBS_L)
+    link_directories(${RCPPLIBS_L})
+	
+    math(EXPR RLibPathLen ${RLibPathLen}+1)
+    string(SUBSTRING ${RCPPLIBS} ${RLibPathLen} -1 RCPPLIBS_l)
+	
+	#Remove the quotes
+    string(SUBSTRING ${RINSIDELIBS} 1 -1 RINSIDELIBS)
+    string(LENGTH ${RINSIDELIBS} lenRInsideFQNameLen)
+    math(EXPR lenRInsideFQNameLen ${lenRInsideFQNameLen}-1)
+    string(SUBSTRING ${RINSIDELIBS} 0 ${lenRInsideFQNameLen} RINSIDELIBS)
+
+    string(LENGTH "libRInside.a" lenRInsideName)
+    string(LENGTH ${RINSIDELIBS} lenRInsideFQName)
+
+    math(EXPR RLibPathLen ${lenRInsideFQName}-${lenRInsideName}-1)
+    string(SUBSTRING ${RINSIDELIBS} 0 ${RLibPathLen} RINSIDELIBS_L)
+
+    math(EXPR RLibPathLen ${RLibPathLen}+1)
+    string(SUBSTRING ${RINSIDELIBS} ${RLibPathLen} -1 RINSIDELIBS_l)
+
+    link_directories(${RINSIDELIBS_L})
+else()	
+    if (${RCPPLIBS} MATCHES "[-][L]([^ ;])+")
+        string(SUBSTRING ${CMAKE_MATCH_0} ${NUM_TRUNC_CHARS} -1 RCPPLIBS_L)
+        link_directories(${RCPPLIBS_L} )
+    endif()
+
+    if (${RCPPLIBS} MATCHES "[-][l][R]([^;])+")
+        string(SUBSTRING ${CMAKE_MATCH_0} ${NUM_TRUNC_CHARS} -1 RCPPLIBS_l)
+    endif()
+
+    if (${RINSIDELIBS} MATCHES "[-][L]([^ ;])+")
+        string(SUBSTRING ${CMAKE_MATCH_0} ${NUM_TRUNC_CHARS} -1 RINSIDELIBS_L)
+        link_directories(${RINSIDELIBS_L})
+    endif()
+
+    if (${RINSIDELIBS} MATCHES "[-][l][R]([^;])+")
+        string(SUBSTRING ${CMAKE_MATCH_0} ${NUM_TRUNC_CHARS} -1 RINSIDELIBS_l)
+    endif()
+
+    # If the faster 'gold' linker is used, to avoid complaints about undefined symbol
+    SET(CMAKE_FIND_LIBRARY_SUFFIXES_SAVED ${CMAKE_FIND_LIBRARY_SUFFIXES}) # Backup
+    LIST(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".so.3")
+    FIND_LIBRARY(BLAS_LIBRARY blas)
+    SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_SAVED}) # Restore
+    LIST(APPEND EXTRA_LIBRARIES ${BLAS_LIBRARY})
+endif()
+
+execute_process(COMMAND R CMD config CXXFLAGS
+                OUTPUT_VARIABLE RCXXFLAGS)
+
+execute_process(COMMAND R CMD config BLAS_LIBS
+                OUTPUT_VARIABLE RBLAS)
+
+execute_process(COMMAND R CMD config LAPACK_LIBS
+                OUTPUT_VARIABLE RLAPACK)
+
+
+FIND_LIBRARY(LAPACK_LIBRARY lapack)
+
+set(CMAKE_CXX_FLAGS "-W -Wall -pedantic -Wextra ${CMAKE_CXX_FLAGS}")
+
+if (CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR
+    CMAKE_BUILD_TYPE STREQUAL "RelWithDebugInfo" )
+    add_definitions("-DDEBUG")
+elseif ( CMAKE_BUILD_TYPE STREQUAL "RELEASE" )
+    add_definitions("-O3")
+endif()
+
+foreach (next_SOURCE ${sources})
+   get_filename_component(source_name ${next_SOURCE} NAME_WE)
+   add_executable( ${source_name} ${next_SOURCE} )
+   
+   target_link_libraries(${source_name} ${RLDFLAGS_l})
+   target_link_libraries(${source_name} ${BLAS_LIBS})
+   target_link_libraries(${source_name} ${LAPACK_LIBS})
+   target_link_libraries(${source_name} ${RINSIDELIBS_l})
+   target_link_libraries(${source_name} ${RCPPLIBS_l})
+   target_link_libraries(${source_name} ${EXTRA_LIBRARIES})
+   target_link_libraries(${source_name} ${LAPACK_LIBRARY})
+endforeach (next_SOURCE ${sources})



More information about the Rinside-commits mailing list