FindR.cmake 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. ################################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ################################################################################
  16. # - Try to find the R library
  17. # Once done this will define
  18. #
  19. # R_FOUND - system has the R library
  20. # R_INCLUDE_DIR - the R include directory(s)
  21. # R_LIBRARIES - The libraries needed to use R
  22. IF (NOT R_FOUND)
  23. IF (WIN32)
  24. SET (R_lib "libR")
  25. SET (Rcpp_lib "libRcpp")
  26. SET (RInside_lib "libRInside")
  27. ELSE()
  28. SET (R_lib "R")
  29. SET (Rcpp_lib "Rcpp")
  30. SET (RInside_lib "RInside")
  31. ENDIF()
  32. FIND_PATH(R_INCLUDE_DIR R.h PATHS /usr/lib /usr/lib64 /usr/share /usr/local/lib /usr/local/lib64 PATH_SUFFIXES R/include)
  33. FIND_PATH(RCPP_INCLUDE_DIR Rcpp.h PATHS /usr/lib /usr/lib64 /usr/share /usr/local/lib /usr/local/lib64 PATH_SUFFIXES R/library/Rcpp/include/ R/site-library/Rcpp/include/)
  34. FIND_PATH(RINSIDE_INCLUDE_DIR RInside.h PATHS /usr/lib /usr/lib64 /usr/share /usr/local/lib /usr/local/lib64 PATH_SUFFIXES R/library/RInside/include R/site-library/RInside/include)
  35. FIND_LIBRARY (R_LIBRARY NAMES ${R_lib} PATHS /usr/lib /usr/share /usr/lib64 /usr/local/lib /usr/local/lib64 PATH_SUFFIXES R/lib)
  36. FIND_LIBRARY (RCPP_LIBRARY NAMES ${Rcpp_lib} PATHS /usr/lib /usr/share /usr/lib64 /usr/local/lib /usr/local/lib64 PATH_SUFFIXES R/library/Rcpp/lib/ R/site-library/Rcpp/lib/)
  37. FIND_LIBRARY (RINSIDE_LIBRARY NAMES ${RInside_lib} PATHS /usr/lib /usr/share /usr/lib64 /usr/local/lib /usr/local/lib64 PATH_SUFFIXES R/library/RInside/lib/ R/site-library/RInside/lib/)
  38. IF (RCPP_LIBRARY STREQUAL "RCPP_LIBRARY-NOTFOUND")
  39. SET (RCPP_LIBRARY "") # Newer versions of Rcpp are header-only, with no associated library.
  40. ENDIF()
  41. SET (R_INCLUDE_DIRS ${R_INCLUDE_DIR} ${RINSIDE_INCLUDE_DIR} ${RCPP_INCLUDE_DIR})
  42. SET (R_LIBRARIES ${R_LIBRARY} ${RINSIDE_LIBRARY} ${RCPP_LIBRARY})
  43. include(FindPackageHandleStandardArgs)
  44. find_package_handle_standard_args(R DEFAULT_MSG
  45. R_LIBRARIES
  46. R_INCLUDE_DIRS
  47. )
  48. MARK_AS_ADVANCED(R_INCLUDE_DIRS R_LIBRARIES)
  49. ENDIF()