docs
This commit is contained in:
@@ -26,12 +26,212 @@
|
||||
# 2. Within an installed instance of R
|
||||
# 3. Within external system libraries
|
||||
#
|
||||
set_package_properties(R PROPERTIES
|
||||
DESCRIPTION "The R Project for Statistical Computing."
|
||||
URL "https://www.r-project.org/")
|
||||
|
||||
macro_optional_find_package (R ON)
|
||||
find_program (
|
||||
R_COMMAND
|
||||
NAMES R r
|
||||
)
|
||||
|
||||
if (R_LIBRARIES AND R_INCLUDE_DIR)
|
||||
if (R_COMMAND)
|
||||
# find the R binary
|
||||
|
||||
set (REAL_SOURCES
|
||||
MESSAGE(STATUS "Looking for R executable")
|
||||
IF(NOT R_EXECUTABLE)
|
||||
FIND_PROGRAM(R_EXECUTABLE R)
|
||||
IF(R_EXECUTABLE-NOTFOUND)
|
||||
MESSAGE(FATAL_ERROR "Could NOT find R (TODO: name option)")
|
||||
ELSE(R_EXECUTABLE-NOTFOUND)
|
||||
MESSAGE(STATUS "Using R at ${R_EXECUTABLE}")
|
||||
ENDIF(R_EXECUTABLE-NOTFOUND)
|
||||
|
||||
ENDIF(NOT R_EXECUTABLE)
|
||||
|
||||
|
||||
# find R_HOME
|
||||
|
||||
MESSAGE(STATUS "Looking for R_HOME")
|
||||
IF(NOT R_HOME)
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${R_EXECUTABLE} "--slave" "--no-save" "-e" "cat(R.home())"
|
||||
OUTPUT_VARIABLE R_HOME)
|
||||
ENDIF(NOT R_HOME)
|
||||
IF(NOT R_HOME)
|
||||
MESSAGE(FATAL_ERROR "Could NOT determine R_HOME (probably you misspecified the location of R)")
|
||||
ELSE(NOT R_HOME)
|
||||
MESSAGE(STATUS "R_HOME is ${R_HOME}")
|
||||
ENDIF(NOT R_HOME)
|
||||
|
||||
# find R include dir
|
||||
|
||||
MESSAGE(STATUS "Looking for R include files")
|
||||
IF(NOT R_INCLUDEDIR)
|
||||
IF(WIN32 OR APPLE) # 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 or apple (but we do not really need to support ancient versions of R, there).
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${R_EXECUTABLE} "--slave" "--no-save" "-e" "cat(R.home('include'))"
|
||||
OUTPUT_VARIABLE R_INCLUDEDIR)
|
||||
ELSE(WIN32 OR APPLE)
|
||||
EXECUTE_PROCESS(
|
||||
COMMAND ${R_EXECUTABLE} CMD sh -c "echo -n $R_INCLUDE_DIR"
|
||||
OUTPUT_VARIABLE R_INCLUDEDIR)
|
||||
ENDIF(WIN32 OR APPLE)
|
||||
ELSE(NOT R_INCLUDEDIR)
|
||||
MESSAGE(STATUS "Location specified by user")
|
||||
ENDIF(NOT R_INCLUDEDIR)
|
||||
|
||||
IF(NOT R_INCLUDEDIR)
|
||||
SET(R_INCLUDEDIR ${R_HOME}/include)
|
||||
MESSAGE(STATUS "Not findable via R. Guessing")
|
||||
ENDIF(NOT R_INCLUDEDIR)
|
||||
MESSAGE(STATUS "Include files should be at ${R_INCLUDEDIR}. Checking for R.h")
|
||||
|
||||
IF(NOT R_H)
|
||||
FIND_FILE(R_H
|
||||
R.h
|
||||
PATHS ${R_INCLUDEDIR}
|
||||
NO_DEFAULT_PATH)
|
||||
ENDIF(NOT R_H)
|
||||
|
||||
IF(NOT R_H)
|
||||
MESSAGE(FATAL_ERROR "Not found")
|
||||
ELSE(NOT R_H)
|
||||
MESSAGE(STATUS "Found at ${R_H}")
|
||||
GET_FILENAME_COMPONENT(R_INCLUDEDIR ${R_H}
|
||||
PATH)
|
||||
ENDIF(NOT R_H)
|
||||
|
||||
# check for existence of libR.so
|
||||
|
||||
IF(NOT LIBR_SO)
|
||||
MESSAGE(STATUS "Checking for existence of R shared library")
|
||||
FIND_LIBRARY(LIBR_SO
|
||||
R
|
||||
PATHS ${R_HOME}/lib ${R_SHAREDLIBDIR} ${R_HOME}/bin
|
||||
NO_DEFAULT_PATH)
|
||||
endif(NOT LIBR_SO)
|
||||
|
||||
|
||||
IF(NOT LIBR_SO)
|
||||
MESSAGE(FATAL_ERROR "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)
|
||||
MESSAGE(STATUS "Exists at ${LIBR_SO}")
|
||||
GET_FILENAME_COMPONENT(R_SHAREDLIBDIR ${LIBR_SO}
|
||||
PATH)
|
||||
SET(R_USED_LIBS R)
|
||||
ENDIF(NOT LIBR_SO)
|
||||
|
||||
|
||||
# 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
|
||||
|
||||
MESSAGE(STATUS "Checking whether we should link against Rlapack library")
|
||||
FIND_LIBRARY(LIBR_LAPACK
|
||||
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)
|
||||
IF(WIN32 OR APPLE)
|
||||
ELSE(WIN32 OR APPLE)
|
||||
# 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)
|
||||
ENDIF(WIN32 OR APPLE)
|
||||
ENDIF(NOT LIBR_LAPACK)
|
||||
|
||||
# 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
|
||||
|
||||
MESSAGE(STATUS "Checking whether we should link against Rblas library")
|
||||
FIND_LIBRARY(LIBR_BLAS
|
||||
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)
|
||||
|
||||
# find R package library location
|
||||
IF(WIN32)
|
||||
SET(PATH_SEP ";")
|
||||
ELSE(WIN32)
|
||||
SET(PATH_SEP ":")
|
||||
ENDIF(WIN32)
|
||||
|
||||
MESSAGE(STATUS "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)
|
||||
ELSE(NOT R_LIBDIR)
|
||||
MESSAGE(STATUS "Location specified by user")
|
||||
ENDIF(NOT R_LIBDIR)
|
||||
|
||||
# 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 "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(FATAL_ERROR "No existing library location found")
|
||||
ELSE(NOT EXISTS ${R_LIBDIR})
|
||||
MESSAGE(STATUS "Will use ${R_LIBDIR}")
|
||||
ENDIF(NOT EXISTS ${R_LIBDIR})
|
||||
endif()
|
||||
#macro_optional_find_package (R ON)
|
||||
|
||||
if (R_INCLUDEDIR AND R_LIBDIR)
|
||||
add_feature_info(R yes "Real")
|
||||
|
||||
set (REAL_SOURCES
|
||||
real.c
|
||||
)
|
||||
|
||||
@@ -43,7 +243,7 @@ add_to_group( REAL_PL pl_library)
|
||||
|
||||
include_directories (
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${R_INCLUDE_DIR}
|
||||
${R_INCLUDEDIR}
|
||||
)
|
||||
|
||||
list (APPEND CMAKE_REQUIRED_INCLUDES
|
||||
@@ -52,8 +252,8 @@ include_directories (
|
||||
)
|
||||
|
||||
add_lib(real ${REAL_SOURCES})
|
||||
|
||||
target_link_libraries (real ${R_LIBRARIES} libYap)
|
||||
link_directories(${R_LIBDIR})
|
||||
target_link_libraries (real R libYap)
|
||||
|
||||
check_include_files( "stdio.h;R.h" HAVE_R_H )
|
||||
check_include_files( "R.h;Rembedded.h" HAVE_R_EMBEDDED_H )
|
||||
|
@@ -5,11 +5,11 @@
|
||||
@version 1:0:4, 2013/12/25, sinter_class
|
||||
@license Perl Artistic License
|
||||
|
||||
@defgroup realmd The R Prolog Programming Interface
|
||||
@defgroup real The R Prolog Programming Interface
|
||||
@ingroup packages
|
||||
@{
|
||||
|
||||
+ @ref realpl
|
||||
+ @tableofcontents
|
||||
|
||||
This library enables the communication with an R process started as a shared library.
|
||||
It is the result of the efforts of two research groups that have worked in parallel.
|
||||
@@ -60,7 +60,7 @@ There is a raft of examples packed in a single file that tests the library.
|
||||
~~~~
|
||||
@}
|
||||
@defgroup RSyntax Prolog and R Syntax
|
||||
@ingroup realmd
|
||||
@ingroup real
|
||||
@{
|
||||
|
||||
There are syntactic conventions in R that make unparsable prolog code.
|
||||
@@ -166,7 +166,7 @@ atoms or codes with + as in the above example.
|
||||
|
||||
@}
|
||||
@defgroup RealExamples Examples
|
||||
@ingroup realmd
|
||||
@ingroup real
|
||||
@{
|
||||
|
||||
~~~~
|
||||
@@ -217,7 +217,7 @@ logical :-
|
||||
|
||||
@}
|
||||
@defgroup RealInfo Real Information
|
||||
@ingroup realmd
|
||||
@ingroup real
|
||||
@{
|
||||
|
||||
|
||||
@@ -230,229 +230,9 @@ logical :-
|
||||
|
||||
Also @ref yap-real describes the YAP specfic details in real.
|
||||
|
||||
@file real.md
|
||||
'
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll@}
|
||||
@}
|
||||
@defgroup yap_real Development of real in YAP
|
||||
@ingroup realmd
|
||||
@ingroup real
|
||||
@{
|
||||
|
||||
|
||||
@@ -461,7 +241,7 @@ with the internals of the implementation of R. It includes major
|
||||
changes and is likely to be much less stable than the version
|
||||
maintained by Nicos ANgelopoulos. We refer to the version herein as
|
||||
'realC' and describe the main novelties vs the version described
|
||||
in~\cite{}. Their major differences:
|
||||
in~\cite . Their major differences:
|
||||
|
||||
- Most of realC is written in `C`, instead of aa a Prolog string
|
||||
generator. The `C` code respects the SWI-Prolog fli interface and
|
||||
@@ -497,6 +277,7 @@ in~\cite{}. Their major differences:
|
||||
?- [examples/for_real].
|
||||
?- for_real.
|
||||
|
||||
@}
|
||||
|
||||
---
|
||||
- Nicos Angelopoulos and Vitor Santos Costa, December, 2012.
|
||||
@@ -506,4 +287,3 @@ in~\cite{}. Their major differences:
|
||||
- Updates: Vitor Santos Costa Dec. 2015
|
||||
|
||||
@}
|
||||
@}
|
||||
|
Reference in New Issue
Block a user