This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/cmake/FindR.cmake

78 lines
3.0 KiB
CMake
Raw Normal View History

2014-12-14 12:05:43 +00:00
#
2014-12-14 12:05:43 +00:00
# - This module locates an installed R distribution.
#
2014-12-14 12:05:43 +00:00
# Defines the following:
# R_COMMAND - Path to R command
# R_HOME - Path to 'R home', as reported by R
# R_INCLUDE_DIR - Path to R include directory
# R_LIBRARY_BASE - Path to R library
# R_LIBRARY_BLAS - Path to Rblas / blas library
# R_LIBRARY_LAPACK - Path to Rlapack / lapack library
# R_LIBRARY_READLINE - Path to readline library
# R_LIBRARIES - Array of: R_LIBRARY_BASE, R_LIBRARY_BLAS, R_LIBRARY_LAPACK, R_LIBRARY_BASE [, R_LIBRARY_READLINE]
#
2014-12-14 12:05:43 +00:00
# VTK_R_HOME - (deprecated, use R_HOME instead) Path to 'R home', as reported by R
#
2014-12-14 12:05:43 +00:00
# Variable search order:
# 1. Attempt to locate and set R_COMMAND
# - If unsuccessful, generate error and prompt user to manually set R_COMMAND
# 2. Use R_COMMAND to set R_HOME
# 3. Locate other libraries in the priority:
# 1. Within a user-built instance of R at R_HOME
# 2. Within an installed instance of R
# 3. Within external system libraries
#
2014-12-14 12:05:43 +00:00
set(TEMP_CMAKE_FIND_APPBUNDLE ${CMAKE_FIND_APPBUNDLE})
set(CMAKE_FIND_APPBUNDLE "NEVER")
find_program(R_COMMAND R DOC "R executable.")
set(CMAKE_FIND_APPBUNDLE ${TEMP_CMAKE_FIND_APPBUNDLE})
2014-12-14 12:05:43 +00:00
if(R_COMMAND)
execute_process(WORKING_DIRECTORY .
COMMAND ${R_COMMAND} RHOME
OUTPUT_VARIABLE R_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
# deprecated
if(VTK_R_HOME)
set(R_HOME ${VTK_R_HOME} CACHE PATH "R home directory obtained from R RHOME")
else()
set(R_HOME ${R_ROOT_DIR} CACHE PATH "R home directory obtained from R RHOME")
set(VTK_R_HOME ${R_HOME})
endif()
# /deprecated
# the following command does nothing currently, but will be used when deprecated code is removed
set(R_HOME ${R_ROOT_DIR} CACHE PATH "R home directory obtained from R RHOME")
2014-12-14 12:05:43 +00:00
find_path(R_INCLUDE_DIR R.h
HINTS ${R_ROOT_DIR}
PATHS /usr/local/lib /usr/local/lib64 /usr/share
PATH_SUFFIXES include R/include
DOC "Path to file R.h")
2014-12-14 12:05:43 +00:00
find_library(R_LIBRARY_BASE R
HINTS ${R_ROOT_DIR}/lib
DOC "R library (example libR.a, libR.dylib, etc.).")
2014-12-14 12:05:43 +00:00
find_library(R_LIBRARY_BLAS NAMES Rblas blas
HINTS ${R_ROOT_DIR}/lib
DOC "Rblas library (example libRblas.a, libRblas.dylib, etc.).")
2014-12-14 12:05:43 +00:00
find_library(R_LIBRARY_LAPACK NAMES Rlapack lapack
HINTS ${R_ROOT_DIR}/lib
DOC "Rlapack library (example libRlapack.a, libRlapack.dylib, etc.).")
2014-12-14 12:05:43 +00:00
find_library(R_LIBRARY_READLINE readline
DOC "(Optional) system readline library. Only required if the R libraries were built with readline support.")
2014-12-14 12:05:43 +00:00
else()
message(SEND_ERROR "FindR.cmake requires the following variables to be set: R_COMMAND")
endif()
2014-12-14 12:05:43 +00:00
# Note: R_LIBRARY_BASE is added to R_LIBRARIES twice; this may be due to circular linking dependencies; needs further investigation
set(R_LIBRARIES ${R_LIBRARY_BASE} ${R_LIBRARY_BLAS} ${R_LIBRARY_LAPACK} ${R_LIBRARY_BASE})
if(R_LIBRARY_READLINE)
set(R_LIBRARIES ${R_LIBRARIES} ${R_LIBRARY_READLINE})
endif()