KDE/kdeedu
Alexander Rieder
alexanderrieder at gmail.com
Sun May 2 18:51:57 CEST 2010
SVN commit 1121900 by arieder:
Cleanup FindR.cmake
Tanks to Alexander Neundorf for being so patient with me on this.
CCMAIL: kde-buildsystem at kde.org
M +2 -3 cantor/src/backends/R/rserver/CMakeLists.txt
M +39 -108 cmake/modules/FindR.cmake
--- trunk/KDE/kdeedu/cantor/src/backends/R/rserver/CMakeLists.txt #1121899:1121900
@@ -1,5 +1,4 @@
-include_directories(${R_INCLUDEDIR})
-LINK_DIRECTORIES(${R_SHAREDLIBDIR})
+include_directories(${R_INCLUDE_DIR})
set( RServer_SRCS
rserver.cpp
@@ -18,7 +17,7 @@
add_custom_target(rautoloads COMMAND ${R_EXECUTABLE} --slave --file=${CMAKE_CURRENT_SOURCE_DIR}/tools/autoloads.r > ${CMAKE_CURRENT_BINARY_DIR}/rautoloads.h )
kde4_add_executable( cantor_rserver ${RServer_SRCS} )
-target_link_libraries( cantor_rserver ${KDE4_KDEUI_LIBS} cantorlibs ${R_USED_LIBS} ${KDE4_KIO_LIBS})
+target_link_libraries( cantor_rserver ${KDE4_KDEUI_LIBS} cantorlibs ${R_LIBRARIES} ${KDE4_KIO_LIBS})
add_dependencies(cantor_rserver renvvars rautoloads)
install(TARGETS cantor_rserver ${INSTALL_TARGETS_DEFAULT_ARGS} )
--- trunk/KDE/kdeedu/cmake/modules/FindR.cmake #1121899:1121900
@@ -5,14 +5,12 @@
# R_EXECUTABLE - executable of R
# R_HOME - home directory of R
# R_INCLUDE_DIR - the R include directory
-# R_USED_LIBS - Link these to use R
+# R_LIBRARIES - Link these to use R
# find the R binary
FIND_PROGRAM(R_EXECUTABLE R)
-IF(R_EXECUTABLE-NOTFOUND)
- MESSAGE(STATUS "Could NOT find R ")
-ENDIF(R_EXECUTABLE-NOTFOUND)
+IF(R_EXECUTABLE)
# find R_HOME
IF(NOT R_HOME)
@@ -25,145 +23,78 @@
ENDIF(NOT R_HOME)
# find R include dir
-IF(NOT R_INCLUDEDIR)
+ IF(NOT R_INCLUDE_DIR)
IF(WIN32) # This version of the test will not work with R < 2.9.0, but the other version (in the else part) will not work on windows (and on windows the paths are generally standard, anyway).
EXECUTE_PROCESS(
COMMAND ${R_EXECUTABLE} "--slave" "--no-save" "-e" "cat(R.home('include'))"
- OUTPUT_VARIABLE R_INCLUDEDIR)
+ OUTPUT_VARIABLE R_INCLUDE_DIR)
ELSE(WIN32)
EXECUTE_PROCESS(
COMMAND ${R_EXECUTABLE} CMD sh -c "echo -n $R_INCLUDE_DIR"
- OUTPUT_VARIABLE R_INCLUDEDIR)
+ OUTPUT_VARIABLE R_INCLUDE_DIR)
ENDIF(WIN32)
-ENDIF(NOT R_INCLUDEDIR)
+ ENDIF(NOT R_INCLUDE_DIR)
-IF(NOT R_INCLUDEDIR)
- SET(R_INCLUDEDIR ${R_HOME}/include)
+ IF(NOT R_INCLUDE_DIR)
+ SET(R_INCLUDE_DIR ${R_HOME}/include)
MESSAGE(STATUS "R_Home not findable via R. Guessing")
-ENDIF(NOT R_INCLUDEDIR)
+ ENDIF(NOT R_INCLUDE_DIR)
-FIND_FILE(R_H
- R.h
- PATHS ${R_INCLUDEDIR}
- NO_DEFAULT_PATH)
-IF(NOT R_H)
- MESSAGE(STATUS "R.h Not found")
-ELSE(NOT R_H)
- GET_FILENAME_COMPONENT(R_INCLUDEDIR ${R_H}
- PATH)
-ENDIF(NOT R_H)
+ FIND_PATH(R_INCLUDE_DIR R.h)
# check for existence of libR.so
-FIND_LIBRARY(LIBR_SO
+ FIND_LIBRARY(R_R_LIBRARY
R
- PATHS ${R_HOME}/lib ${R_SHAREDLIBDIR} ${R_HOME}/bin
- NO_DEFAULT_PATH)
-IF(NOT LIBR_SO)
+ HINTS ${R_HOME}/lib ${R_SHARED_LIB_DIR} ${R_HOME}/bin )
+ IF(NOT R_R_LIBRARY)
MESSAGE(STATUS "libR not found. Make sure the location of R was detected correctly, above, and R was compiled with the --enable-shlib option")
-ELSE(NOT LIBR_SO)
- GET_FILENAME_COMPONENT(R_SHAREDLIBDIR ${LIBR_SO}
+ ELSE(NOT R_R_LIBRARY)
+ GET_FILENAME_COMPONENT(R_SHARED_LIB_DIR ${R_R_LIBRARY}
PATH)
- SET(R_USED_LIBS R)
-ENDIF(NOT LIBR_SO)
+ SET(R_LIBRARIES ${R_R_LIBRARY})
+ ENDIF(NOT R_R_LIBRARY)
# for at least some versions of R, we seem to have to link against -lRlapack. Else loading some
# R packages will fail due to unresolved symbols, or we can't link against -lR.
# However, we can't do this unconditionally,
# as this is not available in some configurations of R
-FIND_LIBRARY(LIBR_LAPACK
+ FIND_LIBRARY(R_LAPACK_LIBRARY
Rlapack
- PATHS ${R_SHAREDLIBDIR}
- NO_DEFAULT_PATH)
-IF(NOT LIBR_LAPACK)
- #MESSAGE(STATUS "No, it does not exist in ${R_SHAREDLIBDIR}")
-ELSE(NOT LIBR_LAPACK)
- #MESSAGE(STATUS "Yes, ${LIBR_LAPACK} exists")
- SET(R_USED_LIBS ${R_USED_LIBS} Rlapack)
+ HINTS ${R_SHARED_LIB_DIR} )
+ IF(NOT R_LAPACK_LIBRARY)
+ #MESSAGE(STATUS "No, it does not exist in ${R_SHARED_LIB_DIR}")
+ ELSE(NOT R_LAPACK_LIBRARY)
+ #MESSAGE(STATUS "Yes, ${R_LAPACK_LIBRARY} exists")
+ SET(R_LIBRARIES ${R_LIBRARIES} ${R_LAPACK_LIBRARY})
IF(NOT WIN32)
# needed when linking to Rlapack on linux for some unknown reason.
# apparently not needed on windows (let's see, when it comes back to bite us, though)
# and compiling on windows is hard enough even without requiring libgfortran, too.
- SET(R_USED_LIBS ${R_USED_LIBS} gfortran)
+ SET(R_LIBRARIES ${R_LIBRARIES} gfortran)
ENDIF(NOT WIN32)
-ENDIF(NOT LIBR_LAPACK)
+ ENDIF(NOT R_LAPACK_LIBRARY)
# for at least some versions of R, we seem to have to link against -lRlapack. Else loading some
# R packages will fail due to unresolved symbols, or we can't link against -lR.
# However, we can't do this unconditionally,
# as this is not available in some configurations of R
-FIND_LIBRARY(LIBR_BLAS
+ FIND_LIBRARY(R_BLAS_LIBRARY
Rblas
- PATHS ${R_SHAREDLIBDIR}
- NO_DEFAULT_PATH)
-IF(NOT LIBR_BLAS)
- #MESSAGE(STATUS "No, it does not exist in ${R_SHAREDLIBDIR}")
-ELSE(NOT LIBR_BLAS)
- #MESSAGE(STATUS "Yes, ${LIBR_BLAS} exists")
- SET(R_USED_LIBS ${R_USED_LIBS} Rblas)
-ENDIF(NOT LIBR_BLAS)
+ HINTS ${R_SHARED_LIB_DIR} )
+ IF(NOT R_BLAS_LIBRARY)
+ #MESSAGE(STATUS "No, it does not exist in ${R_SHARED_LIB_DIR}")
+ ELSE(NOT R_BLAS_LIBRARY)
+ #MESSAGE(STATUS "Yes, ${R_BLAS_LIBRARY} exists")
+ SET(R_LIBRARIES ${R_LIBRARIES} ${R_BLAS_LIBRARY})
+ ENDIF(NOT R_BLAS_LIBRARY)
-# find R package library location
-IF(WIN32)
- SET(PATH_SEP ";")
-ELSE(WIN32)
- SET(PATH_SEP ":")
-ENDIF(WIN32)
+ENDIF( R_EXECUTABLE )
-#Checking for R package library location to use
-IF(NOT R_LIBDIR)
- EXECUTE_PROCESS(
- COMMAND ${R_EXECUTABLE} "--slave" "--no-save" "-e" "cat(paste(unique (c(.Library.site, .Library)), collapse='${PATH_SEP}'))"
- OUTPUT_VARIABLE R_LIBDIR)
-ENDIF(NOT R_LIBDIR)
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(R DEFAULT_MSG
+ R_EXECUTABLE R_INCLUDE_DIR R_R_LIBRARY)
-# strip whitespace
-STRING(REGEX REPLACE "[ \n]+"
- "" R_LIBDIR
- "${R_LIBDIR}")
-
-# strip leading colon(s)
-STRING(REGEX REPLACE "^${PATH_SEP}+"
- "" R_LIBDIR
- "${R_LIBDIR}")
-
-# strip trailing colon(s)
-STRING(REGEX REPLACE "${PATH_SEP}+$"
- "" R_LIBDIR
- "${R_LIBDIR}")
-
-# find first path
-STRING(REGEX REPLACE "${PATH_SEP}"
- " " R_LIBDIR
- "${R_LIBDIR}")
-
-IF(NOT R_LIBDIR)
- MESSAGE(STATUS "R LibDir not reliably determined or specified. Guessing.")
- SET(R_LIBDIR ${R_HOME}/library)
-ENDIF(NOT 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})
- SET(USE_R_LIBDIR 1)
- 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(STATUS "No existing library location found")
-ENDIF(NOT EXISTS ${R_LIBDIR})
-
-IF( R_EXECUTABLE AND R_HOME AND R_H AND LIBR_SO AND R_LIBDIR )
- MESSAGE(STATUS "Found R at ${R_HOME}: using libraries ${R_USED_LIBS}")
- SET(R_FOUND TRUE)
-ENDIF(R_EXECUTABLE AND R_HOME AND R_H AND LIBR_SO AND R_LIBDIR )
+MARK_AS_ADVANCED(R_INCLUDE_DIR R_R_LIBRARY R_LAPACK_LIBRARY R_BLAS_LIBRARY)
More information about the Kde-buildsystem
mailing list