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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Oct 28 23:07:44 CET 2012


Author: pwa
Date: 2012-10-28 23:07:44 +0100 (Sun, 28 Oct 2012)
New Revision: 266

Added:
   pkg/inst/examples/armadillo/cmake/WIN.readme.txt
   pkg/inst/examples/eigen/cmake/WIN.readme.txt
Modified:
   pkg/ChangeLog
   pkg/inst/NEWS.Rd
   pkg/inst/examples/armadillo/cmake/CMakeLists.txt
   pkg/inst/examples/eigen/cmake/CMakeLists.txt
   pkg/inst/examples/standard/cmake/CMakeLists.txt
Log:
Added R_ARCH auto detection to windows cmake builds
Added readme files for windows eigen and armadillo binaries


Modified: pkg/ChangeLog
===================================================================
--- pkg/ChangeLog	2012-10-16 01:37:50 UTC (rev 265)
+++ pkg/ChangeLog	2012-10-28 22:07:44 UTC (rev 266)
@@ -1,3 +1,13 @@
+2012-10-28  Peter Aberline  <peter.aberline at gmail.com>
+
+	* inst/examples/standard/cmake/CMakeLists.txt: R_ARCH autodetection 
+	* inst/examples/armadillo/cmake/CMakeLists.txt: Dito
+	* inst/examples/eigen/cmake/CMakeLists.txt: Dito
+
+	* inst/examples/armadillo/cmake/WIN.readme.txt: Added instructions
+	for running windows binaries.
+	* inst/examples/eigen/cmake/WIN.readme.txt: Dito
+
 2012-10-15  Dirk Eddelbuettel  <edd at debian.org>
 
 	* inst/include/RInside.h: Added two new boolean arguments to

Modified: pkg/inst/NEWS.Rd
===================================================================
--- pkg/inst/NEWS.Rd	2012-10-16 01:37:50 UTC (rev 265)
+++ pkg/inst/NEWS.Rd	2012-10-28 22:07:44 UTC (rev 266)
@@ -16,6 +16,9 @@
     \item Added non-throwing variants of parseEval() and parseEvalQ()
     \item Modified Qt and Wt examples of density estimation applications
     to be much more resilient to bad user input
+    \item Updated CMake build support for standard, armadillo and eigen
+    \item Improved CMake builds of examples/standard, examples/eigen and
+    examples/armadillo by detecting architecture
   }
 }
 \section{Changes in RInside version 0.2.8 (2012-09-07)}{
@@ -152,4 +155,4 @@
     \item Minor code cleanups
     \item Initial version in SVN at R-Forge
   }
-}
\ No newline at end of file
+}

Modified: pkg/inst/examples/armadillo/cmake/CMakeLists.txt
===================================================================
--- pkg/inst/examples/armadillo/cmake/CMakeLists.txt	2012-10-16 01:37:50 UTC (rev 265)
+++ pkg/inst/examples/armadillo/cmake/CMakeLists.txt	2012-10-28 22:07:44 UTC (rev 266)
@@ -10,7 +10,24 @@
 
 set(NUM_TRUNC_CHARS 2)
 
-execute_process(COMMAND R CMD config --cppflags
+set (RPATH "R")
+set (RSCRIPT_PATH "Rscript")
+
+if (CMAKE_HOST_WIN32)
+    execute_process(COMMAND ${RSCRIPT_PATH} -e "cat(.Platform$r_arch)"
+                    OUTPUT_VARIABLE R_ARCH)
+		
+	execute_process(COMMAND R --arch ${R_ARCH} RHOME
+                    OUTPUT_VARIABLE R_HOME)
+	
+    string(REPLACE "\\" "/" R_HOME ${R_HOME})	
+	
+	set (RPATH ${R_HOME}/bin/R)
+endif()
+
+set (RCPPFLAGS_CMD " ${RPATH} " " CMD " " config " " --cppflags ") 
+
+execute_process(COMMAND ${RPATH} CMD config --cppflags
                 OUTPUT_VARIABLE RCPPFLAGS)
 
 if (CMAKE_HOST_WIN32)
@@ -22,7 +39,7 @@
 string(SUBSTRING ${RCPPFLAGS} ${NUM_TRUNC_CHARS} -1 RCPPFLAGS)
 include_directories(${RCPPFLAGS})
 
-execute_process(COMMAND R CMD config --ldflags
+execute_process(COMMAND ${RPATH} CMD config --ldflags
                 OUTPUT_VARIABLE RLDFLAGS)
 string(LENGTH ${RLDFLAGS} RLDFLAGS_LEN)
 
@@ -37,24 +54,24 @@
     string(STRIP ${RLDFLAGS_l} RLDFLAGS_l )
 endif()
 
-execute_process(COMMAND Rscript -e "Rcpp:::CxxFlags()"
+execute_process(COMMAND ${RSCRIPT_PATH} -e "Rcpp:::CxxFlags()"
                 OUTPUT_VARIABLE RCPPINCL)
 string(SUBSTRING ${RCPPINCL} ${NUM_TRUNC_CHARS} -1 RCPPINCL)
 include_directories(${RCPPINCL})
 
-execute_process(COMMAND Rscript -e "Rcpp:::LdFlags()"
+execute_process(COMMAND ${RSCRIPT_PATH} -e "Rcpp:::LdFlags()"
                 OUTPUT_VARIABLE RCPPLIBS)
 
-execute_process(COMMAND Rscript -e "RInside:::CxxFlags()"
+execute_process(COMMAND ${RSCRIPT_PATH} -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()"
+execute_process(COMMAND ${RSCRIPT_PATH} -e "RInside:::LdFlags()"
                 OUTPUT_VARIABLE RINSIDELIBS)
 
-execute_process(COMMAND Rscript -e "RcppArmadillo:::CxxFlags()"
+execute_process(COMMAND ${RSCRIPT_PATH} -e "RcppArmadillo:::CxxFlags()"
                 OUTPUT_VARIABLE RCPPARMADILLOINCL)
 
 string(LENGTH ${RCPPARMADILLOINCL} INCLLENGTH)
@@ -124,13 +141,13 @@
     FIND_LIBRARY(LAPACK_LIBRARY lapack)
 endif()
 
-execute_process(COMMAND R CMD config CXXFLAGS
+execute_process(COMMAND ${RPATH} CMD config CXXFLAGS
                 OUTPUT_VARIABLE RCXXFLAGS)
 
-execute_process(COMMAND R CMD config BLAS_LIBS
+execute_process(COMMAND ${RPATH} CMD config BLAS_LIBS
                 OUTPUT_VARIABLE RBLAS)
 
-execute_process(COMMAND R CMD config LAPACK_LIBS
+execute_process(COMMAND ${RPATH} CMD config LAPACK_LIBS
                 OUTPUT_VARIABLE RLAPACK)
 
 set(CMAKE_CXX_FLAGS "-W -Wall -pedantic -Wextra ${CMAKE_CXX_FLAGS}")
@@ -158,3 +175,4 @@
    target_link_libraries(${source_name} ${LAPACK_LIBRARY})
    
 endforeach (next_SOURCE ${sources})
+

Added: pkg/inst/examples/armadillo/cmake/WIN.readme.txt
===================================================================
--- pkg/inst/examples/armadillo/cmake/WIN.readme.txt	                        (rev 0)
+++ pkg/inst/examples/armadillo/cmake/WIN.readme.txt	2012-10-28 22:07:44 UTC (rev 266)
@@ -0,0 +1,37 @@
+
+Building these examples on Windows is a bit more difficult than on Linux.
+
+* Put R in the path:
+C:\R\R-2.1X.X\bin
+C:\R\R-2.1X.X\bin\i386
+
+* Add required environment variables:
+R_HOME	C:\R\R-2.1X.X
+CYGWIN	nodosfilewarning
+
+* Then libpack and libblas for Windows needed to be obtained from:
+
+http://icl.cs.utk.edu/lapack-for-windows/lapack/index.html#libraries_mingw
+
+* The CMakeLists.txt files expect the liblapack.lib and libblas.lib files to be in the same directory as themselves for the Windows build. You can edit lines 7 and 8 of the the CMakeLists.txt files if they are not in this location.
+
+* I generally build in a 'build' directly below cmake:
+mkdir build
+cd build
+cmake -G "Unix Makefiles" ../.
+make
+
+To run these example there are further DLL dependencies required not installed by RTools:
+
+libgcc_s_dw2-1.dll
+libgfortran.dll
+libquadmath-0.dll
+liblapack.dll
+
+I was able to grab these by installing MinGW from: http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/
+Use the version that matches the gcc version that is installed by RTools.
+
+Once installed, either add their location to the PATH, or copy them to either the same directory as the example executable, or put them in the windows/system32 folder.
+
+Peter
+peter dot aberline at gmail dot com

Modified: pkg/inst/examples/eigen/cmake/CMakeLists.txt
===================================================================
--- pkg/inst/examples/eigen/cmake/CMakeLists.txt	2012-10-16 01:37:50 UTC (rev 265)
+++ pkg/inst/examples/eigen/cmake/CMakeLists.txt	2012-10-28 22:07:44 UTC (rev 266)
@@ -10,7 +10,24 @@
 
 set(NUM_TRUNC_CHARS 2)
 
-execute_process(COMMAND R CMD config --cppflags
+set (RPATH "R")
+set (RSCRIPT_PATH "Rscript")
+
+if (CMAKE_HOST_WIN32)
+    execute_process(COMMAND ${RSCRIPT_PATH} -e "cat(.Platform$r_arch)"
+                    OUTPUT_VARIABLE R_ARCH)
+		
+	execute_process(COMMAND ${RPATH} --arch ${R_ARCH} RHOME
+                    OUTPUT_VARIABLE R_HOME)
+	
+    string(REPLACE "\\" "/" R_HOME ${R_HOME})	
+	
+	set (RPATH ${R_HOME}/bin/R)
+endif()
+
+set (RCPPFLAGS_CMD " ${RPATH} " " CMD " " config " " --cppflags ") 
+
+execute_process(COMMAND ${RPATH} CMD config --cppflags
                 OUTPUT_VARIABLE RCPPFLAGS)
 
 if (CMAKE_HOST_WIN32)
@@ -149,3 +166,4 @@
    target_link_libraries(${source_name} ${EXTRA_LIBRARIES})
    target_link_libraries(${source_name} ${LAPACK_LIBRARY})
 endforeach (next_SOURCE ${sources})
+

Added: pkg/inst/examples/eigen/cmake/WIN.readme.txt
===================================================================
--- pkg/inst/examples/eigen/cmake/WIN.readme.txt	                        (rev 0)
+++ pkg/inst/examples/eigen/cmake/WIN.readme.txt	2012-10-28 22:07:44 UTC (rev 266)
@@ -0,0 +1,37 @@
+
+Building these examples on Windows is a bit more difficult than on Linux.
+
+* Put R in the path:
+C:\R\R-2.1X.X\bin
+C:\R\R-2.1X.X\bin\i386
+
+* Add required environment variables:
+R_HOME	C:\R\R-2.1X.X
+CYGWIN	nodosfilewarning
+
+* Then libpack and libblas for Windows needed to be obtained from:
+
+http://icl.cs.utk.edu/lapack-for-windows/lapack/index.html#libraries_mingw
+
+* The CMakeLists.txt files expect the liblapack.lib and libblas.lib files to be in the same directory as themselves for the Windows build. You can edit lines 7 and 8 of the the CMakeLists.txt files if they are not in this location.
+
+* I generally build in a 'build' directly below cmake:
+mkdir build
+cd build
+cmake -G "Unix Makefiles" ../.
+make
+
+To run these example there are further DLL dependencies required not installed by RTools:
+
+libgcc_s_dw2-1.dll
+libgfortran.dll
+libquadmath-0.dll
+liblapack.dll
+
+I was able to grab these by installing MinGW from: http://sourceforge.net/projects/mingw/files/MinGW/Base/gcc/Version4/
+Use the version that matches the gcc version that is installed by RTools.
+
+Once installed, either add their location to the PATH, or copy them to either the same directory as the example executable, or put them in the windows/system32 folder.
+
+Peter
+peter dot aberline at gmail dot com

Modified: pkg/inst/examples/standard/cmake/CMakeLists.txt
===================================================================
--- pkg/inst/examples/standard/cmake/CMakeLists.txt	2012-10-16 01:37:50 UTC (rev 265)
+++ pkg/inst/examples/standard/cmake/CMakeLists.txt	2012-10-28 22:07:44 UTC (rev 266)
@@ -3,26 +3,40 @@
 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)
+set (RPATH "R")
+set (RSCRIPT_PATH "Rscript")
 
 if (CMAKE_HOST_WIN32)
-    if (${RCPPFLAGS} MATCHES "[-][I]([^ ;])+")
-	set (RCPPFLAGS ${CMAKE_MATCH_0})
+    execute_process(COMMAND ${RSCRIPT_PATH} -e "cat(.Platform$r_arch)"
+                    OUTPUT_VARIABLE R_ARCH)
+		
+	execute_process(COMMAND ${RPATH} --arch ${R_ARCH} RHOME
+                    OUTPUT_VARIABLE R_HOME)
+	
+    string(REPLACE "\\" "/" R_HOME ${R_HOME})	
+	
+	set (RPATH ${R_HOME}/bin/R)
+endif()
+
+set (RCPPFLAGS_CMD " ${RPATH} " " CMD " " config " " --cppflags ") 
+
+execute_process(COMMAND ${RPATH} 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
+execute_process(COMMAND ${RPATH} CMD config --ldflags
                 OUTPUT_VARIABLE RLDFLAGS)
 string(LENGTH ${RLDFLAGS} RLDFLAGS_LEN)
 
@@ -37,20 +51,20 @@
     string(STRIP ${RLDFLAGS_l} RLDFLAGS_l )
 endif()
 
-execute_process(COMMAND Rscript -e "Rcpp:::CxxFlags()"
+execute_process(COMMAND ${RSCRIPT_PATH} -e "Rcpp:::CxxFlags()"
                 OUTPUT_VARIABLE RCPPINCL)
 string(SUBSTRING ${RCPPINCL} ${NUM_TRUNC_CHARS} -1 RCPPINCL)
 include_directories(${RCPPINCL})
 
-execute_process(COMMAND Rscript -e "Rcpp:::LdFlags()"
+execute_process(COMMAND ${RSCRIPT_PATH} -e "Rcpp:::LdFlags()"
                 OUTPUT_VARIABLE RCPPLIBS)
 
-execute_process(COMMAND Rscript -e "RInside:::CxxFlags()"
+execute_process(COMMAND ${RSCRIPT_PATH} -e "RInside:::CxxFlags()"
                 OUTPUT_VARIABLE RINSIDEINCL)
 string(SUBSTRING ${RINSIDEINCL} ${NUM_TRUNC_CHARS} -1 RINSIDEINCL)
 include_directories(${RINSIDEINCL})
 
-execute_process(COMMAND Rscript -e "RInside:::LdFlags()"
+execute_process(COMMAND ${RSCRIPT_PATH} -e "RInside:::LdFlags()"
                 OUTPUT_VARIABLE RINSIDELIBS)
 
 if (CMAKE_HOST_WIN32)
@@ -100,13 +114,13 @@
     endif()
 endif()
 
-execute_process(COMMAND R CMD config CXXFLAGS
+execute_process(COMMAND ${RPATH} CMD config CXXFLAGS
                 OUTPUT_VARIABLE RCXXFLAGS)
 
-execute_process(COMMAND R CMD config BLAS_LIBS
+execute_process(COMMAND ${RPATH} CMD config BLAS_LIBS
                 OUTPUT_VARIABLE RBLAS)
 
-execute_process(COMMAND R CMD config LAPACK_LIBS
+execute_process(COMMAND ${RPATH} CMD config LAPACK_LIBS
                 OUTPUT_VARIABLE RLAPACK)
 
 set(CMAKE_CXX_FLAGS "-W -Wall -pedantic -Wextra ${CMAKE_CXX_FLAGS}")



More information about the Rinside-commits mailing list