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