mirror of
https://git.gfz-potsdam.de/naaice/poet.git
synced 2025-12-15 12:28:22 +01:00
build: Refactor R runtime detection in CMake to ensure required parameters are set
This commit is contained in:
parent
66098aab40
commit
287eda880a
@ -1,8 +1,9 @@
|
|||||||
# prepare R environment (Rcpp + RInside)
|
# prepare R environment (Rcpp + RInside)
|
||||||
find_program(R_EXE "R")
|
find_program(R_EXE "R"
|
||||||
|
REQUIRED
|
||||||
|
)
|
||||||
|
|
||||||
# search for R executable, R header file and library path
|
# search for R executable, R header file and library path
|
||||||
if(R_EXE)
|
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${R_EXE} RHOME
|
COMMAND ${R_EXE} RHOME
|
||||||
OUTPUT_VARIABLE R_ROOT_DIR
|
OUTPUT_VARIABLE R_ROOT_DIR
|
||||||
@ -11,18 +12,16 @@ if(R_EXE)
|
|||||||
|
|
||||||
find_path(
|
find_path(
|
||||||
R_INCLUDE_DIR R.h
|
R_INCLUDE_DIR R.h
|
||||||
HINTS ${R_ROOT_DIR}
|
HINTS /usr/include /usr/local/include /usr/share ${R_ROOT_DIR}/include
|
||||||
PATHS /usr/include /usr/local/include /usr/share
|
PATH_SUFFIXES R/include R
|
||||||
PATH_SUFFIXES include/R R/include
|
REQUIRED
|
||||||
)
|
)
|
||||||
|
|
||||||
find_library(
|
find_library(
|
||||||
R_LIBRARY libR.so
|
R_LIBRARY libR.so
|
||||||
HINTS ${R_ROOT_DIR}/lib
|
HINTS ${R_ROOT_DIR}/lib
|
||||||
|
REQUIRED
|
||||||
)
|
)
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "No R runtime found!")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(R_LIBRARIES ${R_LIBRARY})
|
set(R_LIBRARIES ${R_LIBRARY})
|
||||||
set(R_INCLUDE_DIRS ${R_INCLUDE_DIR})
|
set(R_INCLUDE_DIRS ${R_INCLUDE_DIR})
|
||||||
@ -71,11 +70,8 @@ list(APPEND R_INCLUDE_DIRS ${R_RInside_INCLUDE_DIR})
|
|||||||
# putting all together into interface library
|
# putting all together into interface library
|
||||||
|
|
||||||
add_library(RRuntime INTERFACE IMPORTED)
|
add_library(RRuntime INTERFACE IMPORTED)
|
||||||
set_target_properties(
|
target_link_libraries(RRuntime INTERFACE ${R_LIBRARIES})
|
||||||
RRuntime PROPERTIES
|
target_include_directories(RRuntime INTERFACE ${R_INCLUDE_DIRS})
|
||||||
INTERFACE_LINK_LIBRARIES "${R_LIBRARIES}"
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${R_INCLUDE_DIRS}"
|
|
||||||
)
|
|
||||||
|
|
||||||
unset(R_LIBRARIES)
|
unset(R_LIBRARIES)
|
||||||
unset(R_INCLUDE_DIRS)
|
unset(R_INCLUDE_DIRS)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user