Ruby.cmake 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. enable_language(C)
  2. cmake_policy(SET CMP0185 NEW)
  3. set(Ruby_RBENV_EXECUTABLE "") # Suppress rbenv code path for this test.
  4. find_package(Ruby 1.9.9 REQUIRED)
  5. if (NOT Ruby_FOUND)
  6. message (FATAL_ERROR "Failed to find Ruby >=1.9.9")
  7. endif()
  8. if (NOT Ruby_Interpreter_FOUND)
  9. message (FATAL_ERROR "Failed to find Ruby 'Interpreter' component")
  10. endif()
  11. if (NOT Ruby_Development_FOUND)
  12. message (FATAL_ERROR "Failed to find Ruby 'Development' component")
  13. endif()
  14. foreach(var_CMP0185
  15. RUBY_EXECUTABLE
  16. RUBY_INCLUDE_DIRS
  17. RUBY_LIBRARY
  18. RUBY_VERSION
  19. )
  20. if(DEFINED ${var_CMP0185})
  21. message(FATAL_ERROR "Pre-CMP0185 result variable is set: ${var_CMP0185}")
  22. endif()
  23. endforeach()
  24. if(NOT TARGET Ruby::Interpreter)
  25. message(SEND_ERROR "Ruby::Interpreter not found")
  26. endif()
  27. if (NOT TARGET Ruby::Ruby)
  28. message(SEND_ERROR "Ruby::Ruby not found")
  29. endif()
  30. if (NOT TARGET Ruby::Module)
  31. message(SEND_ERROR "Ruby::Module not found")
  32. endif()
  33. add_executable(ruby_version_var "${CMAKE_CURRENT_LIST_DIR}/ruby_version.c")
  34. target_include_directories(ruby_version_var PRIVATE ${Ruby_INCLUDE_DIRS})
  35. target_link_libraries(ruby_version_var PRIVATE ${Ruby_LIBRARIES})
  36. add_test(NAME ruby_version_var COMMAND ruby_version_var)
  37. add_executable(ruby_version_tgt "${CMAKE_CURRENT_LIST_DIR}/ruby_version.c")
  38. target_link_libraries(ruby_version_tgt Ruby::Ruby)
  39. add_test(NAME ruby_version_tgt COMMAND ruby_version_tgt)