Skip to content

Commit 6d22952

Browse files
authored
check if R_HOME is defined
1 parent c67c281 commit 6d22952

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

cmake/FindR.cmake

+19-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,26 @@
77
# R_INCLUDE_DIR - the R include directory
88
# R_LIBRARIES - Link these to use R
99

10+
# Check if R_HOME is defined in the environment
11+
MACRO(SUBDIRLIST result curdir)
12+
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
13+
SET(dirlist "")
14+
FOREACH(child ${children})
15+
IF(IS_DIRECTORY ${curdir}/${child})
16+
LIST(APPEND dirlist ${curdir}/${child})
17+
ENDIF()
18+
ENDFOREACH()
19+
SET(${result} ${dirlist})
20+
ENDMACRO()
21+
1022
# find the R binary
11-
FIND_PROGRAM(R_EXECUTABLE R)
23+
SET(R_HOME $ENV{R_HOME})
24+
IF(R_HOME)
25+
SUBDIRLIST(SUBDIRS ${R_HOME})
26+
FIND_PROGRAM(R_EXECUTABLE R HINTS SUBDIRS)
27+
ELSE()
28+
FIND_PROGRAM(R_EXECUTABLE R)
29+
ENDIF()
1230

1331
SET(ABORT_CONFIG FALSE)
1432
IF(R_EXECUTABLE)

0 commit comments

Comments
 (0)