[rkward-cvs] SF.net SVN: rkward: [2100] branches/KDE4_port/rkward/rbackend/FindR.cmake

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sun Oct 21 23:51:43 UTC 2007


Revision: 2100
          http://rkward.svn.sourceforge.net/rkward/?rev=2100&view=rev
Author:   tfry
Date:     2007-10-21 16:51:43 -0700 (Sun, 21 Oct 2007)

Log Message:
-----------
Fix R library dir location detection

Modified Paths:
--------------
    branches/KDE4_port/rkward/rbackend/FindR.cmake

Modified: branches/KDE4_port/rkward/rbackend/FindR.cmake
===================================================================
--- branches/KDE4_port/rkward/rbackend/FindR.cmake	2007-10-21 21:26:53 UTC (rev 2099)
+++ branches/KDE4_port/rkward/rbackend/FindR.cmake	2007-10-21 23:51:43 UTC (rev 2100)
@@ -112,24 +112,48 @@
 MESSAGE(STATUS "Checking for R package library location to use")
 IF(NOT R_LIBDIR)
 	EXEC_PROGRAM(${R_EXECUTABLE}
-		ARGS CMD sh -c 'echo $R_LIBS'
+		ARGS CMD sh -c 'echo $R_LIBS:$R_LIBS_SITE'
 		OUTPUT_VARIABLE R_LIBDIR)
 ELSE(NOT R_LIBDIR)
 	MESSAGE(STATUS "Location specified by user")
 ENDIF(NOT R_LIBDIR)
 
+IF(NOT R_LIBDIR)
+	MESSAGE(STATUS "Not reliably determined or specified. Guessing.")
+	SET(R_LIBDIR ${R_HOME}/library)
+ENDIF(NOT R_LIBDIR)
+
 # strip whitespace
 STRING(REGEX REPLACE "[ \n]+"
 	"" R_LIBDIR
 	"${R_LIBDIR}")
 
-IF(NOT R_LIBDIR)
-	MESSAGE(STATUS "Not reliably determined or specified. Guessing.")
-	SET(R_LIBDIR ${R_HOME}/library)
-ENDIF(NOT R_LIBDIR)
+# strip leading colon(s)
+STRING(REGEX REPLACE "^:+"
+	"" R_LIBDIR
+	"${R_LIBDIR}")
 
+# find first path
+STRING(REGEX REPLACE ":"
+	" " R_LIBDIR
+	"${R_LIBDIR}")
+
+SET(R_LIBDIRS ${R_LIBDIR})
+SEPARATE_ARGUMENTS(R_LIBDIRS)
+
+SET(R_LIBDIR)
+FOREACH(CURRENTDIR ${R_LIBDIRS})
+	IF(NOT USE_R_LIBDIR)
+		IF(EXISTS ${CURRENTDIR})
+			SET(R_LIBDIR ${CURRENTDIR})
+		ELSE(EXISTS ${CURRENTDIR})
+			MESSAGE(STATUS "${CURRENTDIR} does not exist. Skipping")
+		ENDIF(EXISTS ${CURRENTDIR})
+	ENDIF(NOT USE_R_LIBDIR)
+ENDFOREACH(CURRENTDIR ${R_LIBDIRS})
+
 IF(NOT EXISTS ${R_LIBDIR})
-	MESSAGE(FATAL_ERROR "${R_LIBDIR} does not exist")
+	MESSAGE(FATAL_ERROR "No existing library location found")
 ELSE(NOT EXISTS ${R_LIBDIR})
 	MESSAGE(STATUS "Will use ${R_LIBDIR}")
 ENDIF(NOT EXISTS ${R_LIBDIR})


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list