Created
March 31, 2017 14:16
-
-
Save fikovnik/b910135cc457d5d0b1dd7ec9342665ab to your computer and use it in GitHub Desktop.
Getting R and Rcpp CPP and LD flags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set(NUM_TRUNC_CHARS 2) | |
| execute_process( | |
| COMMAND R CMD config --cppflags | |
| OUTPUT_VARIABLE RCPPFLAGS) | |
| string(SUBSTRING ${RCPPFLAGS} ${NUM_TRUNC_CHARS} -1 RCPPFLAGS) | |
| include_directories(${RCPPFLAGS}) | |
| message("R CPP flags: ${RCPPFLAGS}") | |
| execute_process( | |
| COMMAND R CMD config --ldflags | |
| OUTPUT_VARIABLE RLDFLAGS) | |
| string(LENGTH ${RLDFLAGS} RLDFLAGS_LEN) | |
| message("R LD flags: ${RLDFLAGS}") | |
| if (${RLDFLAGS} MATCHES "[-][L]([^ ;])+") | |
| string(SUBSTRING ${CMAKE_MATCH_0} ${NUM_TRUNC_CHARS} -1 RLDFLAGS_L) | |
| string(STRIP ${RLDFLAGS_L} RLDFLAGS_L ) | |
| link_directories(${RLDFLAGS_L}) | |
| endif() | |
| if (${RLDFLAGS} MATCHES "[-][l]([^;])+") | |
| string(SUBSTRING ${CMAKE_MATCH_0} ${NUM_TRUNC_CHARS} -1 RLDFLAGS_l) | |
| string(STRIP ${RLDFLAGS_l} RLDFLAGS_l ) | |
| link_libraries(${RLDFLAGS_l}) | |
| endif() | |
| execute_process( | |
| COMMAND Rscript -e "Rcpp:::CxxFlags()" | |
| OUTPUT_VARIABLE RCPPINCL) | |
| string(SUBSTRING ${RCPPINCL} ${NUM_TRUNC_CHARS} -1 RCPPINCL) | |
| include_directories(${RCPPINCL}) | |
| message("Rcpp CPP flags: ${RCPPINCL}") | |
| execute_process( | |
| COMMAND Rscript -e "Rcpp:::LdFlags()" | |
| OUTPUT_VARIABLE RCPPLIBS) | |
| if (${RCPPLIBS} MATCHES "[-][L]([^ ;])+") | |
| string(SUBSTRING ${CMAKE_MATCH_0} ${NUM_TRUNC_CHARS} -1 RCPPLIBS_L) | |
| link_directories(${RCPPLIBS_L} ) | |
| endif() | |
| message("Rcpp LD flags: ${RCPPLIBS}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment